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

jvergara
29.24.2009 366f4d0fdb60facc557fa4517d60b431ccf40d6e
Fix for issue 4151 (Default java heap not enough to launch import)

The idea is to improve what we currently have, which is relying on java ergonomics and only setting the '-client' and '-server' arguments as default java arguments. As far as I can see with the new import code, the java ergonomics (this has been reproduced in Solaris and Mac OS X) are not enough to guarantee that the server will be able to make a small import (around 2000 entries) out of the box.

The proposed fix tries to set the following arguments to the server command-lines (start-ds and import-ldif in particular):

-Xms128m -Xmx256m

These arguments will be set if and only if:

They can be used while the setup is being run (and so the JVM supports them and the system where we are running is able to launch a JVM using them).

The ergonomics of the JVM where the setup is being run does not allocate a maximum heap that is higher than those values. With this check we guarantee that we are not going to allocate less memory than what the JVM already does by default.
1 files modified
50 ■■■■■ changed files
opends/src/quicksetup/org/opends/quicksetup/installer/InstallerHelper.java 50 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/installer/InstallerHelper.java
@@ -102,6 +102,10 @@
  private static final String INITIAL_CLIENT_HEAP_ARG = "-Xms8m";
  private static final String SERVER_HEAP_ARGS = "-Xms128m -Xmx256m";
  private static final long SERVER_MAX_HEAP_BYTES = 256 * 1024 * 1024;
  /**
   * Invokes the method ConfigureDS.configMain with the provided parameters.
   * @param args the arguments to be passed to ConfigureDS.configMain.
@@ -926,10 +930,17 @@
      boolean supportsClient = supportsClient(javaHome, installPath);
      boolean supportsServer = supportsServer(javaHome, installPath);
      boolean supportsClientInitialHeap = supportsInitialHeap(javaHome,
          installPath);
      boolean supportsClientInitialHeap =
        supportsOption(INITIAL_CLIENT_HEAP_ARG, javaHome, installPath);
      boolean supportsServerInitialHeap = false;
      // If the current max memory is bigger than the max heap we want to set,
      // assume that the JVM ergonomics are going to be able to allocate enough
      // memory.
      if (Runtime.getRuntime().maxMemory() < SERVER_MAX_HEAP_BYTES)
      {
        supportsServerInitialHeap =
          supportsOption(SERVER_HEAP_ARGS, javaHome, installPath);
      }
      // Scripts to which we will pass -client argument
      String[] clientScripts =
      {
@@ -950,12 +961,25 @@
          "upgrade", "verify-index", "dbtest"
      };
      if (supportsServer)
      if (supportsServer || supportsServerInitialHeap)
      {
        for (int i=0; i<serverScripts.length; i++)
        {
          writer.newLine();
          writer.write(serverScripts[i]+".java-args=-server");
          String arg = "";
          if (supportsServer)
          {
            arg = "-server";
          }
          if (supportsServerInitialHeap)
          {
            if (arg.length() > 0)
            {
              arg += " ";
            }
            arg += SERVER_HEAP_ARGS;
          }
          writer.write(serverScripts[i]+".java-args="+arg);
        }
      }
      else
@@ -967,7 +991,6 @@
        }
      }
      if (supportsClient || supportsClientInitialHeap)
      {
        for (int i=0; i<clientScripts.length; i++)
@@ -1085,19 +1108,6 @@
  }
  /**
   * Tells whether the provided java installation supports the server option
   * or not.
   * @param javaHome the java installation path.
   * @param installPath the install path of the server.
   * @return <CODE>true</CODE> if the provided java installation supports the
   * server option and <CODE>false</CODE> otherwise.
   */
  private boolean supportsInitialHeap(String javaHome, String installPath)
  {
    return supportsOption(INITIAL_CLIENT_HEAP_ARG, javaHome, installPath);
  }
  /**
   * Tells whether the provided java installation supports the client option
   * or not.
   * @param javaHome the java installation path.