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

jcambon
12.18.2009 f5f7aec63906ffc084de9a79d95f1016ac6276bb
Partial Fix for issue #3938 : dsconfig is really too slow in non-interactive mode, almost unusable on Niagara systems

This is a partial fix for this dsconfig performance issue:
Linked to fix for issue #2017 (tools usage should disclose default value for options),
we systematically parsed the configuration file.
This fix allows to only parse the config file when necessary (i.e. for help command, or if -port/--trustAll not specified in the command line)

On a machine with a CPU almost equivalent of the Niagara ones,
it allows to save ~20% of the dsconfig time (~9s instead of ~11s).
4 files modified
46 ■■■■ changed files
opends/src/server/org/opends/server/tools/dsconfig/DSConfig.java 6 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsconfig/InternalManagementContextFactory.java 9 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java 21 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsconfig/ManagementContextFactory.java 10 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsconfig/DSConfig.java
@@ -544,7 +544,8 @@
   * @throws ArgumentException
   *           If a global argument could not be registered.
   */
  private void initializeGlobalArguments() throws ArgumentException {
  private void initializeGlobalArguments(String[] args)
    throws ArgumentException {
    if (globalArgumentsInitialized == false) {
      verboseArgument = new BooleanArgument("verbose", 'v', "verbose",
          INFO_DESCRIPTION_VERBOSE.get());
@@ -619,6 +620,7 @@
      // Register any global arguments required by the management
      // context factory.
      factory.setRawArguments(args);
      factory.registerGlobalArguments(parser);
      globalArgumentsInitialized = true;
@@ -706,7 +708,7 @@
  private int run(String[] args) {
    // Register global arguments and sub-commands.
    try {
      initializeGlobalArguments();
      initializeGlobalArguments(args);
      initializeSubCommands();
    } catch (ArgumentException e) {
      Message message = ERR_CANNOT_INITIALIZE_ARGS.get(e.getMessage());
opends/src/server/org/opends/server/tools/dsconfig/InternalManagementContextFactory.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2007-2008 Sun Microsystems, Inc.
 *      Copyright 2007-2009 Sun Microsystems, Inc.
 */
package org.opends.server.tools.dsconfig;
@@ -105,4 +105,11 @@
    return new CommandBuilder(null, null);
  }
  /**
   * {@inheritDoc}
   */
  public void setRawArguments(String[] args) {
    // No implementation required.
  }
}
opends/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java
@@ -59,6 +59,7 @@
import java.util.LinkedHashSet;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLHandshakeException;
import org.opends.server.tools.ToolConstants;
/**
@@ -79,6 +80,9 @@
  // This CLI is always using the administration connector with SSL
  private boolean alwaysSSL = false;
  // Raw arguments
  private String[] rawArgs = null;
  /**
   * Creates a new LDAP management context factory.
   *
@@ -323,7 +327,13 @@
    return context;
  }
  /**
   * {@inheritDoc}
   */
  public void setRawArguments(String[] args) {
    this.rawArgs = args;
  }
  /**
   * {@inheritDoc}
@@ -343,7 +353,16 @@
    try
    {
      secureArgsList.initArgumentsWithConfiguration();
      if (rawArgs != null) {
        for (String rawArg : rawArgs) {
          if (rawArg.contains(ToolConstants.OPTION_LONG_HELP) ||
            (rawArg.charAt(1) == ToolConstants.OPTION_SHORT_HELP) || (rawArg.
            charAt(1) == '?')) {
            // used for usage default values only
            secureArgsList.initArgumentsWithConfiguration();
          }
        }
      }
    }
    catch (ConfigException ce)
    {
opends/src/server/org/opends/server/tools/dsconfig/ManagementContextFactory.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2007-2008 Sun Microsystems, Inc.
 *      Copyright 2007-2009 Sun Microsystems, Inc.
 */
package org.opends.server.tools.dsconfig;
@@ -88,6 +88,14 @@
  /**
   * Set the raw arguments (used for default value setting).
   *
   * @param args raw arguments.
   */
  public void setRawArguments(String[] args);
  /**
   * Validates any global arguments passed to the application.
   * Implementations of this method should check that the values
   * passed to their global arguments are valid and are not