GUACAMOLE-102: Initial addition of connection weight to JDBC authentication extension

This commit is contained in:
Nick Couchman
2017-03-19 11:57:28 -04:00
committed by Nick Couchman
parent 91920d0b2d
commit 025f77d1c4
11 changed files with 180 additions and 8 deletions

View File

@@ -87,6 +87,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
@@ -194,6 +199,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(

View File

@@ -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.

View File

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