Exemplo n.º 1
0
  /**
   * This method finds out the next port on which OptimizeIt can send its profiler output.
   *
   * <p>If "watchdog.server.&lt;SERVER_NAME&gt;.profilers.OptimizeIt.port is specified then, the
   * property value is returned as an int.
   *
   * <p>If not the "watchdog.profilers.OptimizeIt.startPort" property is looked up to find out where
   * the port numbers start for all the servers (and incremented by one for each server)
   *
   * <p>If this property is unspecified too, then the default is OPTIMIZEIT_START_PORT.
   */
  private static synchronized String getOptimizeItAuditPort(String serverPropertyPrefix) {
    String rc = DCPLib.getProperty(serverPropertyPrefix + ".profilers.OptimizeIt.port", null);
    if (rc != null) return rc;

    if (msOptimizeItStartPort < 0) {
      rc = DCPLib.getProperty("watchdog.java.profilers.OptimizeIt.startPort", null);
      if (rc == null) msOptimizeItStartPort = OPTIMIZEIT_START_PORT;
      else {
        try {
          msOptimizeItStartPort = Integer.parseInt(rc);
        } catch (NumberFormatException ex) {
          msOptimizeItStartPort = OPTIMIZEIT_START_PORT;
        }
      }
    }
    return Integer.toString(msOptimizeItStartPort++);
  }
Exemplo n.º 2
0
  /** Stop this server hard. Destroy the server process. */
  protected void stopServerHard() {
    if (mProcess != null) {
      String propertyName = getPropertyPrefix() + ".shutdown.cmd";
      String shutdownCmd = DCPLib.getProperty(propertyName, null);
      if (shutdownCmd != null) {
        mLogger.finer(propertyName + " " + shutdownCmd);
        ExecuteShutdownCmdThread script = new ExecuteShutdownCmdThread(shutdownCmd);
        script.start();
      }

      mLogger.finer("Destroying server process using destory()");
      mProcess.destroy();
      mLogger.finer("Destroyed server process");
      mProcess = null;
      mPid = 0;
    }
  }
Exemplo n.º 3
0
  /**
   * This method should update the ServerCommand "struct" and setup the necessary values for the
   * server to be executed under OptimizeIt.
   */
  protected void updateServerCommandForOptimizeIt(ServerCommand serverCmd) {

    mLogger.config(mPropertyPrefix + " checking for optit");

    String optitPrefix = WDConstants.WD_PREFIX + ".java.profilers.OptimizeIt.";

    String home = DCPLib.getProperty(optitPrefix + "home", null);
    if (home == null) {
      mLogger.warning("OptimizeItHome is not specified. Cannot start OptimizeIt");
      return;
    }

    if (!(new java.io.File(home)).exists()) {
      mLogger.warning("OptimizeItHome : " + home + " does not exist." + " Cannot start OptimizeIt");
      return;
    }

    String classPath = DCPLib.getProperty(optitPrefix + "addonClassPath", "");
    classPath = WDUtil.sreplace(classPath, "OPTIMIZEIT_HOME", home);
    serverCmd.setClasspath(serverCmd.getClasspath() + File.pathSeparator + classPath);

    String libPath = DCPLib.getProperty(optitPrefix + "addonLibPath", "");
    libPath = WDUtil.sreplace(libPath, "OPTIMIZEIT_HOME", home);

    String sysLibPath = serverCmd.getLibPath();
    if (sysLibPath == null) sysLibPath = System.getProperty("java.library.path", "");
    serverCmd.setLibPath(libPath + File.pathSeparator + sysLibPath);

    String javaArgs = DCPLib.getProperty(optitPrefix + "javaArgs", "");
    javaArgs = WDUtil.sreplace(javaArgs, "OPTIMIZEIT_HOME", home);
    List jvmFlags = serverCmd.getJVMFlags();
    jvmFlags.add(0, javaArgs);

    String profilerClass = DCPLib.getProperty(optitPrefix + "class", "intuitive.audit.Audit");

    if (mOptitAuditPort == null) {
      mOptitAuditPort = getOptimizeItAuditPort(mPropertyPrefix);
    }
    System.out.println("OptimizeIt for " + mName + " is running at " + mOptitAuditPort);
    mLogger.config("OptimizeIt running at " + mOptitAuditPort);

    String optitArgs = DCPLib.getProperty(optitPrefix + "args", "");
    optitArgs = WDUtil.sreplace(optitArgs, "OPTIMIZEIT_HOME", home);
    optitArgs = WDUtil.sreplace(optitArgs, "AUDIT_PORT", mOptitAuditPort);

    String mainClass = serverCmd.getMainClassName();
    List appArgs = serverCmd.getAppArgs();

    serverCmd.setMainClassName(profilerClass);

    appArgs.add(0, mainClass);
    appArgs.add(0, optitArgs);
  }
Exemplo n.º 4
0
 /**
  * This method finds out the next port on which Java debuggere can send its debug output.
  *
  * <p>If "watchdog.server.&lt;SERVER_NAME&gt;.profilers.OptimizeIt.port is specified then, the
  * property value is returned as an int.
  *
  * <p>If not the "watchdog.java.profilers.OptimizeIt.startPort" property is looked up to find out
  * where the port numbers start for all the servers (and incremented by one for each server)
  *
  * <p>If this property is unspecified too, then the default is OPTIMIZEIT_START_PORT.
  */
 private static synchronized String getJDBPort(String serverPropertyPrefix) {
   String rc = DCPLib.getProperty(serverPropertyPrefix + ".java.debug.port", null);
   if (rc != null) return rc;
   return Integer.toString(msJDBPort++);
 }