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 78cc885b4..788daa1b0 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
@@ -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.
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 2f0aa7303..515ea726b 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
@@ -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`),
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
index 2b14e27f3..14a016b1f 100644
--- 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
@@ -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;
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 2f778fa5f..03ffa431c 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
@@ -38,6 +38,7 @@
+
parent_id = #{parentIdentifier,jdbcType=VARCHAR}
@@ -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}
)
@@ -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}
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 7b9081ee6..d1b5bf5f9 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
@@ -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,
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
index 6388b445f..20882ed74 100644
--- 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
@@ -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;
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 f53e43948..dd9265dfa 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
@@ -38,6 +38,7 @@
+
parent_id = #{parentIdentifier,jdbcType=INTEGER}::integer
@@ -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}
)
@@ -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