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/server/org/opends/server/tools/InstallDSArgumentParser.java | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/opends/src/server/org/opends/server/tools/InstallDSArgumentParser.java b/opends/src/server/org/opends/server/tools/InstallDSArgumentParser.java
index 3cf450b..900d30b 100644
--- a/opends/src/server/org/opends/server/tools/InstallDSArgumentParser.java
+++ b/opends/src/server/org/opends/server/tools/InstallDSArgumentParser.java
@@ -36,6 +36,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;
+import org.opends.admin.ads.util.ConnectionUtils;
import org.opends.messages.Message;
import org.opends.quicksetup.Constants;
import org.opends.quicksetup.Installation;
@@ -99,6 +100,7 @@
StringArgument keyStorePasswordArg;
StringArgument certNicknameArg;
StringArgument progNameArg;
+ IntegerArgument connectTimeoutArg = null;
private static final Logger LOG = Logger.getLogger(
InstallDSArgumentParser.class.getName());
@@ -411,6 +413,17 @@
INFO_INSTALLDS_DESCRIPTION_CERT_NICKNAME.get());
addDefaultArgument(certNicknameArg);
+ int defaultTimeout = ConnectionUtils.getDefaultLDAPTimeout();
+ connectTimeoutArg = new IntegerArgument(OPTION_LONG_CONNECT_TIMEOUT,
+ null, OPTION_LONG_CONNECT_TIMEOUT,
+ false, false, true, INFO_TIMEOUT_PLACEHOLDER.get(),
+ defaultTimeout, null,
+ true, 1, true, 65535,
+ INFO_DESCRIPTION_CONNECTION_TIMEOUT.get());
+ connectTimeoutArg.setPropertyName(OPTION_LONG_CONNECT_TIMEOUT);
+ connectTimeoutArg.setHidden(true);
+ addArgument(connectTimeoutArg);
+
showUsageArg = new BooleanArgument(
OPTION_LONG_HELP.toLowerCase(), OPTION_SHORT_HELP,
OPTION_LONG_HELP,
@@ -784,4 +797,24 @@
String configDir = Utils.getPath(root, Installation.CONFIG_PATH_RELATIVE);
return Utils.getPath(configDir, Installation.CURRENT_CONFIG_FILE_NAME);
}
+
+ /**
+ * Returns the timeout to be used to connect in milliseconds. The method
+ * must be called after parsing the arguments.
+ * @return the timeout to be used to connect in milliseconds. Returns
+ * {@code 0} if there is no timeout.
+ * @throw {@code IllegalStateException} if the method is called before
+ * parsing the arguments.
+ */
+ public int getConnectTimeout()
+ {
+ try
+ {
+ return connectTimeoutArg.getIntValue();
+ }
+ catch (ArgumentException ae)
+ {
+ throw new IllegalStateException("Argument parser is not parsed: "+ae, ae);
+ }
+ }
}
--
Gitblit v1.10.0