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

This commit is contained in:
Nick Couchman authored and Nick Couchman committed 2017-06-05 15:34:21 -04:00
1 parent d0647ad6a4
commit 83a8e8223e
2 files changed
+8 -23

No files matched your search

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