From ad636a8035cc19f5a412b6b97b3f95ba37d0fe9a Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Fri, 30 Aug 2013 14:25:48 +0000
Subject: [PATCH] Back-port fix for OPENDJ-1112: LoadBalancing connection factories need better diagnostic messages
---
opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/FailoverLoadBalancingAlgorithm.java | 78 +++++++++++++++++++++++++++++++++++---
1 files changed, 71 insertions(+), 7 deletions(-)
diff --git a/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/FailoverLoadBalancingAlgorithm.java b/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/FailoverLoadBalancingAlgorithm.java
index 44c1ed1..9e9f6a1 100644
--- a/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/FailoverLoadBalancingAlgorithm.java
+++ b/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/FailoverLoadBalancingAlgorithm.java
@@ -22,6 +22,7 @@
*
*
* Copyright 2010 Sun Microsystems, Inc.
+ * Portions copyright 2013 ForgeRock AS.
*/
package org.forgerock.opendj.ldap;
@@ -35,10 +36,10 @@
* underlying connection factories.
* <p>
* This algorithm is typically used for load-balancing <i>between</i> data
- * centers, where there is preference to always forward connection
- * requests to the <i>closest available</i> data center. This algorithm
- * contrasts with the {@link RoundRobinLoadBalancingAlgorithm} which is used for
- * load-balancing <i>within</i> a data center.
+ * centers, where there is preference to always forward connection requests to
+ * the <i>closest available</i> data center. This algorithm contrasts with the
+ * {@link RoundRobinLoadBalancingAlgorithm} which is used for load-balancing
+ * <i>within</i> a data center.
* <p>
* This algorithm selects connection factories based on the order in which they
* were provided during construction. More specifically, an attempt to obtain a
@@ -69,7 +70,70 @@
* The ordered collection of connection factories.
*/
public FailoverLoadBalancingAlgorithm(final Collection<ConnectionFactory> factories) {
- super(factories);
+ this(factories, null, 1, TimeUnit.SECONDS, null);
+ }
+
+ /**
+ * Creates a new fail-over load balancing algorithm which will monitor
+ * offline connection factories every 1 second using the default scheduler.
+ *
+ * @param factories
+ * The ordered collection of connection factories.
+ * @param listener
+ * The event listener which should be notified whenever a
+ * connection factory changes state from online to offline or
+ * vice-versa.
+ */
+ public FailoverLoadBalancingAlgorithm(final Collection<ConnectionFactory> factories,
+ final LoadBalancerEventListener listener) {
+ this(factories, listener, 1, TimeUnit.SECONDS, null);
+ }
+
+ /**
+ * Creates a new fail-over load balancing algorithm which will monitor
+ * offline connection factories using the specified frequency using the
+ * default scheduler.
+ *
+ * @param factories
+ * The connection factories.
+ * @param listener
+ * The event listener which should be notified whenever a
+ * connection factory changes state from online to offline or
+ * vice-versa.
+ * @param interval
+ * The interval between attempts to poll offline factories.
+ * @param unit
+ * The time unit for the interval between attempts to poll
+ * offline factories.
+ */
+ public FailoverLoadBalancingAlgorithm(final Collection<ConnectionFactory> factories,
+ final LoadBalancerEventListener listener, final long interval, final TimeUnit unit) {
+ this(factories, listener, interval, unit, null);
+ }
+
+ /**
+ * Creates a new fail-over load balancing algorithm which will monitor
+ * offline connection factories using the specified frequency and scheduler.
+ *
+ * @param factories
+ * The connection factories.
+ * @param listener
+ * The event listener which should be notified whenever a
+ * connection factory changes state from online to offline or
+ * vice-versa.
+ * @param interval
+ * The interval between attempts to poll offline factories.
+ * @param unit
+ * The time unit for the interval between attempts to poll
+ * offline factories.
+ * @param scheduler
+ * The scheduler which should for periodically monitoring dead
+ * connection factories to see if they are usable again.
+ */
+ public FailoverLoadBalancingAlgorithm(final Collection<ConnectionFactory> factories,
+ final LoadBalancerEventListener listener, final long interval, final TimeUnit unit,
+ final ScheduledExecutorService scheduler) {
+ super(factories, listener, interval, unit, scheduler);
}
/**
@@ -87,7 +151,7 @@
*/
public FailoverLoadBalancingAlgorithm(final Collection<ConnectionFactory> factories,
final long interval, final TimeUnit unit) {
- super(factories, interval, unit);
+ this(factories, null, interval, unit, null);
}
/**
@@ -107,7 +171,7 @@
*/
public FailoverLoadBalancingAlgorithm(final Collection<ConnectionFactory> factories,
final long interval, final TimeUnit unit, final ScheduledExecutorService scheduler) {
- super(factories, interval, unit, scheduler);
+ this(factories, null, interval, unit, scheduler);
}
/**
--
Gitblit v1.10.0