mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-102: Correction to WLC algorithm to try to keep ratio no higher than configure weights.
This commit is contained in:
@@ -187,8 +187,24 @@ public class RestrictedGuacamoleTunnelService
|
||||
@Override
|
||||
public int compare(ModeledConnection a, ModeledConnection b) {
|
||||
|
||||
return ((getActiveConnections(a).size() + 1) * b.getConnectionWeight() -
|
||||
(getActiveConnections(b).size() + 1) * a.getConnectionWeight());
|
||||
// Active connections
|
||||
int Ca = getActiveConnections(a).size();
|
||||
int Cb = getActiveConnections(b).size();
|
||||
|
||||
// Assigned weight
|
||||
int Wa = a.getConnectionWeight();
|
||||
int Wb = b.getConnectionWeight();
|
||||
|
||||
// Net weight of connections
|
||||
int NWa = Ca * Wb;
|
||||
int NWb = Cb * Wa;
|
||||
|
||||
// If net weights are equal, return difference in weight
|
||||
if (NWa == NWb)
|
||||
return (Wa - Wb);
|
||||
|
||||
// Return different in net weights
|
||||
return (NWa - NWb);
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user