Examples of ExternalCommand


Examples of org.apache.helix.ExternalCommand

    String methodName = TestHelper.getTestMethodName();
    String testName = className + "_" + methodName;

    System.out.println("START " + testName + " at " + new Date(System.currentTimeMillis()));

    ExternalCommand cmd = ScriptTestHelper.runCommandLineTest("dummy.sh");
    String output = cmd.getStringOutput("UTF8");
    int idx = output.indexOf("this is a dummy test for verify ExternalCommand works");
    Assert.assertNotSame(idx, -1);

    System.out.println("END " + testName + " at " + new Date(System.currentTimeMillis()));
View Full Code Here

Examples of org.apache.helix.ExternalCommand

        timeoutValue = Long.parseLong(timeout);
      } catch (NumberFormatException e) {
        // OK to use 0
      }
    }
    ExternalCommand externalCmd =
        ExternalCommand.executeWithTimeout(new File(workingDir), cmdValue, timeoutValue, args);

    int exitValue = externalCmd.exitValue();

    // debug
    // System.out.println("command: " + cmd + ", exitValue: " + exitValue
    // + " output:\n" + externalCmd.getStringOutput());

    if (_logger.isDebugEnabled()) {
      _logger.debug("command: " + cmd + ", exitValue: " + exitValue + " output:\n"
          + externalCmd.getStringOutput());
    }

    // monitor pid if pidFile exists
    if (pidFile == null) {
      // no pid to monitor
View Full Code Here

Examples of org.apache.helix.ExternalCommand

        timeoutValue = Long.parseLong(timeout);
      } catch (NumberFormatException e) {
        // OK to use 0
      }
    }
    ExternalCommand externalCmd =
        ExternalCommand.executeWithTimeout(new File(workingDir), cmdValue, timeoutValue, args);

    int exitValue = externalCmd.exitValue();

    // debug
    // System.out.println("command: " + cmd + ", exitValue: " + exitValue
    // + " output:\n" + externalCmd.getStringOutput());

    if (_logger.isDebugEnabled()) {
      _logger.debug("command: " + cmd + ", exitValue: " + exitValue + " output:\n"
          + externalCmd.getStringOutput());
    }

    // monitor pid if pidFile exists
    if (pidFile == null) {
      // no pid to monitor
View Full Code Here

Examples of org.apache.helix.ExternalCommand

    String methodName = TestHelper.getTestMethodName();
    String testName = className + "_" + methodName;

    System.out.println("START " + testName + " at " + new Date(System.currentTimeMillis()));

    ExternalCommand cmd = ScriptTestHelper.runCommandLineTest("helix_random_kill_local_startzk.sh");
    String output = cmd.getStringOutput("UTF8");
    int i = getStateTransitionLatency(0, output);
    int j = output.indexOf("ms", i);
    long latency = Long.parseLong(output.substring(i, j));
    System.out.println("startup latency: " + latency);
View Full Code Here

Examples of org.apache.helix.ExternalCommand

    }
  }
 
  public static ProcessStateCode getProcessState(String processId) throws Exception {
    if (OS_NAME.equals("Mac OS X") || OS_NAME.equals("Linux")) {
      ExternalCommand cmd = ExternalCommand.start("ps", processId);
      cmd.waitFor();
     
      // split by new lines
      // should return 2 lines for an existing process, or 1 line for a non-existing process
      String lines[] = cmd.getStringOutput().split("[\\r\\n]+");
      if (lines.length != 2) {
        LOG.info("process: " + processId + " not exist");
        return null;
      }
     
View Full Code Here

Examples of org.apache.helix.ExternalCommand

        timeoutValue = Long.parseLong(timeout);
      } catch (NumberFormatException e) {
        // OK to use 0
      }
    }
    ExternalCommand externalCmd = ExternalCommand.executeWithTimeout(new File(workingDir),
        cmdValue, timeoutValue, args);
   
    // debug
    // System.out.println("command output:\n" + externalCmd.getStringOutput());
   
    int exitValue = externalCmd.exitValue();
    _logger.info("Executed command: " + cmd + ", exitValue: " + exitValue);
   
    // if exit-value != 0, transition fails
    if (exitValue != 0) {
      throw new Exception("fail to execute command: " + cmd + ", exitValue: " + exitValue
          + ", error: " + externalCmd.getStringError());
    }
   
    // monitor pid if pidFile exists
    if (pidFile == null) {
      // no pid to monitor
View Full Code Here

Examples of org.linkedin.util.concurrent.ExternalCommand

   * @throws InterruptedException
   */
  public static File copyToJar(File jarFile, File root, boolean update)
    throws IOException, InterruptedException
  {
    ExternalCommand cmd =
      ExternalCommand.create("jar", "-" + (update ? "u" : "c") "vfM",
                             jarFile.getCanonicalPath(),
                             ".");
    cmd.setWorkingDirectory(root);
    cmd.start();
    cmd.waitFor();

    assertEquals(0, cmd.exitValue());

    jarFile.deleteOnExit();
    return jarFile.getCanonicalFile();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.