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

jvergara
05.12.2009 3ed20de790c625ca5f353df0254fd6b2ff78b634
Use timeout argument when launching start in the setup and control-panel code.
3 files modified
87 ■■■■■ changed files
opends/src/guitools/org/opends/guitools/controlpanel/task/RestartServerTask.java 30 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/task/StartServerTask.java 15 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java 42 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/task/RestartServerTask.java
@@ -47,6 +47,8 @@
{
  private boolean starting;
  private StartServerTask startTask;
  /**
   * Constructor of the task.
   * @param info the control panel information.
@@ -55,6 +57,7 @@
  public RestartServerTask(ControlPanelInfo info, ProgressDialog dlg)
  {
    super(info, dlg);
    startTask = new StartServerTask(info, dlg);
  }
  /**
@@ -94,7 +97,16 @@
   */
  private String getStartCommandLineName()
  {
    return getCommandLinePath("start-ds");
    return startTask.getCommandLinePath();
  }
  /**
   * Returns the arguments of the start command-line.
   * @return the arguments of the start command-line.
   */
  private ArrayList<String> getStartCommandLineArguments()
  {
    return startTask.getCommandLineArguments();
  }
  /**
@@ -120,14 +132,12 @@
      public void run()
      {
        String cmdLine = getStopCommandLineName();
        printEquivalentCommandLine(cmdLine, getCommandLineArguments(),
            INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_STOP_SERVER.get());
        dlg.setSummary(Message.raw(
            Utilities.applyFont(
            INFO_CTRL_PANEL_STOPPING_SERVER_SUMMARY.get().toString(),
            ColorAndFontConstants.defaultFont)));
        dlg.appendProgressHtml(Utilities.applyFont(
            INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_STOP_SERVER.get()+"<br><b>"+
              cmdLine+"</b><br><br>",
              ColorAndFontConstants.progressFont));
      }
    });
    // To display new status
@@ -158,21 +168,23 @@
                "<b>"+INFO_CTRL_PANEL_SERVER_STOPPED.get()+"</b><br><br>",
                ColorAndFontConstants.progressFont));
            String cmdLine = getStartCommandLineName();
            printEquivalentCommandLine(cmdLine, getStartCommandLineArguments(),
                INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_START_SERVER.get());
            dlg.setSummary(Message.raw(
                Utilities.applyFont(
                INFO_CTRL_PANEL_STARTING_SERVER_SUMMARY.get().toString(),
                ColorAndFontConstants.defaultFont)));
            dlg.appendProgressHtml(Utilities.applyFont(
                INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_START_SERVER.get()+"<br><b>"+
                  cmdLine+"</b><br><br>",
                  ColorAndFontConstants.progressFont));
          }
        });
        starting = true;
        // To display new status
        getInfo().regenerateDescriptor();
        arguments = getStartCommandLineArguments();
        args = new String[arguments.size()];
        arguments.toArray(args);
        returnCode = executeCommandLine(getStartCommandLineName(), args);
        if (returnCode != 0)
        {
opends/src/guitools/org/opends/guitools/controlpanel/task/StartServerTask.java
@@ -22,13 +22,15 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.task;
import static org.opends.messages.AdminToolMessages.*;
import java.util.ArrayList;
import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
import org.opends.guitools.controlpanel.ui.ProgressDialog;
import org.opends.messages.Message;
@@ -73,4 +75,15 @@
  {
    return getCommandLinePath("start-ds");
  }
  /**
   * {@inheritDoc}
   */
  protected ArrayList<String> getCommandLineArguments()
  {
    ArrayList<String> args = new ArrayList<String>();
    args.add("--timeout");
    args.add("0");
    return args;
  }
};
opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java
@@ -329,6 +329,8 @@
      ArrayList<String> argList = new ArrayList<String>();
      argList.add(Utils.getScriptPath(
          Utils.getPath(installation.getServerStartCommandFile())));
      argList.add("--timeout");
      argList.add("0");
      String[] args = new String[argList.size()];
      argList.toArray(args);
      ProcessBuilder pb = new ProcessBuilder(args);
@@ -423,22 +425,11 @@
           * to connect or since the startup process is asynchronous we will
           * have to wait for the databases and the listeners to initialize.
           * Just check if we can connect to the server.
           * Try 10 times with an interval of 5 seconds between try.
           * Try 30 times with an interval of 3 seconds between try.
           */
          boolean connected = false;
          Configuration config = installation.getCurrentConfiguration();
          int port = config.getAdminConnectorPort();
          String hostName = null;
          if (application != null)
          {
            hostName = application.getUserData().getHostName();
          }
          if (hostName == null)
          {
            hostName = "localhost";
          }
          hostName = ConnectionUtils.getHostNameForLdapUrl(hostName);
          String ldapUrl = "ldaps://"+hostName+":" + port;
          // See if the application has prompted for credentials.  If
          // not we'll just try to connect anonymously.
@@ -454,20 +445,35 @@
          }
          InitialLdapContext ctx = null;
          for (int i=0; i<20 && !connected; i++)
          for (int i=0; i<50 && !connected; i++)
          {
            if ((i == 10) || (i == 11) && !"localhost".equals(hostName))
            String hostName = null;
            if (application != null)
            {
              hostName = application.getUserData().getHostName();
            }
            if (hostName == null)
            {
              hostName = "localhost";
            }
            int dig = i % 10;
            if (((dig >= 3) || (dig <= 4)) &&
            !"localhost".equals(hostName))
            {
              // Try with local host.  This might be necessary in certain
              // network configurations.
              ldapUrl = "ldaps://localhost:" + port;
              hostName = "localhost";
            }
            if ((i == 15) || (i == 16))
            if (((dig >= 5) || (dig <= 6)))
            {
              // Try with 0.0.0.0.  This might be necessary in certain
              // network configurations.
              ldapUrl = "ldaps://0.0.0.0:" + port;
              hostName = "0.0.0.0";
            }
            hostName = ConnectionUtils.getHostNameForLdapUrl(hostName);
            String ldapUrl = "ldaps://"+hostName+":" + port;
            try
            {
              ctx = Utils.createLdapsContext(
@@ -497,7 +503,7 @@
            {
              try
              {
                Thread.sleep(7500);
                Thread.sleep(3000);
              }
              catch (Throwable t)
              {