From 03fe0954e42abf00746b8efa4c79ee74cf514427 Mon Sep 17 00:00:00 2001
From: ludovicp <ludovicp@localhost>
Date: Thu, 27 May 2010 15:10:50 +0000
Subject: [PATCH] Fix an issue with connection timeouts in CLI. The timeout is now configurable on CLI with the --connectTimeout option (expressed in milliseconds), the default is 30 000 milliseconds. This solves Issue 4196.

---
 opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java |   27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java b/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
index 8c1b313..d1276bd 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
@@ -83,6 +83,7 @@
   private boolean stopPooling;
   private boolean pooling;
   private ApplicationTrustManager trustManager;
+  private int connectTimeout = ConnectionUtils.getDefaultLDAPTimeout();
   private ConnectionProtocolPolicy connectionPolicy =
     ConnectionProtocolPolicy.USE_MOST_SECURE_AVAILABLE;
   private String ldapURL;
@@ -353,7 +354,7 @@
     {
       InitialLdapContext cloneLdc =
         ConnectionUtils.cloneInitialLdapContext(userDataCtx,
-            ConnectionUtils.getDefaultLDAPTimeout(),
+            getConnectTimeout(),
             getTrustManager(), null);
       connectionPool.registerConnection(cloneLdc);
     }
@@ -579,7 +580,7 @@
             ctx = Utils.createLdapsContext(lastRemoteAdministrationURL,
                 lastWorkingBindDN,
                 lastWorkingBindPwd,
-                Utils.getDefaultLDAPTimeout(), null,
+                getConnectTimeout(), null,
                 getTrustManager());
           }
         }
@@ -885,6 +886,28 @@
   }
 
   /**
+   * Returns the timeout to establish the connection in milliseconds.
+   * @return the timeout to establish the connection in milliseconds.
+   */
+  public int getConnectTimeout()
+  {
+    return connectTimeout;
+  }
+
+  /**
+   * Sets the timeout to establish the connection in milliseconds.
+   * Use {@code 0} to express no timeout.
+   * @param connectTimeout the timeout to establish the connection in
+   * milliseconds.
+   * Use {@code 0} to express no timeout.
+   */
+  public void setConnectTimeout(int connectTimeout)
+  {
+    this.connectTimeout = connectTimeout;
+    connectionPool.setConnectTimeout(connectTimeout);
+  }
+
+  /**
    * Returns the connection policy to be used by this ControlPanelInfo (and in
    * general by the control panel).
    * @return the connection policy to be used by this ControlPanelInfo.

--
Gitblit v1.10.0