mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Ludovic Poitou
22.52.2010 97491bcdb796a35879477018ea768c1be2c989e4
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)
      {