From 23b59def043a8f71238ec5d73a393b32fb40f83c Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Thu, 14 Oct 2010 16:15:50 +0000
Subject: [PATCH] Commit from OpenDS, matthew_swift * add unit tests for ConnectionEventListeners.

---
 sdk/src/org/opends/sdk/AbstractLoadBalancingAlgorithm.java |   62 +++++++++++++++++--------------
 1 files changed, 34 insertions(+), 28 deletions(-)

diff --git a/sdk/src/org/opends/sdk/AbstractLoadBalancingAlgorithm.java b/sdk/src/org/opends/sdk/AbstractLoadBalancingAlgorithm.java
index 75826a1..42c7f8c 100644
--- a/sdk/src/org/opends/sdk/AbstractLoadBalancingAlgorithm.java
+++ b/sdk/src/org/opends/sdk/AbstractLoadBalancingAlgorithm.java
@@ -196,7 +196,7 @@
           {
             // Enable monitoring.
             monitoringFuture = scheduler.scheduleWithFixedDelay(
-                new MonitorThread(), 0, monitoringInterval,
+                new MonitorRunnable(), 0, monitoringInterval,
                 monitoringIntervalTimeUnit);
           }
         }
@@ -237,9 +237,9 @@
 
 
 
-  private final class MonitorThread implements Runnable
+  private final class MonitorRunnable implements Runnable
   {
-    private MonitorThread()
+    private MonitorRunnable()
     {
       // Nothing to do.
     }
@@ -277,43 +277,26 @@
 
 
   /**
-   * Creates a new abstract load balancing algorithm.
+   * Creates a new abstract load balancing algorithm which will monitor offline
+   * connection factories every 10 seconds using the default scheduler.
    *
    * @param factories
    *          The connection factories.
    */
   AbstractLoadBalancingAlgorithm(final Collection<ConnectionFactory> factories)
   {
-    this(factories, StaticUtils.getDefaultScheduler());
+    this(factories, 10, TimeUnit.SECONDS, StaticUtils.getDefaultScheduler());
   }
 
 
 
   /**
-   * Creates a new abstract load balancing algorithm.
+   * Creates a new abstract load balancing algorithm which will monitor offline
+   * connection factories using the specified frequency using the default
+   * scheduler.
    *
    * @param factories
    *          The connection factories.
-   * @param scheduler
-   *          The scheduler which should for periodically monitoring dead
-   *          connection factories to see if they are usable again.
-   */
-  AbstractLoadBalancingAlgorithm(final Collection<ConnectionFactory> factories,
-      final ScheduledExecutorService scheduler)
-  {
-    this(factories, StaticUtils.getDefaultScheduler(), 10, TimeUnit.SECONDS);
-  }
-
-
-
-  /**
-   * Creates a new abstract load balancing algorithm.
-   *
-   * @param factories
-   *          The connection factories.
-   * @param scheduler
-   *          The scheduler which should for periodically monitoring dead
-   *          connection factories to see if they are usable again.
    * @param interval
    *          The interval between attempts to poll offline factories.
    * @param unit
@@ -321,8 +304,31 @@
    *          factories.
    */
   AbstractLoadBalancingAlgorithm(final Collection<ConnectionFactory> factories,
-      final ScheduledExecutorService scheduler, final long interval,
-      final TimeUnit unit)
+      final long interval, final TimeUnit unit)
+  {
+    this(factories, interval, unit, StaticUtils.getDefaultScheduler());
+  }
+
+
+
+  /**
+   * Creates a new abstract load balancing algorithm which will monitor offline
+   * connection factories using the specified frequency and scheduler.
+   *
+   * @param factories
+   *          The connection factories.
+   * @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.
+   */
+  AbstractLoadBalancingAlgorithm(final Collection<ConnectionFactory> factories,
+      final long interval, final TimeUnit unit,
+      final ScheduledExecutorService scheduler)
   {
     Validator.ensureNotNull(factories, scheduler, unit);
 

--
Gitblit v1.10.0