--- loncom/interface/domainprefs.pm 2018/11/18 22:50:52 1.341
+++ loncom/interface/domainprefs.pm 2018/11/24 16:48:01 1.342
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.341 2018/11/18 22:50:52 raeburn Exp $
+# $Id: domainprefs.pm,v 1.342 2018/11/24 16:48:01 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -6339,13 +6339,13 @@ sub print_loadbalancing {
my $numinrow = 1;
my $datatable;
my %servers = &Apache::lonnet::internet_dom_servers($dom);
- my (%currbalancer,%currtargets,%currrules,%existing);
+ my (%currbalancer,%currtargets,%currrules,%existing,%currcookies);
if (ref($settings) eq 'HASH') {
%existing = %{$settings};
}
if ((keys(%servers) > 1) || (keys(%existing) > 0)) {
&get_loadbalancers_config(\%servers,\%existing,\%currbalancer,
- \%currtargets,\%currrules);
+ \%currtargets,\%currrules,\%currcookies);
} else {
return;
}
@@ -6422,6 +6422,9 @@ sub print_loadbalancing {
my %hostherechecked = (
no => ' checked="checked"',
);
+ my %balcookiechecked = (
+ no => ' checked="checked"',
+ );
foreach my $sparetype (@sparestypes) {
my $targettable;
for (my $i=0; $i<$numspares; $i++) {
@@ -6477,6 +6480,11 @@ sub print_loadbalancing {
}
}
}
+ if ($currcookies{$lonhost}) {
+ %balcookiechecked = (
+ yes => ' checked="checked"',
+ );
+ }
$datatable .= &mt('Hosting on balancer itself').'
'.
'
';
@@ -6485,7 +6493,12 @@ sub print_loadbalancing {
'value="'.$sparetype.'"'.$hostherechecked{$sparetype}.' />'.$typetitles{$sparetype}.
'
';
}
- $datatable .= ''.
+ $datatable .= &mt('Use balancer cookie').'
'.
+ '
'.
+ '
'.
+ ''.
&loadbalancing_rules($dom,$intdom,$currrules{$lonhost},
$othertitle,$usertypes,$types,\%servers,
\%currbalancer,$lonhost,
@@ -6499,10 +6512,11 @@ sub print_loadbalancing {
}
sub get_loadbalancers_config {
- my ($servers,$existing,$currbalancer,$currtargets,$currrules) = @_;
+ my ($servers,$existing,$currbalancer,$currtargets,$currrules,$currcookies) = @_;
return unless ((ref($servers) eq 'HASH') &&
(ref($existing) eq 'HASH') && (ref($currbalancer) eq 'HASH') &&
- (ref($currtargets) eq 'HASH') && (ref($currrules) eq 'HASH'));
+ (ref($currtargets) eq 'HASH') && (ref($currrules) eq 'HASH') &&
+ (ref($currcookies) eq 'HASH'));
if (keys(%{$existing}) > 0) {
my $oldlonhost;
foreach my $key (sort(keys(%{$existing}))) {
@@ -6521,6 +6535,9 @@ sub get_loadbalancers_config {
$currbalancer->{$key} = 1;
$currtargets->{$key} = $existing->{$key}{'targets'};
$currrules->{$key} = $existing->{$key}{'rules'};
+ if ($existing->{$key}{'cookie'}) {
+ $currcookies->{$key} = 1;
+ }
}
}
} else {
@@ -17003,12 +17020,12 @@ sub modify_loadbalancing {
my @sparestypes = ('primary','default');
my %typetitles = &sparestype_titles();
my $resulttext;
- my (%currbalancer,%currtargets,%currrules,%existing);
+ my (%currbalancer,%currtargets,%currrules,%existing,%currcookies);
if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
%existing = %{$domconfig{'loadbalancing'}};
}
&get_loadbalancers_config(\%servers,\%existing,\%currbalancer,
- \%currtargets,\%currrules);
+ \%currtargets,\%currrules,\%currcookies);
my ($saveloadbalancing,%defaultshash,%changes);
my ($alltypes,$othertypes,$titles) =
&loadbalancing_titles($dom,$intdom,$usertypes,$types);
@@ -17060,6 +17077,18 @@ sub modify_loadbalancing {
}
$defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype} = \@offloadto;
}
+ if ($env{'form.loadbalancing_cookie_'.$i}) {
+ $defaultshash{'loadbalancing'}{$balancer}{'cookie'} = 1;
+ if (exists($currbalancer{$balancer})) {
+ unless ($currcookies{$balancer}) {
+ $changes{'curr'}{$balancer}{'cookie'} = 1;
+ }
+ }
+ } elsif (exists($currbalancer{$balancer})) {
+ if ($currcookies{$balancer}) {
+ $changes{'curr'}{$balancer}{'cookie'} = 1;
+ }
+ }
if (ref($currtargets{$balancer}) eq 'HASH') {
foreach my $sparetype (@sparestypes) {
if (ref($currtargets{$balancer}{$sparetype}) eq 'ARRAY') {
@@ -17213,6 +17242,10 @@ sub modify_loadbalancing {
}
}
}
+ if ($changes{'curr'}{$balancer}{'cookie'}) {
+ $resulttext .= '