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 dfbf0e9b5..53935e62f 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,7 +81,7 @@ public abstract class JDBCEnvironment extends LocalEnvironment { * If an error occurs while retrieving the property. */ public abstract int getDefaultMaxConnections() throws GuacamoleException; - + /** * Returns the default maximum number of concurrent connections to allow to * any one connection group, unless specified differently on an individual 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 44f4b3b69..78cc885b4 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 @@ -54,6 +54,13 @@ public class ConnectionModel extends ChildObjectModel { */ private Integer maxConnectionsPerUser; + /** + * The weight of the connection for the purposes of calculating + * WLC algorithm. null indicates nothing has been set, and anything less + * than 1 eliminates the system from being used for connections. + */ + private Integer connectionWeight; + /** * The identifiers of all readable sharing profiles associated with this * connection. @@ -164,6 +171,31 @@ public class ConnectionModel extends ChildObjectModel { return maxConnectionsPerUser; } + /** + * Sets the connection weight for load balancing. + * + * @param connectionWeight + * 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 applying weighted + * load balancing algorithms. + * + * @return + * The connection weight used in applying weighted + * load balancing aglorithms. + */ + public Integer getConnectionWeight() { + return connectionWeight; + } + /** * Sets the maximum number of connections that can be established to this * connection concurrently by any one user. 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 bcd7b117e..3d6e625b0 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 @@ -116,6 +116,11 @@ public class ModeledConnection extends ModeledChildDirectoryObjectasList( + new NumericField(CONNECTION_WEIGHT) + )); + /** * All possible attributes of connection objects organized as individual, * logical forms. */ public static final Collection
ATTRIBUTES = Collections.unmodifiableCollection(Arrays.asList( CONCURRENCY_LIMITS, + LOAD_BALANCING, GUACD_PARAMETERS )); @@ -265,6 +278,9 @@ public class ModeledConnection extends ModeledChildDirectoryObject + parent_id = #{parentIdentifier,jdbcType=VARCHAR} @@ -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} ) @@ -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} 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 e018617ba..7b9081ee6 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), 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 000000000..6388b445f --- /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; 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 44828fa29..f53e43948 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 @@ + parent_id = #{parentIdentifier,jdbcType=INTEGER}::integer @@ -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} ) @@ -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