GUACAMOLE-317: Add "failover_only" column to database schema for Guacamole connections.

This commit is contained in:
Michael Jumper
2017-06-06 13:29:22 -07:00
parent eb087ae290
commit 3c553b965c
7 changed files with 75 additions and 13 deletions

View File

@@ -61,6 +61,13 @@ public class ConnectionModel extends ChildObjectModel {
*/
private Integer connectionWeight;
/**
* Whether this connection should be reserved for failover. Failover-only
* connections within a balancing group are only used when all non-failover
* connections are unavailable.
*/
private boolean failoverOnly;
/**
* The identifiers of all readable sharing profiles associated with this
* connection.
@@ -196,6 +203,32 @@ public class ConnectionModel extends ChildObjectModel {
return connectionWeight;
}
/**
* Returns whether this connection should be reserved for failover.
* Failover-only connections within a balancing group are only used when
* all non-failover connections are unavailable.
*
* @return
* true if this connection should be reserved for failover, false
* otherwise.
*/
public boolean isFailoverOnly() {
return failoverOnly;
}
/**
* Sets whether this connection should be reserved for failover.
* Failover-only connections within a balancing group are only used when
* all non-failover connections are unavailable.
*
* @param failoverOnly
* true if this connection should be reserved for failover, false
* otherwise.
*/
public void setFailoverOnly(boolean failoverOnly) {
this.failoverOnly = failoverOnly;
}
/**
* Sets the maximum number of connections that can be established to this
* connection concurrently by any one user.

View File

@@ -65,9 +65,9 @@ CREATE TABLE `guacamole_connection` (
`max_connections` int(11),
`max_connections_per_user` int(11),
-- Connection weight
-- Load-balancing behavior
`connection_weight` int(11),
`failover_only` boolean NOT NULL DEFAULT 0,
PRIMARY KEY (`connection_id`),
UNIQUE KEY `connection_name_parent` (`connection_name`, `parent_id`),

View File

@@ -23,3 +23,10 @@
ALTER TABLE guacamole_connection
ADD COLUMN connection_weight int(11);
--
-- Add failover-only flag
--
ALTER TABLE guacamole_connection
ADD COLUMN failover_only BOOLEAN NOT NULL DEFAULT 0;

View File

@@ -38,6 +38,7 @@
<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"/>
<result column="failover_only" property="failoverOnly" jdbcType="BOOLEAN"/>
<!-- Associated sharing profiles -->
<collection property="sharingProfileIdentifiers" resultSet="sharingProfiles" ofType="java.lang.String"
@@ -97,7 +98,8 @@
proxy_hostname,
proxy_port,
proxy_encryption_method,
connection_weight
connection_weight,
failover_only
FROM guacamole_connection
WHERE connection_id IN
<foreach collection="identifiers" item="identifier"
@@ -129,7 +131,8 @@
proxy_hostname,
proxy_port,
proxy_encryption_method,
connection_weight
connection_weight,
failover_only
FROM guacamole_connection
JOIN guacamole_connection_permission ON guacamole_connection_permission.connection_id = guacamole_connection.connection_id
WHERE guacamole_connection.connection_id IN
@@ -166,7 +169,8 @@
proxy_hostname,
proxy_port,
proxy_encryption_method,
connection_weight
connection_weight,
failover_only
FROM guacamole_connection
WHERE
<if test="parentIdentifier != null">parent_id = #{parentIdentifier,jdbcType=VARCHAR}</if>
@@ -194,7 +198,8 @@
proxy_hostname,
proxy_port,
proxy_encryption_method,
connection_weight
connection_weight,
failover_only
)
VALUES (
#{object.name,jdbcType=VARCHAR},
@@ -205,7 +210,8 @@
#{object.proxyHostname,jdbcType=VARCHAR},
#{object.proxyPort,jdbcType=INTEGER},
#{object.proxyEncryptionMethod,jdbcType=VARCHAR},
#{object.connectionWeight,jdbcType=INTEGER}
#{object.connectionWeight,jdbcType=INTEGER},
#{object.failoverOnly,jdbcType=BOOLEAN}
)
</insert>
@@ -222,6 +228,7 @@
proxy_port = #{object.proxyPort,jdbcType=INTEGER},
proxy_encryption_method = #{object.proxyEncryptionMethod,jdbcType=VARCHAR},
connection_weight = #{object.connectionWeight,jdbcType=INTEGER}
failover_only = #{object.failoverOnly,jdbcType=BOOLEAN}
WHERE connection_id = #{object.objectID,jdbcType=INTEGER}
</update>

View File

@@ -108,6 +108,7 @@ CREATE TABLE guacamole_connection (
-- Connection Weight
connection_weight integer,
failover_only boolean NOT NULL DEFAULT FALSE,
-- Guacamole proxy (guacd) overrides
proxy_port integer,

View File

@@ -23,3 +23,10 @@
ALTER TABLE guacamole_connection
ADD COLUMN connection_weight int;
--
-- Add failover-only flag
--
ALTER TABLE guacamole_connection
ADD COLUMN failover_only BOOLEAN NOT NULL DEFAULT FALSE;

View File

@@ -38,6 +38,7 @@
<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"/>
<result column="failover_only" property="failoverOnly" jdbcType="BOOLEAN"/>
<!-- Associated sharing profiles -->
<collection property="sharingProfileIdentifiers" resultSet="sharingProfiles" ofType="java.lang.String"
@@ -97,7 +98,8 @@
proxy_hostname,
proxy_port,
proxy_encryption_method,
connection_weight
connection_weight,
failover_only
FROM guacamole_connection
WHERE connection_id IN
<foreach collection="identifiers" item="identifier"
@@ -129,7 +131,8 @@
proxy_hostname,
proxy_port,
proxy_encryption_method,
connection_weight
connection_weight,
failover_only
FROM guacamole_connection
JOIN guacamole_connection_permission ON guacamole_connection_permission.connection_id = guacamole_connection.connection_id
WHERE guacamole_connection.connection_id IN
@@ -166,7 +169,8 @@
proxy_hostname,
proxy_port,
proxy_encryption_method,
connection_weight
connection_weight,
failover_only
FROM guacamole_connection
WHERE
<if test="parentIdentifier != null">parent_id = #{parentIdentifier,jdbcType=INTEGER}::integer</if>
@@ -194,7 +198,8 @@
proxy_hostname,
proxy_port,
proxy_encryption_method,
connection_weight
connection_weight,
failover_only
)
VALUES (
#{object.name,jdbcType=VARCHAR},
@@ -205,7 +210,8 @@
#{object.proxyHostname,jdbcType=VARCHAR},
#{object.proxyPort,jdbcType=INTEGER},
#{object.proxyEncryptionMethod,jdbcType=VARCHAR}::guacamole_proxy_encryption_method,
#{object.connectionWeight,jdbcType=INTEGER}
#{object.connectionWeight,jdbcType=INTEGER},
#{object.failoverOnly,jdbcType=BOOLEAN}
)
</insert>
@@ -221,7 +227,8 @@
proxy_hostname = #{object.proxyHostname,jdbcType=VARCHAR},
proxy_port = #{object.proxyPort,jdbcType=INTEGER},
proxy_encryption_method = #{object.proxyEncryptionMethod,jdbcType=VARCHAR}::guacamole_proxy_encryption_method,
connection_weight = #{object.connectionWeight,jdbcType=INTEGER}
connection_weight = #{object.connectionWeight,jdbcType=INTEGER},
failover_only = #{object.failoverOnly,jdbcType=BOOLEAN}
WHERE connection_id = #{object.objectID,jdbcType=INTEGER}::integer
</update>