GUACAMOLE-102: Remove some extra debugging code, and continue to tweak the WLC 
algorithm.


Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/15869fef
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/15869fef
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/15869fef

Branch: refs/heads/master
Commit: 15869fef0d300c8a48e9ac91e6862a9d3c9fb837
Parents: 83a8e82
Author: Nick Couchman <[email protected]>
Authored: Mon Mar 20 09:55:41 2017 -0400
Committer: Nick Couchman <[email protected]>
Committed: Mon Jun 5 15:34:21 2017 -0400

----------------------------------------------------------------------
 .../tunnel/RestrictedGuacamoleTunnelService.java     | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/15869fef/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/tunnel/RestrictedGuacamoleTunnelService.java
----------------------------------------------------------------------
diff --git 
a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/tunnel/RestrictedGuacamoleTunnelService.java
 
b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/tunnel/RestrictedGuacamoleTunnelService.java
index ae7a059..8cc6605 100644
--- 
a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/tunnel/RestrictedGuacamoleTunnelService.java
+++ 
b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/tunnel/RestrictedGuacamoleTunnelService.java
@@ -173,16 +173,13 @@ public class RestrictedGuacamoleTunnelService
     protected ModeledConnection acquire(RemoteAuthenticatedUser user,
             List<ModeledConnection> connections) throws GuacamoleException {
 
-        logger.trace("Attempting to acquire a connection...");
         // Do not acquire connection unless within overall limits
         if (!tryIncrement(totalActiveConnections, 
environment.getAbsoluteMaxConnections()))
             throw new GuacamoleResourceConflictException("Cannot connect. 
Overall maximum connections reached.");
 
         // Get username
         String username = user.getIdentifier();
-        logger.trace("Username is: {}", username);
 
-        logger.trace("Sorting {} connections.", connections.size());
         // Sort connections in ascending order of usage
         ModeledConnection[] sortedConnections = connections.toArray(new 
ModeledConnection[connections.size()]);
         Arrays.sort(sortedConnections, new Comparator<ModeledConnection>() {
@@ -190,12 +187,14 @@ public class RestrictedGuacamoleTunnelService
             @Override
             public int compare(ModeledConnection a, ModeledConnection b) {
                 
-                logger.trace("Comparing {} to {}.", a.getName(), b.getName());
+                logger.debug("Calculating weights for connections {} and {}.", 
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();
+                logger.debug("Connection {} has computed weight of {}.", 
a.getName(), connsA * 10000 / weightA);
+                logger.debug("Connection {} has computed weight of {}.", 
b.getName(), connsB * 10000 / weightB);
 
                 return (connsA * 10000 / weightA) - (connsB * 10000 / weightB);
 
@@ -209,19 +208,20 @@ public class RestrictedGuacamoleTunnelService
         // Return the first unreserved connection
         for (ModeledConnection connection : sortedConnections) {
 
+            // If connection weight is negative, this host is disabled and 
should not be used.
+            if (connection.getConnectionWeight() < 0)
+                continue;
+
             // Attempt to aquire connection according to per-user limits
-            logger.trace("Trying to grab a seat on this train: {}", 
connection.getName());
             Seat seat = new Seat(username, connection.getIdentifier());
             if (tryAdd(activeSeats, seat,
                     connection.getMaxConnectionsPerUser())) {
 
-                logger.trace("Got a seat, trying to get the connection...");
                 // Attempt to aquire connection according to overall limits
                 if (tryAdd(activeConnections, connection.getIdentifier(),
                         connection.getMaxConnections()))
                     return connection;
 
-                logger.trace("Uh-oh, failed to get the connection...");
                 // Acquire failed - retry with next connection
                 activeSeats.remove(seat);
 
@@ -232,7 +232,6 @@ public class RestrictedGuacamoleTunnelService
 
         }
 
-        logger.trace("Well, we failed to get a seat at all...");
         // Acquire failed
         totalActiveConnections.decrementAndGet();
 

Reply via email to