From 97491bcdb796a35879477018ea768c1be2c989e4 Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Fri, 22 Oct 2010 06:52:25 +0000
Subject: [PATCH] Sync commit by matthew_swift Expose Grizzly transport configuration in LDAPOptions and LDAPListenerOptions in order to allow better customization of transport.
---
sdk/src/com/sun/opends/sdk/tools/AuthRate.java | 59 ++++++++++++++++++++++++++++++-----------------------------
1 files changed, 30 insertions(+), 29 deletions(-)
diff --git a/sdk/src/com/sun/opends/sdk/tools/AuthRate.java b/sdk/src/com/sun/opends/sdk/tools/AuthRate.java
index 7965437..e6a4890 100644
--- a/sdk/src/com/sun/opends/sdk/tools/AuthRate.java
+++ b/sdk/src/com/sun/opends/sdk/tools/AuthRate.java
@@ -65,10 +65,11 @@
- private BindStatsThread()
+ private BindStatsThread(boolean extraFieldRequired)
{
- super(new String[] { "bind time %" });
- extraColumn = new String[1];
+ super(extraFieldRequired ? new String[] { "bind time %" }
+ : new String[0]);
+ extraColumn = new String[extraFieldRequired ? 1 : 0];
}
@@ -77,9 +78,12 @@
String[] getAdditionalColumns()
{
invalidCredRecentCount.set(0);
- final long searchWaitTime = searchWaitRecentTime.getAndSet(0);
- extraColumn[0] = String.format("%.1f",
- ((float)(waitTime - searchWaitTime) / waitTime) * 100.0);
+ if (extraColumn.length != 0)
+ {
+ final long searchWaitTime = searchWaitRecentTime.getAndSet(0);
+ extraColumn[0] = String.format("%.1f",
+ ((float) (waitTime - searchWaitTime) / waitTime) * 100.0);
+ }
return extraColumn;
}
}
@@ -183,7 +187,7 @@
else
{
return performBind(connection, data,
- new UpdateStatsResultHandler<BindResult>(startTime));
+ new BindUpdateStatsResultHandler(startTime));
}
}
@@ -383,11 +387,7 @@
@Override
StatsThread newStatsThread()
{
- if(filter != null && baseDN != null)
- {
- return new BindStatsThread();
- }
- return new StatsThread(new String[0]);
+ return new BindStatsThread(filter != null && baseDN != null);
}
@@ -400,7 +400,7 @@
}
}
/**
- * The main method for SearchRate tool.
+ * The main method for AuthRate tool.
*
* @param args
* The command-line arguments provided to this program.
@@ -408,7 +408,7 @@
public static void main(final String[] args)
{
- final int retCode = mainSearchRate(args, System.in, System.out, System.err);
+ final int retCode = mainAuthRate(args, System.in, System.out, System.err);
System.exit(filterExitCode(retCode));
}
@@ -416,23 +416,23 @@
/**
* Parses the provided command-line arguments and uses that information to run
- * the ldapsearch tool.
+ * the tool.
*
* @param args
* The command-line arguments provided to this program.
* @return The error code.
*/
- static int mainSearchRate(final String[] args)
+ static int mainAuthRate(final String[] args)
{
- return mainSearchRate(args, System.in, System.out, System.err);
+ return mainAuthRate(args, System.in, System.out, System.err);
}
/**
* Parses the provided command-line arguments and uses that information to run
- * the ldapsearch tool.
+ * the tool.
*
* @param args
* The command-line arguments provided to this program.
@@ -448,7 +448,7 @@
* @return The error code.
*/
- static int mainSearchRate(final String[] args, final InputStream inStream,
+ static int mainAuthRate(final String[] args, final InputStream inStream,
final OutputStream outStream, final OutputStream errStream)
{
@@ -654,6 +654,14 @@
try
{
argParser.parseArguments(args);
+
+ // If we should just display usage or version information,
+ // then print it and exit.
+ if (argParser.usageOrVersionDisplayed())
+ {
+ return 0;
+ }
+
connectionFactory =
connectionFactoryProvider.getConnectionFactory();
runner.validate();
@@ -670,26 +678,19 @@
final LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae
.getMessage());
println(message);
- println(argParser.getUsageMessage());
return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
}
- // If we should just display usage or version information,
- // then print it and exit.
- if (argParser.usageOrVersionDisplayed())
- {
- return 0;
- }
-
final List<String> attributes = new LinkedList<String>();
final ArrayList<String> filterAndAttributeStrings = argParser
.getTrailingArguments();
if (filterAndAttributeStrings.size() > 0)
{
// the list of trailing arguments should be structured as follow:
- // the first trailing argument is
- // considered the filter, the other as attributes.
+ // the first trailing argument is considered the filter, the other as
+ // attributes.
runner.filter = filterAndAttributeStrings.remove(0);
+
// The rest are attributes
for (final String s : filterAndAttributeStrings)
{
--
Gitblit v1.10.0