[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm /lonnet/perl lonnet.pm

raeburn raeburn at source.lon-capa.org
Sun May 4 23:24:41 EDT 2014


raeburn		Mon May  5 03:24:41 2014 EDT

  Modified files:              
    /loncom/auth	lonroles.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - Support situation where different servers belonging to user's (and course's)
    domain are running different versions of LON-CAPA, and role selected has a
    version requirement unmet by server currently hosting user session.
    - Additional arg passed to &choose_server() -- $skiploadbal (boolean)
      If true, a server identified in domain configuration as a loadbalancer
      will not be included when choosing from the domain's servers.
  
  
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.302 loncom/auth/lonroles.pm:1.303
--- loncom/auth/lonroles.pm:1.302	Sun May  4 21:49:05 2014
+++ loncom/auth/lonroles.pm	Mon May  5 03:24:37 2014
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.302 2014/05/04 21:49:05 raeburn Exp $
+# $Id: lonroles.pm,v 1.303 2014/05/05 03:24:37 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1758,7 +1758,7 @@
             my $otherserver;
             if (($major eq '' && $minor eq '') || 
                 (($reqdmajor > $major) || (($reqdmajor == $major) && ($reqdminor > $minor)))) {
-                my ($userdomserver) = &Apache::lonnet::choose_server($env{'user.domain'},undef,$required);
+                my ($userdomserver) = &Apache::lonnet::choose_server($env{'user.domain'},undef,$required,1);
                 my $switchlcrev = 
                     &Apache::lonnet::get_server_loncaparev($env{'user.domain'},
                                                            $userdomserver);
@@ -1767,7 +1767,7 @@
                     (($reqdmajor == $swmajor) && ($reqdminor > $swminor))) {
                     my $cdom = $env{'course.'.$tcourseid.'.domain'};
                     if ($cdom ne $env{'user.domain'}) {
-                        my ($coursedomserver,$coursehostname) = &Apache::lonnet::choose_server($cdom); 
+                        my ($coursedomserver,$coursehostname) = &Apache::lonnet::choose_server($cdom,undef,$required,1); 
                         my $serverhomeID = &Apache::lonnet::get_server_homeID($coursehostname);
                         my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID);
                         my %defdomdefaults = &Apache::lonnet::get_domain_defaults($serverhomedom);
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1258 loncom/lonnet/perl/lonnet.pm:1.1259
--- loncom/lonnet/perl/lonnet.pm:1.1258	Sun May  4 21:49:00 2014
+++ loncom/lonnet/perl/lonnet.pm	Mon May  5 03:24:40 2014
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1258 2014/05/04 21:49:00 raeburn Exp $
+# $Id: lonnet.pm,v 1.1259 2014/05/05 03:24:40 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -961,12 +961,29 @@
 # --------- determine least loaded server in a user's domain which allows login
 
 sub choose_server {
-    my ($udom,$checkloginvia,$required) = @_;
+    my ($udom,$checkloginvia,$required,$skiploadbal) = @_;
     my %domconfhash = &Apache::loncommon::get_domainconf($udom);
     my %servers = &get_servers($udom);
     my $lowest_load = 30000;
-    my ($login_host,$hostname,$portal_path,$isredirect);
+    my ($login_host,$hostname,$portal_path,$isredirect,$balancers);
+    if ($skiploadbal) {
+        ($balancers,my $cached)=&is_cached_new('loadbalancing',$udom);
+        unless (defined($cached)) {
+            my $cachetime = 60*60*24;
+            my %domconfig =
+                &Apache::lonnet::get_dom('configuration',['loadbalancing'],$udom);
+            if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
+                $balancers = &do_cache_new('loadbalancing',$udom,$domconfig{'loadbalancing'},
+                                           $cachetime);
+            }
+        }
+    }
     foreach my $lonhost (keys(%servers)) {
+        if ($skiploadbal) {
+            if (ref($balancers) eq 'HASH') {
+                next if (exists($balancers->{$lonhost}));
+            }
+        }   
         my $loginvia;
         if ($checkloginvia) {
             $loginvia = $domconfhash{$udom.'.login.loginvia_'.$lonhost};




More information about the LON-CAPA-cvs mailing list