[LON-CAPA-cvs] cvs: loncom /auth lonlogin.pm /lonnet/perl lonnet.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Thu, 08 May 2003 21:50:54 -0000
albertel Thu May 8 17:50:54 2003 EDT
Modified files:
/loncom/auth lonlogin.pm
/loncom/lonnet/perl lonnet.pm
Log:
- user login load balancing should work now BUG#958
Index: loncom/auth/lonlogin.pm
diff -u loncom/auth/lonlogin.pm:1.40 loncom/auth/lonlogin.pm:1.41
--- loncom/auth/lonlogin.pm:1.40 Thu Apr 3 16:53:51 2003
+++ loncom/auth/lonlogin.pm Thu May 8 17:50:54 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Login Screen
#
-# $Id: lonlogin.pm,v 1.40 2003/04/03 21:53:51 albertel Exp $
+# $Id: lonlogin.pm,v 1.41 2003/05/08 21:50:54 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -89,20 +89,22 @@
# ---------------------------------------------------------- Determine own load
my $loadavg;
- {
- my $loadfile=Apache::File->new('/proc/loadavg');
- $loadavg=<$loadfile>;
- }
+ {
+ my $loadfile=Apache::File->new('/proc/loadavg');
+ $loadavg=<$loadfile>;
+ }
$loadavg =~ s/\s.*//g;
my $loadpercent=100*$loadavg/$loadlim;
+ my $userloadpercent=&Apache::lonnet::userload();
# ------------------------------------------------------- Do the load balancing
my $otherserver='http://'.$ENV{'SERVER_NAME'};
my $firsturl=
($ENV{'request.firsturl'}?$ENV{'request.firsturl'}:$ENV{'form.firsturl'});
# ---------------------------------------- Are we access server and overloaded?
- if (($role eq 'access') && ($loadpercent>100.0)) {
- $otherserver=Apache::lonnet::spareserver($loadpercent);
+ if (($role eq 'access') &&
+ (($userloadpercent>100.0)||($loadpercent>100.0))) {
+ $otherserver=Apache::lonnet::spareserver($loadpercent,$userloadpercent);
}
# -------------------------------------------------------- Set login parameters
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.369 loncom/lonnet/perl/lonnet.pm:1.370
--- loncom/lonnet/perl/lonnet.pm:1.369 Thu May 8 17:35:48 2003
+++ loncom/lonnet/perl/lonnet.pm Thu May 8 17:50:54 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.369 2003/05/08 21:35:48 albertel Exp $
+# $Id: lonnet.pm,v 1.370 2003/05/08 21:50:54 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -396,17 +396,23 @@
# ------------------------------ Find server with least workload from spare.tab
sub spareserver {
- my $loadpercent = shift;
+ my ($loadpercent,$userloadpercent) = @_;
my $tryserver;
my $spareserver='';
- my $lowestserver=$loadpercent;
+ if ($userloadpercent !~ /\d/) { $userloadpercent=0; }
+ my $lowestserver=$loadpercent > $userloadpercent?
+ $loadpercent : $userloadpercent;
foreach $tryserver (keys %spareid) {
- my $answer=reply('load',$tryserver);
+ my $loadans=reply('load',$tryserver);
+ my $userloadans=reply('userload',$tryserver);
+ if ($userloadans !~ /\d/) { $userloadans=0; }
+ my $answer=$loadans > $userloadans?
+ $loadans : $userloadans;
if (($answer =~ /\d/) && ($answer<$lowestserver)) {
$spareserver="http://$hostname{$tryserver}";
$lowestserver=$answer;
}
- }
+ }
return $spareserver;
}