You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by mj...@apache.org on 2017/06/07 00:32:21 UTC
[01/28] incubator-guacamole-client git commit: GUACAMOLE-102: Initial
addition of connection weight to JDBC authentication extension
Repository: incubator-guacamole-client
Updated Branches:
refs/heads/master 91920d0b2 -> eb087ae29
GUACAMOLE-102: Initial addition of connection weight to JDBC authentication extension
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/025f77d1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/025f77d1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/025f77d1
Branch: refs/heads/master
Commit: 025f77d1c40547abafa3a5ed18f341804883493b
Parents: 91920d0
Author: Nick Couchman <vn...@apache.org>
Authored: Sun Mar 19 11:57:28 2017 -0400
Committer: Nick Couchman <ni...@yahoo.com>
Committed: Mon Jun 5 15:33:23 2017 -0400
----------------------------------------------------------------------
.../guacamole/auth/jdbc/JDBCEnvironment.java | 11 +++++++
.../auth/jdbc/connection/ConnectionModel.java | 30 +++++++++++++++++
.../auth/jdbc/connection/ModeledConnection.java | 34 ++++++++++++++++++++
.../RestrictedGuacamoleTunnelService.java | 17 +++++++++-
.../schema/001-create-schema.sql | 5 ++-
.../schema/upgrade/upgrade-pre-0.9.12.sql | 25 ++++++++++++++
.../guacamole/auth/mysql/MySQLEnvironment.java | 13 ++++++++
.../auth/mysql/MySQLGuacamoleProperties.java | 12 +++++++
.../auth/postgresql/PostgreSQLEnvironment.java | 13 ++++++++
.../PostgreSQLGuacamoleProperties.java | 9 ++++++
.../auth/jdbc/connection/ConnectionMapper.xml | 19 +++++++----
11 files changed, 180 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/025f77d1/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/JDBCEnvironment.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/JDBCEnvironment.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/JDBCEnvironment.java
index dfbf0e9..64f2449 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/JDBCEnvironment.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/JDBCEnvironment.java
@@ -81,6 +81,17 @@ public abstract class JDBCEnvironment extends LocalEnvironment {
* If an error occurs while retrieving the property.
*/
public abstract int getDefaultMaxConnections() throws GuacamoleException;
+
+ /**
+ * Returns the connection weight for the purpose of WRR calculation
+ *
+ * @return
+ * The weight of the connection.
+ *
+ * @throws GuacamoleException
+ * If an error occurs while retrieving the property.
+ */
+ public abstract int getConnectionWeight() throws GuacamoleException;
/**
* Returns the default maximum number of concurrent connections to allow to
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/025f77d1/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
index 44f4b3b..91dd42c 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
@@ -55,6 +55,13 @@ public class ConnectionModel extends ChildObjectModel {
private Integer maxConnectionsPerUser;
/**
+ * The weight of the connection for the purposes of calculating
+ * WRR algorithm. null indicates nothing has been set, -1 indicates
+ * the system is unavailable.
+ */
+ private Integer connectionWeight;
+
+ /**
* The identifiers of all readable sharing profiles associated with this
* connection.
*/
@@ -165,6 +172,29 @@ public class ConnectionModel extends ChildObjectModel {
}
/**
+ * Sets the connection weight.
+ *
+ * @param connectionWeight
+ * The weight of the connection. null is acceptable, -1 indicates the
+ * connection should not be used.
+ */
+ public void setConnectionWeight(Integer connectionWeight) {
+ this.connectionWeight = connectionWeight;
+ }
+
+ /**
+ * Returns the connection weight used in calculating the
+ * WRR algorithm.
+ *
+ * @return
+ * The connection weight. Null indicates no weight has been set,
+ * -1 indicates that the system is unavailable.
+ */
+ public Integer getConnectionWeight() {
+ return connectionWeight;
+ }
+
+ /**
* Sets the maximum number of connections that can be established to this
* connection concurrently by any one user.
*
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/025f77d1/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
index bcd7b11..93a7329 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
@@ -117,6 +117,11 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
public static final String MAX_CONNECTIONS_PER_USER_NAME = "max-connections-per-user";
/**
+ * The connection weight for the WRR algorithm.
+ */
+ public static final String CONNECTION_WEIGHT = "connection-weight";
+
+ /**
* All attributes related to restricting user accounts, within a logical
* form.
*/
@@ -265,6 +270,9 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
}
}
+ // Set connection weight
+ attributes.put(CONNECTION_WEIGHT, NumericField.format(getModel().getConnectionWeight()));
+
return attributes;
}
@@ -310,6 +318,13 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
else
getModel().setProxyEncryptionMethod(null);
+ // Translate connection weight attribute
+ try { getModel().setConnectionWeight(NumericField.parse(attributes.get(CONNECTION_WEIGHT))); }
+ catch (NumberFormatException e) {
+ logger.warn("Not setting the connection weight: {}", e.getMessage());
+ logger.debug("Unable to parse numeric attribute.", e);
+ }
+
}
/**
@@ -394,6 +409,25 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
encryptionMethod != null ? encryptionMethod : defaultConfig.getEncryptionMethod()
);
+ /**
+ * Returns the weight of the connection, or the default.
+ *
+ * @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 {
+
+ // Pull default from environment if weight is unset
+ Integer value = getModel().getConnectionWeight();
+ if (value == null)
+ return environment.getDefaultConnectionWeight();
+
+ // Otherwise use defined value
+ return value;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/025f77d1/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 e68c9cb..9c01917 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
@@ -33,6 +33,8 @@ import org.apache.guacamole.GuacamoleResourceConflictException;
import org.apache.guacamole.auth.jdbc.JDBCEnvironment;
import org.apache.guacamole.auth.jdbc.connectiongroup.ModeledConnectionGroup;
import org.apache.guacamole.auth.jdbc.user.RemoteAuthenticatedUser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
@@ -45,6 +47,11 @@ public class RestrictedGuacamoleTunnelService
extends AbstractGuacamoleTunnelService {
/**
+ * Logger for this class.
+ */
+ private static final Logger logger = LoggerFactory.getLogger(RestrictedGuacamoleTunnelService.class);
+
+ /**
* The environment of the Guacamole server.
*/
@Inject
@@ -166,20 +173,24 @@ 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>() {
@Override
public int compare(ModeledConnection a, ModeledConnection b) {
-
+
+ logger.trace("Comparing {} to {}.", a.getName(), b.getName());
return getActiveConnections(a).size()
- getActiveConnections(b).size();
@@ -194,15 +205,18 @@ public class RestrictedGuacamoleTunnelService
for (ModeledConnection connection : sortedConnections) {
// 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);
@@ -213,6 +227,7 @@ public class RestrictedGuacamoleTunnelService
}
+ logger.trace("Well, we failed to get a seat at all...");
// Acquire failed
totalActiveConnections.decrementAndGet();
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/025f77d1/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/001-create-schema.sql
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/001-create-schema.sql b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/001-create-schema.sql
index 519d5ca..2f0aa73 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/001-create-schema.sql
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/001-create-schema.sql
@@ -34,7 +34,6 @@ CREATE TABLE `guacamole_connection_group` (
`max_connections_per_user` int(11),
`enable_session_affinity` boolean NOT NULL DEFAULT 0,
-
PRIMARY KEY (`connection_group_id`),
UNIQUE KEY `connection_group_name_parent` (`connection_group_name`, `parent_id`),
@@ -65,6 +64,10 @@ CREATE TABLE `guacamole_connection` (
-- Concurrency limits
`max_connections` int(11),
`max_connections_per_user` int(11),
+
+ -- Connection weight
+ `connection_weight` int(11),
+
PRIMARY KEY (`connection_id`),
UNIQUE KEY `connection_name_parent` (`connection_name`, `parent_id`),
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/025f77d1/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/upgrade/upgrade-pre-0.9.12.sql
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/upgrade/upgrade-pre-0.9.12.sql b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/upgrade/upgrade-pre-0.9.12.sql
new file mode 100644
index 0000000..48e2dd1
--- /dev/null
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/upgrade/upgrade-pre-0.9.12.sql
@@ -0,0 +1,25 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied. See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+--
+
+--
+-- Add per-user password set date
+--
+
+ALTER TABLE guacamole_connection
+ ADD COLUMN connection_weight int(11);
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/025f77d1/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLEnvironment.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLEnvironment.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLEnvironment.java
index 19a8ef4..63d4ae3 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLEnvironment.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLEnvironment.java
@@ -88,6 +88,11 @@ public class MySQLEnvironment extends JDBCEnvironment {
private int DEFAULT_MAX_CONNECTIONS = 0;
/**
+ * The default value for the connection weight for a connection in
+ * a balancing group.
+ private int DEFAULT_CONNECTION_WEIGHT = 0;
+
+ /**
* The default value for the default maximum number of connections to be
* allowed to any one connection group. Note that, as long as the legacy
* "disallow duplicate" and "disallow simultaneous" properties are still
@@ -195,6 +200,14 @@ public class MySQLEnvironment extends JDBCEnvironment {
}
@Override
+ public int getDefaultConnectionWeight() throws GuacamoleException {
+ return getProperty(
+ MySQLGuacamoleProperties.MYSQL_DEFAULT_CONNECTION_WEIGHT,
+ DEFAULT_CONNECTION_WEIGHT
+ );
+ }
+
+ @Override
public int getDefaultMaxGroupConnections() throws GuacamoleException {
return getProperty(
MySQLGuacamoleProperties.MYSQL_DEFAULT_MAX_GROUP_CONNECTIONS,
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/025f77d1/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLGuacamoleProperties.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLGuacamoleProperties.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLGuacamoleProperties.java
index 9039c02..79f3e7f 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLGuacamoleProperties.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLGuacamoleProperties.java
@@ -175,6 +175,18 @@ public class MySQLGuacamoleProperties {
};
/**
+ * The connection weight for connections in balancing groups.
+ */
+ public static final IntegerGuacamoleProperty
+ MYSQL_DEFAULT_CONNECTION_WEIGHT =
+ new IntegerGuacamoleProperty() {
+
+ @Overide
+ public String getName() { return "mysql-default-connection-weight"; }
+
+ };
+
+ /**
* The maximum number of concurrent connections to allow to any one
* connection group by an individual user. Zero denotes
* unlimited.
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/025f77d1/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLEnvironment.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLEnvironment.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLEnvironment.java
index e0ee75f..5399417 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLEnvironment.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLEnvironment.java
@@ -88,6 +88,11 @@ public class PostgreSQLEnvironment extends JDBCEnvironment {
private int DEFAULT_MAX_CONNECTIONS = 0;
/**
+ * The default value for the connection weight for a connection in
+ * a balancing group.
+ private int DEFAULT_CONNECTION_WEIGHT = 0;
+
+ /**
* The default value for the default maximum number of connections to be
* allowed to any one connection group. Note that, as long as the legacy
* "disallow duplicate" and "disallow simultaneous" properties are still
@@ -195,6 +200,14 @@ public class PostgreSQLEnvironment extends JDBCEnvironment {
}
@Override
+ public int getDefaultConnectionWeight() throws GuacamoleException {
+ return getProperty(
+ PostgreSQLGuacamoleProperties.POSTGRESQL_DEFAULT_CONNECTION_WEIGHT,
+ DEFAULT_CONNECTION_WEIGHT
+ );
+ }
+
+ @Override
public int getDefaultMaxGroupConnections() throws GuacamoleException {
return getProperty(
PostgreSQLGuacamoleProperties.POSTGRESQL_DEFAULT_MAX_GROUP_CONNECTIONS,
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/025f77d1/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLGuacamoleProperties.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLGuacamoleProperties.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLGuacamoleProperties.java
index 3da972f..3ae83ab 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLGuacamoleProperties.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLGuacamoleProperties.java
@@ -157,6 +157,15 @@ public class PostgreSQLGuacamoleProperties {
};
+ public static final IntegerGuacamoleProperty
+ POSTGRESQL_DEFAULT_CONNECTION_WEIGHT =
+ new IntegerGuacamoleProperty() {
+
+ @Override
+ public String getName() { return "postgresql-default-connection-weight"; }
+
+ };
+
/**
* The maximum number of concurrent connections to allow to any one
* connection group. Zero denotes unlimited.
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/025f77d1/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionMapper.xml
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionMapper.xml
index 44828fa..f53e439 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionMapper.xml
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionMapper.xml
@@ -37,6 +37,7 @@
<result column="proxy_port" property="proxyPort" jdbcType="INTEGER"/>
<result column="proxy_encryption_method" property="proxyEncryptionMethod" jdbcType="VARCHAR"
javaType="org.apache.guacamole.net.auth.GuacamoleProxyConfiguration$EncryptionMethod"/>
+ <result column="connection_weight" property="connectionWeight" jdbcType="INTEGER"/>
<!-- Associated sharing profiles -->
<collection property="sharingProfileIdentifiers" resultSet="sharingProfiles" ofType="java.lang.String"
@@ -95,7 +96,8 @@
max_connections_per_user,
proxy_hostname,
proxy_port,
- proxy_encryption_method
+ proxy_encryption_method,
+ connection_weight
FROM guacamole_connection
WHERE connection_id IN
<foreach collection="identifiers" item="identifier"
@@ -126,7 +128,8 @@
max_connections_per_user,
proxy_hostname,
proxy_port,
- proxy_encryption_method
+ proxy_encryption_method,
+ connection_weight
FROM guacamole_connection
JOIN guacamole_connection_permission ON guacamole_connection_permission.connection_id = guacamole_connection.connection_id
WHERE guacamole_connection.connection_id IN
@@ -162,7 +165,8 @@
max_connections_per_user,
proxy_hostname,
proxy_port,
- proxy_encryption_method
+ proxy_encryption_method,
+ connection_weight
FROM guacamole_connection
WHERE
<if test="parentIdentifier != null">parent_id = #{parentIdentifier,jdbcType=INTEGER}::integer</if>
@@ -189,7 +193,8 @@
max_connections_per_user,
proxy_hostname,
proxy_port,
- proxy_encryption_method
+ proxy_encryption_method,
+ connection_weight
)
VALUES (
#{object.name,jdbcType=VARCHAR},
@@ -199,7 +204,8 @@
#{object.maxConnectionsPerUser,jdbcType=INTEGER},
#{object.proxyHostname,jdbcType=VARCHAR},
#{object.proxyPort,jdbcType=INTEGER},
- #{object.proxyEncryptionMethod,jdbcType=VARCHAR}::guacamole_proxy_encryption_method
+ #{object.proxyEncryptionMethod,jdbcType=VARCHAR}::guacamole_proxy_encryption_method,
+ #{object.connectionWeight,jdbcType=INTEGER}
)
</insert>
@@ -214,7 +220,8 @@
max_connections_per_user = #{object.maxConnectionsPerUser,jdbcType=INTEGER},
proxy_hostname = #{object.proxyHostname,jdbcType=VARCHAR},
proxy_port = #{object.proxyPort,jdbcType=INTEGER},
- proxy_encryption_method = #{object.proxyEncryptionMethod,jdbcType=VARCHAR}::guacamole_proxy_encryption_method
+ proxy_encryption_method = #{object.proxyEncryptionMethod,jdbcType=VARCHAR}::guacamole_proxy_encryption_method,
+ connection_weight = #{object.connectionWeight,jdbcType=INTEGER}
WHERE connection_id = #{object.objectID,jdbcType=INTEGER}::integer
</update>
[09/28] incubator-guacamole-client git commit: GUACAMOLE-102: Adding
some commentary for changes in the RestrictedGuacamoleTunnelService class.
Posted by mj...@apache.org.
GUACAMOLE-102: Adding some commentary for changes in the RestrictedGuacamoleTunnelService class.
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/2363c63e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/2363c63e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/2363c63e
Branch: refs/heads/master
Commit: 2363c63e6418d52d665ea79bec2f597145ee5021
Parents: d1259ef
Author: Nick Couchman <vn...@apache.org>
Authored: Mon Mar 20 14:55:35 2017 -0400
Committer: Nick Couchman <ni...@yahoo.com>
Committed: Mon Jun 5 15:34:21 2017 -0400
----------------------------------------------------------------------
.../auth/jdbc/tunnel/RestrictedGuacamoleTunnelService.java | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/2363c63e/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 3db47c6..b41ec91 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
@@ -190,11 +190,15 @@ public class RestrictedGuacamoleTunnelService
logger.debug("Calculating weights for connections {} and {}.", a.getName(), b.getName());
int cw = 0;
int weightA = a.getConnectionWeight();
+ // If the weight is null, we go ahead and sort, anyway
if (weightA == null)
weightA = 0;
+
+ // If the weight is null, we go ahead and sort, anyway
int weightB = b.getConnectionWeight();
if (weightB == null)
weightB = 0;
+
int connsA = getActiveConnections(a).size();
int connsB = getActiveConnections(b).size();
logger.debug("Connection {} has computed weight of {}.", a.getName(), connsA * 10000 / weightA);
[26/28] incubator-guacamole-client git commit: GUACAMOLE-102: Split
out load balancing into a separate section/form.
Posted by mj...@apache.org.
GUACAMOLE-102: Split out load balancing into a separate section/form.
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/5532819a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/5532819a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/5532819a
Branch: refs/heads/master
Commit: 5532819abfcb1bbf6774f1275e0aa5685dcb7a96
Parents: 166c7cc
Author: Nick Couchman <vn...@apache.org>
Authored: Tue Jun 6 09:10:49 2017 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Tue Jun 6 09:10:49 2017 -0400
----------------------------------------------------------------------
.../guacamole/auth/jdbc/connection/ModeledConnection.java | 9 ++++++++-
.../src/main/resources/translations/en.json | 2 +-
2 files changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/5532819a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
index db8c815..3c85f37 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
@@ -127,7 +127,13 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
*/
public static final Form CONCURRENCY_LIMITS = new Form("concurrency", Arrays.<Field>asList(
new NumericField(MAX_CONNECTIONS_NAME),
- new NumericField(MAX_CONNECTIONS_PER_USER_NAME),
+ new NumericField(MAX_CONNECTIONS_PER_USER_NAME)
+ ));
+
+ /**
+ * All attributes related to to load balancing in a logical form.
+ */
+ public static final Form LOAD_BALANCING = new Form("load-balancing", Arrays.<Field>asList(
new NumericField(CONNECTION_WEIGHT)
));
@@ -137,6 +143,7 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
*/
public static final Collection<Form> ATTRIBUTES = Collections.unmodifiableCollection(Arrays.asList(
CONCURRENCY_LIMITS,
+ LOAD_BALANCING,
GUACD_PARAMETERS
));
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/5532819a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/resources/translations/en.json
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/resources/translations/en.json b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/resources/translations/en.json
index 93e95d5..0bc2db3 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/resources/translations/en.json
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/resources/translations/en.json
@@ -20,7 +20,7 @@
"FIELD_HEADER_MAX_CONNECTIONS" : "Maximum number of connections:",
"FIELD_HEADER_MAX_CONNECTIONS_PER_USER" : "Maximum number of connections per user:",
- "FIELD_HEADER_WEIGHT" : "Connection weight for load balancing:",
+ "FIELD_HEADER_WEIGHT" : "Connection weight:",
"FIELD_HEADER_GUACD_HOSTNAME" : "Hostname:",
"FIELD_HEADER_GUACD_ENCRYPTION" : "Encryption:",
[23/28] incubator-guacamole-client git commit: GUACAMOLE-102: Improve
commentary around connection weight methods and variables.
Posted by mj...@apache.org.
GUACAMOLE-102: Improve commentary around connection weight methods and variables.
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/06e27d30
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/06e27d30
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/06e27d30
Branch: refs/heads/master
Commit: 06e27d30ff2823468707309b24a230d9175714d4
Parents: 955d5fb
Author: Nick Couchman <vn...@apache.org>
Authored: Tue Jun 6 08:39:02 2017 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Tue Jun 6 08:39:02 2017 -0400
----------------------------------------------------------------------
.../auth/jdbc/connection/ConnectionModel.java | 15 +++++++++------
.../auth/jdbc/connection/ModeledConnection.java | 10 ++++++----
2 files changed, 15 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/06e27d30/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
index 92ee91d..78cc885 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
@@ -172,22 +172,25 @@ public class ConnectionModel extends ChildObjectModel {
}
/**
- * Sets the connection weight.
+ * Sets the connection weight for load balancing.
*
* @param connectionWeight
- * The weight of the connection. null is acceptable, and anything
- * less than one will prevent the connection from being used.
+ * The weight of the connection used in load balancing.
+ * The value is not required for the connection (null), and
+ * values less than 1 will prevent the connection from being
+ * used.
*/
public void setConnectionWeight(Integer connectionWeight) {
this.connectionWeight = connectionWeight;
}
/**
- * Returns the connection weight used in calculating the
- * weighted algorithms.
+ * Returns the connection weight used in applying weighted
+ * load balancing algorithms.
*
* @return
- * The connection weight as an Integer.
+ * The connection weight used in applying weighted
+ * load balancing aglorithms.
*/
public Integer getConnectionWeight() {
return connectionWeight;
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/06e27d30/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
index ad525b8..db8c815 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
@@ -117,7 +117,7 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
public static final String MAX_CONNECTIONS_PER_USER_NAME = "max-connections-per-user";
/**
- * The connection weight for weighted algorithms.
+ * The connection weight attribute used for weighted load balancing algorithms.
*/
public static final String CONNECTION_WEIGHT = "weight";
@@ -412,11 +412,13 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
}
/**
- * Returns the weight of the connection, or a default
- * of 1 if the weight is undefined.
+ * Returns the weight of the connection used in applying weighted
+ * load balancing algorithms, or a default of 1 if the
+ * attribute is undefined.
*
* @return
- * The weight of the connection.
+ * The weight of the connection used in applying weighted
+ * load balancing algorithms.
*/
public int getConnectionWeight() {
[18/28] incubator-guacamole-client git commit: GUACAMOLE-102: Correct
versions for database schema upgrade scripts
Posted by mj...@apache.org.
GUACAMOLE-102: Correct versions for database schema upgrade scripts
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/6a4bc249
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/6a4bc249
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/6a4bc249
Branch: refs/heads/master
Commit: 6a4bc249a7af583481dc9c09b19c11e1ffaa5c41
Parents: 839f53c
Author: Nick Couchman <vn...@apache.org>
Authored: Mon Jun 5 15:37:13 2017 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Mon Jun 5 21:43:23 2017 -0400
----------------------------------------------------------------------
.../schema/upgrade/upgrade-pre-0.9.12.sql | 25 --------------------
.../schema/upgrade/upgrade-pre-0.9.14.sql | 25 ++++++++++++++++++++
.../schema/upgrade/upgrade-pre-0.9.12.sql | 25 --------------------
.../schema/upgrade/upgrade-pre-0.9.14.sql | 25 ++++++++++++++++++++
4 files changed, 50 insertions(+), 50 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/6a4bc249/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/upgrade/upgrade-pre-0.9.12.sql
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/upgrade/upgrade-pre-0.9.12.sql b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/upgrade/upgrade-pre-0.9.12.sql
deleted file mode 100644
index 48e2dd1..0000000
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/upgrade/upgrade-pre-0.9.12.sql
+++ /dev/null
@@ -1,25 +0,0 @@
---
--- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements. See the NOTICE file
--- distributed with this work for additional information
--- regarding copyright ownership. The ASF licenses this file
--- to you under the Apache License, Version 2.0 (the
--- "License"); you may not use this file except in compliance
--- with the License. You may obtain a copy of the License at
---
--- http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing,
--- software distributed under the License is distributed on an
--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
--- KIND, either express or implied. See the License for the
--- specific language governing permissions and limitations
--- under the License.
---
-
---
--- Add per-user password set date
---
-
-ALTER TABLE guacamole_connection
- ADD COLUMN connection_weight int(11);
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/6a4bc249/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/upgrade/upgrade-pre-0.9.14.sql
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/upgrade/upgrade-pre-0.9.14.sql b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/upgrade/upgrade-pre-0.9.14.sql
new file mode 100644
index 0000000..2b14e27
--- /dev/null
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/upgrade/upgrade-pre-0.9.14.sql
@@ -0,0 +1,25 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied. See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+--
+
+--
+-- Add per-connection weight
+--
+
+ALTER TABLE guacamole_connection
+ ADD COLUMN connection_weight int(11);
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/6a4bc249/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/upgrade/upgrade-pre-0.9.12.sql
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/upgrade/upgrade-pre-0.9.12.sql b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/upgrade/upgrade-pre-0.9.12.sql
deleted file mode 100644
index 1f085a4..0000000
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/upgrade/upgrade-pre-0.9.12.sql
+++ /dev/null
@@ -1,25 +0,0 @@
---
--- Licensed to the Apache Software Foundation (ASF) under one
--- or more contributor license agreements. See the NOTICE file
--- distributed with this work for additional information
--- regarding copyright ownership. The ASF licenses this file
--- to you under the Apache License, Version 2.0 (the
--- "License"); you may not use this file except in compliance
--- with the License. You may obtain a copy of the License at
---
--- http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing,
--- software distributed under the License is distributed on an
--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
--- KIND, either express or implied. See the License for the
--- specific language governing permissions and limitations
--- under the License.
---
-
---
--- Add per-user password set date
---
-
-ALTER TABLE guacamole_connection
- ADD COLUMN connection_weight int;
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/6a4bc249/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/upgrade/upgrade-pre-0.9.14.sql
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/upgrade/upgrade-pre-0.9.14.sql b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/upgrade/upgrade-pre-0.9.14.sql
new file mode 100644
index 0000000..6388b44
--- /dev/null
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/upgrade/upgrade-pre-0.9.14.sql
@@ -0,0 +1,25 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied. See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+--
+
+--
+-- Add per-connection weight
+--
+
+ALTER TABLE guacamole_connection
+ ADD COLUMN connection_weight int;
[20/28] incubator-guacamole-client git commit: GUACAMOLE-102:
Correction to WLC algorithm to try to keep ratio no higher than configure
weights.
Posted by mj...@apache.org.
GUACAMOLE-102: Correction to WLC algorithm to try to keep ratio no higher than configure weights.
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/874b29ba
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/874b29ba
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/874b29ba
Branch: refs/heads/master
Commit: 874b29bae309e198db991035604082eda1f78768
Parents: 25493a8
Author: Nick Couchman <vn...@apache.org>
Authored: Mon Jun 5 21:34:50 2017 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Mon Jun 5 21:43:31 2017 -0400
----------------------------------------------------------------------
.../RestrictedGuacamoleTunnelService.java | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/874b29ba/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 d4ab8aa..6480ec7 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
@@ -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);
}
[19/28] incubator-guacamole-client git commit: GUACAMOLE-102:
Woops...add MySQL module ConnectionMapper.xml updates.
Posted by mj...@apache.org.
GUACAMOLE-102: Woops...add MySQL module ConnectionMapper.xml updates.
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/25493a83
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/25493a83
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/25493a83
Branch: refs/heads/master
Commit: 25493a8355862abb22c128ab7b611bae4f7d830f
Parents: 6a4bc24
Author: Nick Couchman <vn...@apache.org>
Authored: Mon Jun 5 16:45:01 2017 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Mon Jun 5 21:43:25 2017 -0400
----------------------------------------------------------------------
.../auth/jdbc/connection/ConnectionMapper.xml | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/25493a83/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionMapper.xml
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionMapper.xml
index 46f8f10..2f778fa 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionMapper.xml
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionMapper.xml
@@ -37,6 +37,7 @@
<result column="proxy_port" property="proxyPort" jdbcType="INTEGER"/>
<result column="proxy_encryption_method" property="proxyEncryptionMethod" jdbcType="VARCHAR"
javaType="org.apache.guacamole.net.auth.GuacamoleProxyConfiguration$EncryptionMethod"/>
+ <result column="connection_weight" property="connectionWeight" jdbcType="INTEGER"/>
<!-- Associated sharing profiles -->
<collection property="sharingProfileIdentifiers" resultSet="sharingProfiles" ofType="java.lang.String"
@@ -95,7 +96,8 @@
max_connections_per_user,
proxy_hostname,
proxy_port,
- proxy_encryption_method
+ proxy_encryption_method,
+ connection_weight
FROM guacamole_connection
WHERE connection_id IN
<foreach collection="identifiers" item="identifier"
@@ -126,7 +128,8 @@
max_connections_per_user,
proxy_hostname,
proxy_port,
- proxy_encryption_method
+ proxy_encryption_method,
+ connection_weight
FROM guacamole_connection
JOIN guacamole_connection_permission ON guacamole_connection_permission.connection_id = guacamole_connection.connection_id
WHERE guacamole_connection.connection_id IN
@@ -162,7 +165,8 @@
max_connections_per_user,
proxy_hostname,
proxy_port,
- proxy_encryption_method
+ proxy_encryption_method,
+ connection_weight
FROM guacamole_connection
WHERE
<if test="parentIdentifier != null">parent_id = #{parentIdentifier,jdbcType=VARCHAR}</if>
@@ -189,7 +193,8 @@
max_connections_per_user,
proxy_hostname,
proxy_port,
- proxy_encryption_method
+ proxy_encryption_method,
+ connection_weight
)
VALUES (
#{object.name,jdbcType=VARCHAR},
@@ -199,7 +204,8 @@
#{object.maxConnectionsPerUser,jdbcType=INTEGER},
#{object.proxyHostname,jdbcType=VARCHAR},
#{object.proxyPort,jdbcType=INTEGER},
- #{object.proxyEncryptionMethod,jdbcType=VARCHAR}
+ #{object.proxyEncryptionMethod,jdbcType=VARCHAR},
+ #{object.connectionWeight,jdbcType=INTEGER}
)
</insert>
@@ -214,7 +220,8 @@
max_connections_per_user = #{object.maxConnectionsPerUser,jdbcType=INTEGER},
proxy_hostname = #{object.proxyHostname,jdbcType=VARCHAR},
proxy_port = #{object.proxyPort,jdbcType=INTEGER},
- proxy_encryption_method = #{object.proxyEncryptionMethod,jdbcType=VARCHAR}
+ proxy_encryption_method = #{object.proxyEncryptionMethod,jdbcType=VARCHAR},
+ connection_weight = #{object.connectionWeight,jdbcType=INTEGER}
WHERE connection_id = #{object.objectID,jdbcType=INTEGER}
</update>
[02/28] incubator-guacamole-client git commit: GUACAMOLE-102: Make
getConnectionWeight return int, clean up compare code.
Posted by mj...@apache.org.
GUACAMOLE-102: Make getConnectionWeight return int, clean up compare code.
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/f77c5073
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/f77c5073
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/f77c5073
Branch: refs/heads/master
Commit: f77c50730d09e4d02eff887d82a01ab84fd3ff09
Parents: aa4c134
Author: Nick Couchman <vn...@apache.org>
Authored: Fri Jun 2 20:05:15 2017 -0400
Committer: Nick Couchman <ni...@yahoo.com>
Committed: Mon Jun 5 15:34:21 2017 -0400
----------------------------------------------------------------------
.../auth/jdbc/connection/ConnectionModel.java | 12 +++++++-----
.../auth/jdbc/connection/ModeledConnection.java | 2 +-
.../tunnel/RestrictedGuacamoleTunnelService.java | 16 ++++------------
3 files changed, 12 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/f77c5073/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
index 69ef4c3..2da37a7 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
@@ -184,16 +184,18 @@ public class ConnectionModel extends ChildObjectModel {
/**
* Returns the connection weight used in calculating the
- * WRR algorithm.
+ * weighted algorithms.
*
* @return
- * The connection weight. Null indicates no weight has been set,
- * -1 indicates that the system is unavailable.
+ * The connection weight as an int. If the weight is
+ * null a default weight of 1 is returned. Zero and
+ * negative numbers are used to indicate the system is
+ * unavailable.
*/
- public Integer getConnectionWeight() {
+ public int getConnectionWeight() {
if (connectionWeight == null)
return 1;
- return connectionWeight;
+ return connectionWeight.intValue();
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/f77c5073/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
index 414a8a4..67bd793 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
@@ -418,7 +418,7 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
* The weight of the connection.
*
*/
- public Integer getConnectionWeight() {
+ public int getConnectionWeight() {
// Return the connection weight
return getModel().getConnectionWeight();
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/f77c5073/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 56d2f5b..bee5dd3 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
@@ -23,7 +23,6 @@ import com.google.common.collect.ConcurrentHashMultiset;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.Arrays;
-import java.util.Iterator;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@@ -188,15 +187,8 @@ public class RestrictedGuacamoleTunnelService
@Override
public int compare(ModeledConnection a, ModeledConnection b) {
- // Get connection weight for the two systems being compared.
- int weightA = a.getConnectionWeight().intValue();
- int weightB = b.getConnectionWeight().intValue();
-
- // Get current active connections, add 1 to both to avoid calculations with 0.
- int connsA = getActiveConnections(a).size() + 1;
- int connsB = getActiveConnections(b).size() + 1;
-
- return (connsA * weightB) - (connsB * weightA);
+ return ((getActiveConnections(a).size() + 1) * b.getConnectionWeight() -
+ (getActiveConnections(b).size() + 1) * a.getConnectionWeight());
}
@@ -209,8 +201,8 @@ public class RestrictedGuacamoleTunnelService
for (ModeledConnection connection : sortedConnections) {
// If connection weight is zero or negative, this host is disabled and should not be used.
- if (connection.getConnectionWeight() != null && connection.getConnectionWeight().intValue() < 1) {
- logger.warn("Weight for {} is non-null and < 1, connection will be skipped.", connection.getName());
+ if (connection.getConnectionWeight() < 1) {
+ logger.warn("Weight for {} is < 1, connection will be skipped.", connection.getName());
continue;
}
[03/28] incubator-guacamole-client git commit: GUACAMOLE-102: Remove
some extra debugging code, and continue to tweak the WLC algorithm.
Posted by mj...@apache.org.
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 <vn...@apache.org>
Authored: Mon Mar 20 09:55:41 2017 -0400
Committer: Nick Couchman <ni...@yahoo.com>
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();
[22/28] incubator-guacamole-client git commit: GUACAMOLE-102:
Clarification for comments on weights less than 1.
Posted by mj...@apache.org.
GUACAMOLE-102: Clarification for comments on weights less than 1.
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/955d5fb1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/955d5fb1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/955d5fb1
Branch: refs/heads/master
Commit: 955d5fb11f861f0476741a950cbb064150ae9bd4
Parents: 91f7a3e
Author: Nick Couchman <vn...@apache.org>
Authored: Mon Jun 5 22:37:49 2017 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Mon Jun 5 22:37:49 2017 -0400
----------------------------------------------------------------------
.../apache/guacamole/auth/jdbc/connection/ConnectionModel.java | 4 ++--
.../auth/jdbc/tunnel/RestrictedGuacamoleTunnelService.java | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/955d5fb1/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
index 4d28101..92ee91d 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
@@ -175,8 +175,8 @@ public class ConnectionModel extends ChildObjectModel {
* Sets the connection weight.
*
* @param connectionWeight
- * The weight of the connection. null is acceptable, negative values
- * indicate that the connection should not be used.
+ * The weight of the connection. null is acceptable, and anything
+ * less than one will prevent the connection from being used.
*/
public void setConnectionWeight(Integer connectionWeight) {
this.connectionWeight = connectionWeight;
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/955d5fb1/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 6480ec7..c9999ab 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
@@ -216,7 +216,7 @@ public class RestrictedGuacamoleTunnelService
// Return the first unreserved connection
for (ModeledConnection connection : sortedConnections) {
- // If connection weight is zero or negative, this host is disabled and should not be used.
+ // If connection weight is less than 1 this host is disabled and should not be used.
if (connection.getConnectionWeight() < 1) {
logger.debug("Weight for {} is < 1, connection will be skipped.", connection.getName());
continue;
[17/28] incubator-guacamole-client git commit: GUACAMOLE-102: Clean
up unused constants; minor comment corrections.
Posted by mj...@apache.org.
GUACAMOLE-102: Clean up unused constants; minor comment corrections.
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/839f53ca
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/839f53ca
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/839f53ca
Branch: refs/heads/master
Commit: 839f53ca965c87e855c5f21358c3d64f934186da
Parents: d2d5430
Author: Nick Couchman <vn...@apache.org>
Authored: Mon Jun 5 15:20:24 2017 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Mon Jun 5 21:43:21 2017 -0400
----------------------------------------------------------------------
.../guacamole/auth/jdbc/connection/ModeledConnection.java | 2 +-
.../java/org/apache/guacamole/auth/mysql/MySQLEnvironment.java | 6 ------
.../guacamole/auth/postgresql/PostgreSQLEnvironment.java | 6 ------
3 files changed, 1 insertion(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/839f53ca/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
index 29a8b6f..ad525b8 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
@@ -117,7 +117,7 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
public static final String MAX_CONNECTIONS_PER_USER_NAME = "max-connections-per-user";
/**
- * The connection weight for the WRR algorithm.
+ * The connection weight for weighted algorithms.
*/
public static final String CONNECTION_WEIGHT = "weight";
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/839f53ca/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLEnvironment.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLEnvironment.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLEnvironment.java
index 088d186..19a8ef4 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLEnvironment.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLEnvironment.java
@@ -88,12 +88,6 @@ public class MySQLEnvironment extends JDBCEnvironment {
private int DEFAULT_MAX_CONNECTIONS = 0;
/**
- * The default value for the connection weight for a connection in
- * a balancing group.
- */
- private int DEFAULT_CONNECTION_WEIGHT = 0;
-
- /**
* The default value for the default maximum number of connections to be
* allowed to any one connection group. Note that, as long as the legacy
* "disallow duplicate" and "disallow simultaneous" properties are still
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/839f53ca/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLEnvironment.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLEnvironment.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLEnvironment.java
index 1f4b6e5..e0ee75f 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLEnvironment.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLEnvironment.java
@@ -88,12 +88,6 @@ public class PostgreSQLEnvironment extends JDBCEnvironment {
private int DEFAULT_MAX_CONNECTIONS = 0;
/**
- * The default value for the connection weight for a connection in
- * a balancing group.
- */
- private int DEFAULT_CONNECTION_WEIGHT = 0;
-
- /**
* The default value for the default maximum number of connections to be
* allowed to any one connection group. Note that, as long as the legacy
* "disallow duplicate" and "disallow simultaneous" properties are still
[04/28] incubator-guacamole-client git commit: GUACAMOLE-102: Tweak
algorithm for computing the WLC vlaues.
Posted by mj...@apache.org.
GUACAMOLE-102: Tweak algorithm for computing the WLC vlaues.
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/83a8e822
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/83a8e822
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/83a8e822
Branch: refs/heads/master
Commit: 83a8e8223e9453f3928963f0cf1d901de182ac44
Parents: d0647ad
Author: Nick Couchman <vn...@apache.org>
Authored: Mon Mar 20 09:06:04 2017 -0400
Committer: Nick Couchman <ni...@yahoo.com>
Committed: Mon Jun 5 15:34:21 2017 -0400
----------------------------------------------------------------------
.../auth/jdbc/connection/ModeledConnection.java | 13 +++----------
.../tunnel/RestrictedGuacamoleTunnelService.java | 18 +++++-------------
2 files changed, 8 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/83a8e822/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
index aa79ba4..1044a62 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
@@ -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;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/83a8e822/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 92cdfc6..ae7a059 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
@@ -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;
-
}
});
[21/28] incubator-guacamole-client git commit: GUACAMOLE-102:
Corrections to comments in ConnectionModel class.
Posted by mj...@apache.org.
GUACAMOLE-102: Corrections to comments in ConnectionModel class.
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/91f7a3e8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/91f7a3e8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/91f7a3e8
Branch: refs/heads/master
Commit: 91f7a3e8e9e4e125f2002b1d2527d5d0f8e829a4
Parents: 874b29b
Author: Nick Couchman <vn...@apache.org>
Authored: Mon Jun 5 22:29:28 2017 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Mon Jun 5 22:29:28 2017 -0400
----------------------------------------------------------------------
.../guacamole/auth/jdbc/connection/ConnectionModel.java | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/91f7a3e8/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
index f208b5a..4d28101 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
@@ -56,8 +56,8 @@ public class ConnectionModel extends ChildObjectModel {
/**
* The weight of the connection for the purposes of calculating
- * WRR algorithm. null indicates nothing has been set, -1 indicates
- * the system is unavailable.
+ * WLC algorithm. null indicates nothing has been set, and anything less
+ * than 1 eliminates the system from being used for connections.
*/
private Integer connectionWeight;
@@ -187,10 +187,7 @@ public class ConnectionModel extends ChildObjectModel {
* weighted algorithms.
*
* @return
- * The connection weight as an int. If the weight is
- * null a default weight of 1 is returned. Zero and
- * negative numbers are used to indicate the system is
- * unavailable.
+ * The connection weight as an Integer.
*/
public Integer getConnectionWeight() {
return connectionWeight;
[05/28] incubator-guacamole-client git commit: GUACAMOLE-102: Initial
stab at a WLC algorithm.
Posted by mj...@apache.org.
GUACAMOLE-102: Initial stab at a 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/d0647ad6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/d0647ad6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/d0647ad6
Branch: refs/heads/master
Commit: d0647ad6a44d1a0785f29f40bd30412f8592e291
Parents: 4aff2c1
Author: Nick Couchman <vn...@apache.org>
Authored: Mon Mar 20 06:49:10 2017 -0400
Committer: Nick Couchman <ni...@yahoo.com>
Committed: Mon Jun 5 15:34:21 2017 -0400
----------------------------------------------------------------------
.../tunnel/RestrictedGuacamoleTunnelService.java | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/d0647ad6/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 9c01917..92cdfc6 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
@@ -191,9 +191,22 @@ public class RestrictedGuacamoleTunnelService
public int compare(ModeledConnection a, ModeledConnection b) {
logger.trace("Comparing {} to {}.", a.getName(), b.getName());
- return getActiveConnections(a).size()
- - getActiveConnections(b).size();
-
+ int cw = 0;
+
+ 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();
+
+ }
+ catch (GuacamoleException e) {
+ logger.error("Could not compare connections.", e.getMessage());
+ logger.debug("Could not compare connections.", e);
+ }
+
+ return cw;
+
}
});
[16/28] incubator-guacamole-client git commit: GUACAMOLE-102: Clean
up code style issues,
remove the unnecessary getDefaultConnectionWeight method.
Posted by mj...@apache.org.
GUACAMOLE-102: Clean up code style issues, remove the unnecessary getDefaultConnectionWeight method.
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/d2d54302
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/d2d54302
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/d2d54302
Branch: refs/heads/master
Commit: d2d543028f0fa6ced798375ccd91270b5b6f54a7
Parents: f66bbd2
Author: Nick Couchman <vn...@apache.org>
Authored: Mon Jun 5 15:13:19 2017 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Mon Jun 5 21:43:18 2017 -0400
----------------------------------------------------------------------
.../org/apache/guacamole/auth/jdbc/JDBCEnvironment.java | 11 -----------
.../auth/jdbc/connection/ModeledConnection.java | 3 +--
.../jdbc/tunnel/RestrictedGuacamoleTunnelService.java | 4 ++--
.../apache/guacamole/auth/mysql/MySQLEnvironment.java | 8 --------
.../guacamole/auth/postgresql/PostgreSQLEnvironment.java | 8 --------
5 files changed, 3 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/d2d54302/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/JDBCEnvironment.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/JDBCEnvironment.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/JDBCEnvironment.java
index a856d2a..53935e6 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/JDBCEnvironment.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/JDBCEnvironment.java
@@ -83,17 +83,6 @@ public abstract class JDBCEnvironment extends LocalEnvironment {
public abstract int getDefaultMaxConnections() throws GuacamoleException;
/**
- * Returns the connection weight for the purpose of WRR calculation
- *
- * @return
- * The weight of the connection.
- *
- * @throws GuacamoleException
- * If an error occurs while retrieving the property.
- */
- public abstract int getDefaultConnectionWeight() throws GuacamoleException;
-
- /**
* Returns the default maximum number of concurrent connections to allow to
* any one connection group, unless specified differently on an individual
* connection group. Zero denotes unlimited.
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/d2d54302/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
index 7e11a76..29a8b6f 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
@@ -417,12 +417,11 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
*
* @return
* The weight of the connection.
- *
*/
public int getConnectionWeight() {
Integer connectionWeight = getModel().getConnectionWeight();
- if(connectionWeight == null)
+ if (connectionWeight == null)
return 1;
return connectionWeight;
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/d2d54302/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 bee5dd3..d4ab8aa 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
@@ -188,7 +188,7 @@ public class RestrictedGuacamoleTunnelService
public int compare(ModeledConnection a, ModeledConnection b) {
return ((getActiveConnections(a).size() + 1) * b.getConnectionWeight() -
- (getActiveConnections(b).size() + 1) * a.getConnectionWeight());
+ (getActiveConnections(b).size() + 1) * a.getConnectionWeight());
}
@@ -202,7 +202,7 @@ public class RestrictedGuacamoleTunnelService
// If connection weight is zero or negative, this host is disabled and should not be used.
if (connection.getConnectionWeight() < 1) {
- logger.warn("Weight for {} is < 1, connection will be skipped.", connection.getName());
+ logger.debug("Weight for {} is < 1, connection will be skipped.", connection.getName());
continue;
}
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/d2d54302/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLEnvironment.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLEnvironment.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLEnvironment.java
index 6495fcc..088d186 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLEnvironment.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLEnvironment.java
@@ -201,14 +201,6 @@ public class MySQLEnvironment extends JDBCEnvironment {
}
@Override
- public int getDefaultConnectionWeight() throws GuacamoleException {
- return getProperty(
- MySQLGuacamoleProperties.MYSQL_DEFAULT_CONNECTION_WEIGHT,
- DEFAULT_CONNECTION_WEIGHT
- );
- }
-
- @Override
public int getDefaultMaxGroupConnections() throws GuacamoleException {
return getProperty(
MySQLGuacamoleProperties.MYSQL_DEFAULT_MAX_GROUP_CONNECTIONS,
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/d2d54302/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLEnvironment.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLEnvironment.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLEnvironment.java
index e0ad4ec..1f4b6e5 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLEnvironment.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLEnvironment.java
@@ -201,14 +201,6 @@ public class PostgreSQLEnvironment extends JDBCEnvironment {
}
@Override
- public int getDefaultConnectionWeight() throws GuacamoleException {
- return getProperty(
- PostgreSQLGuacamoleProperties.POSTGRESQL_DEFAULT_CONNECTION_WEIGHT,
- DEFAULT_CONNECTION_WEIGHT
- );
- }
-
- @Override
public int getDefaultMaxGroupConnections() throws GuacamoleException {
return getProperty(
PostgreSQLGuacamoleProperties.POSTGRESQL_DEFAULT_MAX_GROUP_CONNECTIONS,
[24/28] incubator-guacamole-client git commit: GUACAMOLE-102: Code
cleanup - remove unused default parameters;
improve commentary and use more standard variable names.
Posted by mj...@apache.org.
GUACAMOLE-102: Code cleanup - remove unused default parameters; improve commentary and use more standard variable names.
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/2986c616
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/2986c616
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/2986c616
Branch: refs/heads/master
Commit: 2986c616906c1a606c215594283060409f85c5a6
Parents: 06e27d3
Author: Nick Couchman <vn...@apache.org>
Authored: Tue Jun 6 08:49:48 2017 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Tue Jun 6 08:49:48 2017 -0400
----------------------------------------------------------------------
.../RestrictedGuacamoleTunnelService.java | 24 ++++++++++----------
.../auth/mysql/MySQLGuacamoleProperties.java | 12 ----------
.../PostgreSQLGuacamoleProperties.java | 9 --------
3 files changed, 12 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/2986c616/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 c9999ab..fa2c99f 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
@@ -188,23 +188,23 @@ public class RestrictedGuacamoleTunnelService
public int compare(ModeledConnection a, ModeledConnection b) {
// Active connections
- int Ca = getActiveConnections(a).size();
- int Cb = getActiveConnections(b).size();
+ int connA = getActiveConnections(a).size();
+ int connB = getActiveConnections(b).size();
// Assigned weight
- int Wa = a.getConnectionWeight();
- int Wb = b.getConnectionWeight();
+ int weightA = a.getConnectionWeight();
+ int weightB = b.getConnectionWeight();
- // Net weight of connections
- int NWa = Ca * Wb;
- int NWb = Cb * Wa;
+ // Calculated weight of connections
+ int calcWeightA = connA * weightB;
+ int calcWeightB = connB * weightA;
- // If net weights are equal, return difference in weight
- if (NWa == NWb)
- return (Wa - Wb);
+ // If calculated weights are equal, return difference in assigned weight
+ if (calcWeightA == calcWeightB)
+ return (weightA - weightB);
- // Return different in net weights
- return (NWa - NWb);
+ // Return different in calculated weights
+ return (calcWeightA - calcWeightB);
}
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/2986c616/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLGuacamoleProperties.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLGuacamoleProperties.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLGuacamoleProperties.java
index 3c88a59..9039c02 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLGuacamoleProperties.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLGuacamoleProperties.java
@@ -175,18 +175,6 @@ public class MySQLGuacamoleProperties {
};
/**
- * The connection weight for connections in balancing groups.
- */
- public static final IntegerGuacamoleProperty
- MYSQL_DEFAULT_CONNECTION_WEIGHT =
- new IntegerGuacamoleProperty() {
-
- @Override
- public String getName() { return "mysql-default-connection-weight"; }
-
- };
-
- /**
* The maximum number of concurrent connections to allow to any one
* connection group by an individual user. Zero denotes
* unlimited.
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/2986c616/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLGuacamoleProperties.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLGuacamoleProperties.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLGuacamoleProperties.java
index 3ae83ab..3da972f 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLGuacamoleProperties.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLGuacamoleProperties.java
@@ -157,15 +157,6 @@ public class PostgreSQLGuacamoleProperties {
};
- public static final IntegerGuacamoleProperty
- POSTGRESQL_DEFAULT_CONNECTION_WEIGHT =
- new IntegerGuacamoleProperty() {
-
- @Override
- public String getName() { return "postgresql-default-connection-weight"; }
-
- };
-
/**
* The maximum number of concurrent connections to allow to any one
* connection group. Zero denotes unlimited.
[28/28] incubator-guacamole-client git commit: GUACAMOLE-102: Merge
support for weighted least-connections (WLC) balancing algorithm.
Posted by mj...@apache.org.
GUACAMOLE-102: Merge support for weighted least-connections (WLC) balancing 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/eb087ae2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/eb087ae2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/eb087ae2
Branch: refs/heads/master
Commit: eb087ae290943d076ece1e3c80cae02034af5710
Parents: 91920d0 d8ba0f8
Author: Michael Jumper <mj...@apache.org>
Authored: Tue Jun 6 17:30:47 2017 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Tue Jun 6 17:30:47 2017 -0700
----------------------------------------------------------------------
.../guacamole/auth/jdbc/JDBCEnvironment.java | 2 +-
.../auth/jdbc/connection/ConnectionModel.java | 32 ++++++++++++++++
.../auth/jdbc/connection/ModeledConnection.java | 40 ++++++++++++++++++++
.../RestrictedGuacamoleTunnelService.java | 33 +++++++++++++++-
.../src/main/resources/translations/en.json | 7 +++-
.../schema/001-create-schema.sql | 5 ++-
.../schema/upgrade/upgrade-pre-0.9.14.sql | 25 ++++++++++++
.../auth/jdbc/connection/ConnectionMapper.xml | 19 +++++++---
.../schema/001-create-schema.sql | 3 ++
.../schema/upgrade/upgrade-pre-0.9.14.sql | 25 ++++++++++++
.../auth/jdbc/connection/ConnectionMapper.xml | 19 +++++++---
11 files changed, 192 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
[13/28] incubator-guacamole-client git commit: GUACAMOLE-102: Get rid
of arbitary constant in compare method for WLC algorithm.
Posted by mj...@apache.org.
GUACAMOLE-102: Get rid of arbitary constant in compare method for 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/4033e097
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/4033e097
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/4033e097
Branch: refs/heads/master
Commit: 4033e097c7dcc976af84d3b8684794be7f184786
Parents: f228527
Author: Nick Couchman <vn...@apache.org>
Authored: Fri Jun 2 14:43:11 2017 -0400
Committer: Nick Couchman <ni...@yahoo.com>
Committed: Mon Jun 5 15:34:21 2017 -0400
----------------------------------------------------------------------
.../auth/jdbc/tunnel/RestrictedGuacamoleTunnelService.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/4033e097/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 744d2e8..71d4f7f 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
@@ -207,7 +207,7 @@ public class RestrictedGuacamoleTunnelService
int connsA = getActiveConnections(a).size() + 1;
int connsB = getActiveConnections(b).size() + 1;
- return (connsA * 10000 / weightA) - (connsB * 10000 / weightB);
+ return (connsA * weightB) - (connsB * weightA);
}
[11/28] incubator-guacamole-client git commit: GUACAMOLE-102: Deal
with weights of 0, and properly dispose of connections with negative weights.
Posted by mj...@apache.org.
GUACAMOLE-102: Deal with weights of 0, and properly dispose of connections with negative weights.
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/075e880a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/075e880a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/075e880a
Branch: refs/heads/master
Commit: 075e880acc7aa115f0a4b27fed3f182f8108affa
Parents: 2363c63
Author: Nick Couchman <vn...@apache.org>
Authored: Wed May 31 15:22:31 2017 -0400
Committer: Nick Couchman <ni...@yahoo.com>
Committed: Mon Jun 5 15:34:21 2017 -0400
----------------------------------------------------------------------
.../auth/jdbc/connection/ModeledConnection.java | 3 +-
.../RestrictedGuacamoleTunnelService.java | 45 +++++++++++---------
2 files changed, 26 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/075e880a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
index 1044a62..414a8a4 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
@@ -409,6 +409,7 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
port != null ? port : defaultConfig.getPort(),
encryptionMethod != null ? encryptionMethod : defaultConfig.getEncryptionMethod()
);
+ }
/**
* Returns the weight of the connection, or the default.
@@ -417,7 +418,7 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
* The weight of the connection.
*
*/
- public int getConnectionWeight() {
+ public Integer getConnectionWeight() {
// Return the connection weight
return getModel().getConnectionWeight();
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/075e880a/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 b41ec91..49af081 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
@@ -23,6 +23,7 @@ import com.google.common.collect.ConcurrentHashMultiset;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.Arrays;
+import java.util.Iterator;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@@ -47,11 +48,6 @@ public class RestrictedGuacamoleTunnelService
extends AbstractGuacamoleTunnelService {
/**
- * Logger for this class.
- */
- private static final Logger logger = LoggerFactory.getLogger(RestrictedGuacamoleTunnelService.class);
-
- /**
* The environment of the Guacamole server.
*/
@Inject
@@ -180,6 +176,14 @@ public class RestrictedGuacamoleTunnelService
// Get username
String username = user.getIdentifier();
+ // Remove connections where weight < 0
+ Iterator<ModeledConnection> i = connections.iterator();
+ while(i.hasNext()) {
+ Integer weight = i.next().getConnectionWeight();
+ if (weight != null && weight.intValue() < 0)
+ i.remove();
+ }
+
// Sort connections in ascending order of usage
ModeledConnection[] sortedConnections = connections.toArray(new ModeledConnection[connections.size()]);
Arrays.sort(sortedConnections, new Comparator<ModeledConnection>() {
@@ -187,22 +191,21 @@ public class RestrictedGuacamoleTunnelService
@Override
public int compare(ModeledConnection a, ModeledConnection b) {
- logger.debug("Calculating weights for connections {} and {}.", a.getName(), b.getName());
- int cw = 0;
- int weightA = a.getConnectionWeight();
- // If the weight is null, we go ahead and sort, anyway
- if (weightA == null)
- weightA = 0;
-
- // If the weight is null, we go ahead and sort, anyway
- int weightB = b.getConnectionWeight();
- if (weightB == null)
- weightB = 0;
-
- 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);
+ int weightA, weightB;
+ // Check if weight of a is null, assign 1 if it is.
+ if (a.getConnectionWeight() == null)
+ weightA = 1;
+ else
+ weightA = a.getConnectionWeight().intValue() + 1;
+
+ // Check if weight of b is null, assign 1 if it is.
+ if (b.getConnectionWeight() == null)
+ weightB = 1;
+ else
+ weightB = b.getConnectionWeight().intValue() + 1;
+
+ int connsA = getActiveConnections(a).size() + 1;
+ int connsB = getActiveConnections(b).size() + 1;
return (connsA * 10000 / weightA) - (connsB * 10000 / weightB);
[06/28] incubator-guacamole-client git commit: GUACAMOLE-102: Finish
adding connection weight attribute.
Posted by mj...@apache.org.
GUACAMOLE-102: Finish adding connection weight attribute.
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/4aff2c1b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/4aff2c1b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/4aff2c1b
Branch: refs/heads/master
Commit: 4aff2c1bb871545f5853f58760058e0d5b787d3f
Parents: 025f77d
Author: Nick Couchman <vn...@apache.org>
Authored: Sun Mar 19 16:24:56 2017 -0400
Committer: Nick Couchman <ni...@yahoo.com>
Committed: Mon Jun 5 15:34:21 2017 -0400
----------------------------------------------------------------------
.../guacamole/auth/jdbc/JDBCEnvironment.java | 2 +-
.../auth/jdbc/connection/ModeledConnection.java | 5 ++--
.../src/main/resources/translations/en.json | 1 +
.../guacamole/auth/mysql/MySQLEnvironment.java | 1 +
.../auth/mysql/MySQLGuacamoleProperties.java | 2 +-
.../schema/001-create-schema.sql | 3 +++
.../schema/upgrade/upgrade-pre-0.9.12.sql | 25 ++++++++++++++++++++
.../auth/postgresql/PostgreSQLEnvironment.java | 1 +
8 files changed, 36 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/4aff2c1b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/JDBCEnvironment.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/JDBCEnvironment.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/JDBCEnvironment.java
index 64f2449..a856d2a 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/JDBCEnvironment.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/JDBCEnvironment.java
@@ -91,7 +91,7 @@ public abstract class JDBCEnvironment extends LocalEnvironment {
* @throws GuacamoleException
* If an error occurs while retrieving the property.
*/
- public abstract int getConnectionWeight() throws GuacamoleException;
+ public abstract int getDefaultConnectionWeight() throws GuacamoleException;
/**
* Returns the default maximum number of concurrent connections to allow to
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/4aff2c1b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
index 93a7329..aa79ba4 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
@@ -119,7 +119,7 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
/**
* The connection weight for the WRR algorithm.
*/
- public static final String CONNECTION_WEIGHT = "connection-weight";
+ public static final String CONNECTION_WEIGHT = "weight";
/**
* All attributes related to restricting user accounts, within a logical
@@ -127,7 +127,8 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
*/
public static final Form CONCURRENCY_LIMITS = new Form("concurrency", Arrays.<Field>asList(
new NumericField(MAX_CONNECTIONS_NAME),
- new NumericField(MAX_CONNECTIONS_PER_USER_NAME)
+ new NumericField(MAX_CONNECTIONS_PER_USER_NAME),
+ new NumericField(CONNECTION_WEIGHT)
));
/**
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/4aff2c1b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/resources/translations/en.json
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/resources/translations/en.json b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/resources/translations/en.json
index bf73c35..c154d8b 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/resources/translations/en.json
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/resources/translations/en.json
@@ -19,6 +19,7 @@
"FIELD_HEADER_MAX_CONNECTIONS" : "Maximum number of connections:",
"FIELD_HEADER_MAX_CONNECTIONS_PER_USER" : "Maximum number of connections per user:",
+ "FIELD_HEADER_WEIGHT" : "Connection Weight for Load Balancing:",
"FIELD_HEADER_GUACD_HOSTNAME" : "Hostname:",
"FIELD_HEADER_GUACD_ENCRYPTION" : "Encryption:",
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/4aff2c1b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLEnvironment.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLEnvironment.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLEnvironment.java
index 63d4ae3..6495fcc 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLEnvironment.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLEnvironment.java
@@ -90,6 +90,7 @@ public class MySQLEnvironment extends JDBCEnvironment {
/**
* The default value for the connection weight for a connection in
* a balancing group.
+ */
private int DEFAULT_CONNECTION_WEIGHT = 0;
/**
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/4aff2c1b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLGuacamoleProperties.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLGuacamoleProperties.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLGuacamoleProperties.java
index 79f3e7f..3c88a59 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLGuacamoleProperties.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLGuacamoleProperties.java
@@ -181,7 +181,7 @@ public class MySQLGuacamoleProperties {
MYSQL_DEFAULT_CONNECTION_WEIGHT =
new IntegerGuacamoleProperty() {
- @Overide
+ @Override
public String getName() { return "mysql-default-connection-weight"; }
};
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/4aff2c1b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/001-create-schema.sql
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/001-create-schema.sql b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/001-create-schema.sql
index e018617..7b9081e 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/001-create-schema.sql
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/001-create-schema.sql
@@ -106,6 +106,9 @@ CREATE TABLE guacamole_connection (
max_connections integer,
max_connections_per_user integer,
+ -- Connection Weight
+ connection_weight integer,
+
-- Guacamole proxy (guacd) overrides
proxy_port integer,
proxy_hostname varchar(512),
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/4aff2c1b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/upgrade/upgrade-pre-0.9.12.sql
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/upgrade/upgrade-pre-0.9.12.sql b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/upgrade/upgrade-pre-0.9.12.sql
new file mode 100644
index 0000000..1f085a4
--- /dev/null
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/schema/upgrade/upgrade-pre-0.9.12.sql
@@ -0,0 +1,25 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied. See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+--
+
+--
+-- Add per-user password set date
+--
+
+ALTER TABLE guacamole_connection
+ ADD COLUMN connection_weight int;
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/4aff2c1b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLEnvironment.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLEnvironment.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLEnvironment.java
index 5399417..e0ad4ec 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLEnvironment.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLEnvironment.java
@@ -90,6 +90,7 @@ public class PostgreSQLEnvironment extends JDBCEnvironment {
/**
* The default value for the connection weight for a connection in
* a balancing group.
+ */
private int DEFAULT_CONNECTION_WEIGHT = 0;
/**
[10/28] incubator-guacamole-client git commit: GUACAMOLE-102:
Continue to work on the load balancing code.
Posted by mj...@apache.org.
GUACAMOLE-102: Continue to work on the load balancing code.
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/d1259ef8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/d1259ef8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/d1259ef8
Branch: refs/heads/master
Commit: d1259ef8dfe9cb7c65b3f3ff152b12820bf80134
Parents: 15869fe
Author: Nick Couchman <vn...@apache.org>
Authored: Mon Mar 20 10:50:33 2017 -0400
Committer: Nick Couchman <ni...@yahoo.com>
Committed: Mon Jun 5 15:34:21 2017 -0400
----------------------------------------------------------------------
.../guacamole/auth/jdbc/connection/ConnectionModel.java | 4 ++--
.../auth/jdbc/tunnel/RestrictedGuacamoleTunnelService.java | 8 ++++++--
2 files changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/d1259ef8/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
index 91dd42c..56cf4ac 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
@@ -175,8 +175,8 @@ public class ConnectionModel extends ChildObjectModel {
* Sets the connection weight.
*
* @param connectionWeight
- * The weight of the connection. null is acceptable, -1 indicates the
- * connection should not be used.
+ * The weight of the connection. null is acceptable, negative values
+ * indicate that the connection should not be used.
*/
public void setConnectionWeight(Integer connectionWeight) {
this.connectionWeight = connectionWeight;
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/d1259ef8/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 8cc6605..3db47c6 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
@@ -190,7 +190,11 @@ public class RestrictedGuacamoleTunnelService
logger.debug("Calculating weights for connections {} and {}.", a.getName(), b.getName());
int cw = 0;
int weightA = a.getConnectionWeight();
+ if (weightA == null)
+ weightA = 0;
int weightB = b.getConnectionWeight();
+ if (weightB == null)
+ weightB = 0;
int connsA = getActiveConnections(a).size();
int connsB = getActiveConnections(b).size();
logger.debug("Connection {} has computed weight of {}.", a.getName(), connsA * 10000 / weightA);
@@ -208,8 +212,8 @@ 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)
+ // If connection weight is zero or negative, this host is disabled and should not be used.
+ if (connection.getConnectionWeight() < 1)
continue;
// Attempt to aquire connection according to per-user limits
[12/28] incubator-guacamole-client git commit: GUACAMOLE-102: Move
null check for connection weight to the connection model.
Posted by mj...@apache.org.
GUACAMOLE-102: Move null check for connection weight to the connection model.
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/58637818
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/58637818
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/58637818
Branch: refs/heads/master
Commit: 58637818ca0c6e88bcd2fcd55f786bee509f5bdc
Parents: 4033e09
Author: Nick Couchman <vn...@apache.org>
Authored: Fri Jun 2 14:47:15 2017 -0400
Committer: Nick Couchman <ni...@yahoo.com>
Committed: Mon Jun 5 15:34:21 2017 -0400
----------------------------------------------------------------------
.../apache/guacamole/auth/jdbc/connection/ConnectionModel.java | 2 ++
.../auth/jdbc/tunnel/RestrictedGuacamoleTunnelService.java | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/58637818/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
index 56cf4ac..69ef4c3 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
@@ -191,6 +191,8 @@ public class ConnectionModel extends ChildObjectModel {
* -1 indicates that the system is unavailable.
*/
public Integer getConnectionWeight() {
+ if (connectionWeight == null)
+ return 1;
return connectionWeight;
}
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/58637818/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 71d4f7f..d1b4912 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
@@ -190,14 +190,14 @@ public class RestrictedGuacamoleTunnelService
int weightA, weightB;
// Check if weight of a is non-null and retrieve it.
- if (a.getConnectionWeight() != null && a.getConnectionWeight().intValue() > 0)
+ if (a.getConnectionWeight().intValue() > 0)
weightA = a.getConnectionWeight().intValue();
// In all other cases assign 1 for sorting.
else
weightA = 1;
// Check if weight of b is null, assign 1 if it is.
- if (b.getConnectionWeight() != null && b.getConnectionWeight().intValue() > 0)
+ if (b.getConnectionWeight().intValue() > 0)
weightB = b.getConnectionWeight().intValue();
// In all other cases assign 1 for sorting.
else
[07/28] incubator-guacamole-client git commit: GUACAMOLE-102: Remove
unnecessary checks for weight value in the compare function.
Posted by mj...@apache.org.
GUACAMOLE-102: Remove unnecessary checks for weight value in the compare function.
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/aa4c1349
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/aa4c1349
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/aa4c1349
Branch: refs/heads/master
Commit: aa4c13492251a4dfd7e8449435f5eebd2eac7e40
Parents: 5863781
Author: Nick Couchman <vn...@apache.org>
Authored: Fri Jun 2 14:51:27 2017 -0400
Committer: Nick Couchman <ni...@yahoo.com>
Committed: Mon Jun 5 15:34:21 2017 -0400
----------------------------------------------------------------------
.../tunnel/RestrictedGuacamoleTunnelService.java | 19 ++++---------------
1 file changed, 4 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/aa4c1349/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 d1b4912..56d2f5b 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
@@ -187,21 +187,10 @@ public class RestrictedGuacamoleTunnelService
@Override
public int compare(ModeledConnection a, ModeledConnection b) {
-
- int weightA, weightB;
- // Check if weight of a is non-null and retrieve it.
- if (a.getConnectionWeight().intValue() > 0)
- weightA = a.getConnectionWeight().intValue();
- // In all other cases assign 1 for sorting.
- else
- weightA = 1;
-
- // Check if weight of b is null, assign 1 if it is.
- if (b.getConnectionWeight().intValue() > 0)
- weightB = b.getConnectionWeight().intValue();
- // In all other cases assign 1 for sorting.
- else
- weightB = 1;
+
+ // Get connection weight for the two systems being compared.
+ int weightA = a.getConnectionWeight().intValue();
+ int weightB = b.getConnectionWeight().intValue();
// Get current active connections, add 1 to both to avoid calculations with 0.
int connsA = getActiveConnections(a).size() + 1;
[14/28] incubator-guacamole-client git commit: GUACAMOLE-102: Clean
up and simplify WLC sorting code.
Posted by mj...@apache.org.
GUACAMOLE-102: Clean up and simplify WLC sorting code.
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/f2285272
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/f2285272
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/f2285272
Branch: refs/heads/master
Commit: f22852721c12d38716aec8aad001f0986b31223c
Parents: 56f6c4b
Author: Nick Couchman <vn...@apache.org>
Authored: Wed May 31 21:39:16 2017 -0400
Committer: Nick Couchman <ni...@yahoo.com>
Committed: Mon Jun 5 15:34:21 2017 -0400
----------------------------------------------------------------------
.../RestrictedGuacamoleTunnelService.java | 27 ++++++++------------
1 file changed, 10 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/f2285272/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 590648c..744d2e8 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
@@ -189,28 +189,21 @@ public class RestrictedGuacamoleTunnelService
public int compare(ModeledConnection a, ModeledConnection b) {
int weightA, weightB;
- // Check if weight of a is null, assign 1 if it is.
- if (a.getConnectionWeight() == null)
- weightA = 1;
- // If weight is less than 1, host will be disabled
- // but for sorting we set it to 1 to avoid divide
- // by 0.
- else if (a.getConnectionWeight().intValue() < 1)
- weightA = 1;
+ // Check if weight of a is non-null and retrieve it.
+ if (a.getConnectionWeight() != null && a.getConnectionWeight().intValue() > 0)
+ weightA = a.getConnectionWeight().intValue();
+ // In all other cases assign 1 for sorting.
else
- weightA = a.getConnectionWeight().intValue() + 1;
+ weightA = 1;
// Check if weight of b is null, assign 1 if it is.
- if (b.getConnectionWeight() == null)
- weightB = 1;
- // If weight is less than 1, host will be disabled,
- // but for sorting we set it to 1 to avoid divide
- // by 0.
- else if (b.getConnectionWeight().intValue() < 1)
- weightB = 1;
+ if (b.getConnectionWeight() != null && b.getConnectionWeight().intValue() > 0)
+ weightB = b.getConnectionWeight().intValue();
+ // In all other cases assign 1 for sorting.
else
- weightB = b.getConnectionWeight().intValue() + 1;
+ weightB = 1;
+ // Get current active connections, add 1 to both to avoid calculations with 0.
int connsA = getActiveConnections(a).size() + 1;
int connsB = getActiveConnections(b).size() + 1;
[08/28] incubator-guacamole-client git commit: GUACAMOLE-102: Remove
redundant iterations through connections.
Posted by mj...@apache.org.
GUACAMOLE-102: Remove redundant iterations through connections.
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/56f6c4bb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/56f6c4bb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/56f6c4bb
Branch: refs/heads/master
Commit: 56f6c4bb2ff93e3af4538d3f8011a89716f292e3
Parents: 075e880
Author: Nick Couchman <vn...@apache.org>
Authored: Wed May 31 20:18:25 2017 -0400
Committer: Nick Couchman <ni...@yahoo.com>
Committed: Mon Jun 5 15:34:21 2017 -0400
----------------------------------------------------------------------
.../RestrictedGuacamoleTunnelService.java | 27 +++++++++++++-------
1 file changed, 18 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/56f6c4bb/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 49af081..590648c 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
@@ -48,6 +48,11 @@ public class RestrictedGuacamoleTunnelService
extends AbstractGuacamoleTunnelService {
/**
+ * Logger for this class.
+ */
+ private static final Logger logger = LoggerFactory.getLogger(RestrictedGuacamoleTunnelService.class);
+
+ /**
* The environment of the Guacamole server.
*/
@Inject
@@ -176,14 +181,6 @@ public class RestrictedGuacamoleTunnelService
// Get username
String username = user.getIdentifier();
- // Remove connections where weight < 0
- Iterator<ModeledConnection> i = connections.iterator();
- while(i.hasNext()) {
- Integer weight = i.next().getConnectionWeight();
- if (weight != null && weight.intValue() < 0)
- i.remove();
- }
-
// Sort connections in ascending order of usage
ModeledConnection[] sortedConnections = connections.toArray(new ModeledConnection[connections.size()]);
Arrays.sort(sortedConnections, new Comparator<ModeledConnection>() {
@@ -195,12 +192,22 @@ public class RestrictedGuacamoleTunnelService
// Check if weight of a is null, assign 1 if it is.
if (a.getConnectionWeight() == null)
weightA = 1;
+ // If weight is less than 1, host will be disabled
+ // but for sorting we set it to 1 to avoid divide
+ // by 0.
+ else if (a.getConnectionWeight().intValue() < 1)
+ weightA = 1;
else
weightA = a.getConnectionWeight().intValue() + 1;
// Check if weight of b is null, assign 1 if it is.
if (b.getConnectionWeight() == null)
weightB = 1;
+ // If weight is less than 1, host will be disabled,
+ // but for sorting we set it to 1 to avoid divide
+ // by 0.
+ else if (b.getConnectionWeight().intValue() < 1)
+ weightB = 1;
else
weightB = b.getConnectionWeight().intValue() + 1;
@@ -220,8 +227,10 @@ public class RestrictedGuacamoleTunnelService
for (ModeledConnection connection : sortedConnections) {
// If connection weight is zero or negative, this host is disabled and should not be used.
- if (connection.getConnectionWeight() < 1)
+ if (connection.getConnectionWeight() != null && connection.getConnectionWeight().intValue() < 1) {
+ logger.warn("Weight for {} is non-null and < 1, connection will be skipped.", connection.getName());
continue;
+ }
// Attempt to aquire connection according to per-user limits
Seat seat = new Seat(username, connection.getIdentifier());
[15/28] incubator-guacamole-client git commit: GUACAMOLE-102: Move
null checking logic to ModeledConnection.
Posted by mj...@apache.org.
GUACAMOLE-102: Move null checking logic to ModeledConnection.
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/f66bbd2e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/f66bbd2e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/f66bbd2e
Branch: refs/heads/master
Commit: f66bbd2e0f07e1dd15d15d94265eaadb87fbd888
Parents: f77c507
Author: Nick Couchman <vn...@apache.org>
Authored: Mon Jun 5 14:53:21 2017 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Mon Jun 5 21:43:05 2017 -0400
----------------------------------------------------------------------
.../guacamole/auth/jdbc/connection/ConnectionModel.java | 6 ++----
.../guacamole/auth/jdbc/connection/ModeledConnection.java | 9 ++++++---
2 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/f66bbd2e/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
index 2da37a7..f208b5a 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java
@@ -192,10 +192,8 @@ public class ConnectionModel extends ChildObjectModel {
* negative numbers are used to indicate the system is
* unavailable.
*/
- public int getConnectionWeight() {
- if (connectionWeight == null)
- return 1;
- return connectionWeight.intValue();
+ public Integer getConnectionWeight() {
+ return connectionWeight;
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/f66bbd2e/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
index 67bd793..7e11a76 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
@@ -412,7 +412,8 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
}
/**
- * Returns the weight of the connection, or the default.
+ * Returns the weight of the connection, or a default
+ * of 1 if the weight is undefined.
*
* @return
* The weight of the connection.
@@ -420,8 +421,10 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
*/
public int getConnectionWeight() {
- // Return the connection weight
- return getModel().getConnectionWeight();
+ Integer connectionWeight = getModel().getConnectionWeight();
+ if(connectionWeight == null)
+ return 1;
+ return connectionWeight;
}
[27/28] incubator-guacamole-client git commit: GUACAMOLE-102:
Cleaning up comment, because apparently tu-tus don't go with Guacamole!
Posted by mj...@apache.org.
GUACAMOLE-102: Cleaning up comment, because apparently tu-tus don't go with Guacamole!
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/d8ba0f83
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/d8ba0f83
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/d8ba0f83
Branch: refs/heads/master
Commit: d8ba0f83ef725761631049a143d1c9686c276c98
Parents: 5532819
Author: Nick Couchman <vn...@apache.org>
Authored: Tue Jun 6 19:59:53 2017 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Tue Jun 6 19:59:53 2017 -0400
----------------------------------------------------------------------
.../apache/guacamole/auth/jdbc/connection/ModeledConnection.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/d8ba0f83/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
index 3c85f37..3d6e625 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ModeledConnection.java
@@ -131,7 +131,7 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
));
/**
- * All attributes related to to load balancing in a logical form.
+ * All attributes related to load balancing in a logical form.
*/
public static final Form LOAD_BALANCING = new Form("load-balancing", Arrays.<Field>asList(
new NumericField(CONNECTION_WEIGHT)
[25/28] incubator-guacamole-client git commit: GUACAMOLE-102: Make
field header consistent; add section header for new load balancing section.
Posted by mj...@apache.org.
GUACAMOLE-102: Make field header consistent; add section header for new load balancing section.
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/166c7cca
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/166c7cca
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/166c7cca
Branch: refs/heads/master
Commit: 166c7ccaedc5c1701ef338bac6472f4685199fb9
Parents: 2986c61
Author: Nick Couchman <vn...@apache.org>
Authored: Tue Jun 6 08:55:11 2017 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Tue Jun 6 08:55:11 2017 -0400
----------------------------------------------------------------------
.../src/main/resources/translations/en.json | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/166c7cca/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/resources/translations/en.json
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/resources/translations/en.json b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/resources/translations/en.json
index c154d8b..93e95d5 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/resources/translations/en.json
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/resources/translations/en.json
@@ -19,7 +19,8 @@
"FIELD_HEADER_MAX_CONNECTIONS" : "Maximum number of connections:",
"FIELD_HEADER_MAX_CONNECTIONS_PER_USER" : "Maximum number of connections per user:",
- "FIELD_HEADER_WEIGHT" : "Connection Weight for Load Balancing:",
+
+ "FIELD_HEADER_WEIGHT" : "Connection weight for load balancing:",
"FIELD_HEADER_GUACD_HOSTNAME" : "Hostname:",
"FIELD_HEADER_GUACD_ENCRYPTION" : "Encryption:",
@@ -29,8 +30,9 @@
"FIELD_OPTION_GUACD_ENCRYPTION_NONE" : "None (unencrypted)",
"FIELD_OPTION_GUACD_ENCRYPTION_SSL" : "SSL / TLS",
- "SECTION_HEADER_CONCURRENCY" : "Concurrency Limits",
- "SECTION_HEADER_GUACD" : "Guacamole Proxy Parameters (guacd)"
+ "SECTION_HEADER_CONCURRENCY" : "Concurrency Limits",
+ "SECTION_HEADER_LOAD_BALANCING" : "Load Balancing",
+ "SECTION_HEADER_GUACD" : "Guacamole Proxy Parameters (guacd)"
},