GUACAMOLE-102: Tweak algorithm for computing the WLC vlaues.

This commit is contained in:
Nick Couchman
2017-03-20 09:06:04 -04:00
committed by Nick Couchman
parent d0647ad6a4
commit 83a8e8223e
2 changed files with 8 additions and 23 deletions

View File

@@ -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;
}
}

View File

@@ -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;
}
});