mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUACAMOLE-102: Tweak algorithm for computing the WLC vlaues.
This commit is contained in:
committed by
Nick Couchman
parent
d0647ad6a4
commit
83a8e8223e
@@ -416,19 +416,12 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
|
||||
* @return
|
||||
* The weight of the connection.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while parsing the concurrency limit properties
|
||||
* specified within guacamole.properties.
|
||||
*/
|
||||
public int getConnectionWeight() throws GuacamoleException {
|
||||
public int getConnectionWeight() {
|
||||
|
||||
// Pull default from environment if weight is unset
|
||||
Integer value = getModel().getConnectionWeight();
|
||||
if (value == null)
|
||||
return environment.getDefaultConnectionWeight();
|
||||
// Return the connection weight
|
||||
return getModel().getConnectionWeight();
|
||||
|
||||
// Otherwise use defined value
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -192,21 +192,13 @@ public class RestrictedGuacamoleTunnelService
|
||||
|
||||
logger.trace("Comparing {} to {}.", a.getName(), b.getName());
|
||||
int cw = 0;
|
||||
int weightA = a.getConnectionWeight();
|
||||
int weightB = b.getConnectionWeight();
|
||||
int connsA = getActiveConnections(a).size();
|
||||
int connsB = getActiveConnections(b).size();
|
||||
|
||||
try {
|
||||
if(a.getConnectionWeight() > 0 && b.getConnectionWeight() > 0)
|
||||
cw = (int)(a.getConnectionWeight()/getActiveConnections(a).size() - b.getConnectionWeight()/getActiveConnections(b).size());
|
||||
else
|
||||
cw = getActiveConnections(a).size() - getActiveConnections(b).size();
|
||||
return (connsA * 10000 / weightA) - (connsB * 10000 / weightB);
|
||||
|
||||
}
|
||||
catch (GuacamoleException e) {
|
||||
logger.error("Could not compare connections.", e.getMessage());
|
||||
logger.debug("Could not compare connections.", e);
|
||||
}
|
||||
|
||||
return cw;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user