Codota Logo
ProcessExecutionResults
Code IndexAdd Codota to your IDE (free)

How to use
ProcessExecutionResults
in
org.rhq.core.system

Best Java code snippets using org.rhq.core.system.ProcessExecutionResults (Showing top 20 results out of 315)

  • Common ways to obtain ProcessExecutionResults
private void myMethod () {
ProcessExecutionResults p =
  • Codota IconSystemInfo systemInfo;ProcessExecution processExecution;systemInfo.executeProcess(processExecution)
  • Smart code suggestions by Codota
}
origin: org.rhq/rhq-jboss-as-7-plugin

private ExecutionResult handleExecutionResults(ProcessExecutionResults results, BundleManagerProvider bmp,
  BundleResourceDeployment resourceDeployment, boolean doAudit) {
  ExecutionResult ret = ExecutionResult.OK;
  if (results.getError() != null) {
    ret = ExecutionResult.EXECUTION_ERROR;
  } else if (results.getExitCode() == null) {
    ret = ExecutionResult.TIMEOUT;
  } else if (results.getExitCode() != 0) {
    ret = ExecutionResult.ERROR;
  }
  if (doAudit) {
    audit(bmp, resourceDeployment, "Output", ret == ExecutionResult.OK ? "Standard" : "Error", ret.status(),
      results.getCapturedOutput());
  }
  return ret;
}
origin: org.rhq/rhq-cassandra-ccm-core

public void startCluster(List<Integer> nodeIds) {
  if (log.isDebugEnabled()) {
    log.debug("Starting embedded cluster for nodes " + collectionToString(nodeIds));
  } else {
    log.info("Starting embedded cluster");
  }
  long start = System.currentTimeMillis();
  File basedir = new File(deploymentOptions.getClusterDir());
  for (Integer nodeId : nodeIds) {
    File nodeDir = new File(basedir, "node" + nodeId);
    ProcessExecutionResults results = startNode(nodeDir);
    if (results.getError() != null) {
      log.warn("An unexpected error occurred while starting the node at " + nodeDir, results.getError());
    } else {
      nodeProcessMap.put(nodeId, results.getProcess());
    }
  }
  long end = System.currentTimeMillis();
  log.info("Started embedded cluster in " + (end - start) + " ms");
}
origin: org.rhq/rhq-jboss-as-7-plugin

  /**
   * Logs the result of a process execution.
   *
   * @param results the result of a process execution
   */
  public static void logExecutionResults(ProcessExecutionResults results) {
    // Always log the output at info level. On Unix we could switch depending on a exitCode being !=0, but ...
    LOG.info("Exit code from process execution: " + results.getExitCode());
    LOG.info("Output from process execution: " + SEPARATOR + results.getCapturedOutput() + SEPARATOR);
  }
}
origin: org.jboss.on/jopr-tomcat-plugin

Throwable error = results.getError();
Integer exitCode = results.getExitCode();
origin: org.rhq/rhq-core-native-system

/**
 * Spawns a new process using the Java Runtime API.
 *
 * @see SystemInfo#executeProcess(ProcessExecution)
 */
public ProcessExecutionResults executeProcess(ProcessExecution processExecution) {
  ProcessToStart process = new ProcessToStart();
  ProcessExecutionResults executionResults = new ProcessExecutionResults();
  process.setProgramExecutable(processExecution.getExecutable());
  process.setCheckExecutableExists(processExecution.isCheckExecutableExists());
  process.setArguments(processExecution.getArgumentsAsArray());
  process.setEnvironment(processExecution.getEnvironmentVariablesAsArray());
  process.setWorkingDirectory(processExecution.getWorkingDirectory());
  process.setWaitForExit(Long.valueOf(processExecution.getWaitForCompletion()));
  process.setCaptureOutput(Boolean.valueOf(processExecution.isCaptureOutput()));
  process.setKillOnTimeout(Boolean.valueOf(processExecution.isKillOnTimeout()));
  if (processExecution.isCaptureOutput()) {
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    process.setOutputStream(outputStream);
    executionResults.setCapturedOutputStream(outputStream);
  }
  ProcessExecutorResults javaExecResults = javaExec.execute(process);
  executionResults.setExitCode(javaExecResults.getExitCode());
  executionResults.setError(javaExecResults.getError());
  executionResults.setProcess(javaExecResults.getProcess());
  return executionResults;
}
origin: org.rhq/rhq-cassandra-ccm-core

private ProcessExecutionResults startNode(File basedir) {
  if (log.isDebugEnabled()) {
    log.debug("Starting node at " + basedir);
  }
  File binDir = new File(basedir, "bin");
  File startScript;
  SystemInfo systemInfo = SystemInfoFactory.createSystemInfo();
  ProcessExecution startScriptExe;
  if (systemInfo.getOperatingSystemType() == OperatingSystemType.WINDOWS) {
    startScript = new File(binDir, "cassandra.bat");
    startScriptExe = createProcessExecution(null, startScript);
  } else {
    startScript = new File(binDir, "cassandra");
    startScriptExe = createProcessExecution(null, startScript);
    startScriptExe.addArguments(Arrays.asList("-p", "cassandra.pid"));
  }
  startScriptExe.setWaitForCompletion(0);
  ProcessExecutionResults results = systemInfo.executeProcess(startScriptExe);
  if (log.isDebugEnabled()) {
    log.debug(startScript + " returned with exit code [" + results.getExitCode() + "]");
  }
  return results;
}
origin: org.jboss.on/jopr-tomcat-plugin

String versionOutput = results.getCapturedOutput();
origin: org.rhq/rhq-jboss-as-7-plugin

Throwable error = results.getError();
if (error != null) {
  return BundleHandoverResponse.failure(EXECUTION, error.getMessage(), error);
Integer exitCode = results.getExitCode();
if (exitCode == null) {
  return BundleHandoverResponse.failure(EXECUTION, "Timeout waiting for completion of the CLI process");
origin: org.jboss.on/jopr-tomcat-plugin

private void logExecutionResults(ProcessExecutionResults results) {
  if (log.isDebugEnabled()) {
    log.debug("Exit code from process execution: " + results.getExitCode());
    log.debug("Output from process execution: " + SEPARATOR + results.getCapturedOutput() + SEPARATOR);
  }
}
origin: rhq-project/rhq

/**
 * Spawns a new process using the Java Runtime API.
 *
 * @see SystemInfo#executeProcess(ProcessExecution)
 */
public ProcessExecutionResults executeProcess(ProcessExecution processExecution) {
  ProcessToStart process = new ProcessToStart();
  ProcessExecutionResults executionResults = new ProcessExecutionResults();
  process.setProgramExecutable(processExecution.getExecutable());
  process.setCheckExecutableExists(processExecution.isCheckExecutableExists());
  process.setArguments(processExecution.getArgumentsAsArray());
  process.setEnvironment(processExecution.getEnvironmentVariablesAsArray());
  process.setWorkingDirectory(processExecution.getWorkingDirectory());
  process.setWaitForExit(Long.valueOf(processExecution.getWaitForCompletion()));
  process.setCaptureOutput(Boolean.valueOf(processExecution.getCaptureMode().isCapture()));
  process.setKillOnTimeout(Boolean.valueOf(processExecution.isKillOnTimeout()));
  ProcessExecutionOutputStream outputStream = processExecution.getCaptureMode().createOutputStream();
  process.setOutputStream(outputStream);
  executionResults.setCapturedOutputStream(outputStream);
  ProcessExecutorResults javaExecResults = javaExec.execute(process);
  executionResults.setExitCode(javaExecResults.getExitCode());
  executionResults.setError(javaExecResults.getError());
  executionResults.setProcess(javaExecResults.getProcess());
  return executionResults;
}
origin: org.rhq/rhq-jboss-as-7-plugin

private Result<String> getPatchHistoryJSON(ServerControl control, String operation) {
  ProcessExecutionResults results = control.cli().disconnected(true).executeCliCommand("patch history");
  switch (handleExecutionResults(results, null, null, false)) {
  case EXECUTION_ERROR:
    return new Result<String>(null,
      "Failed to determine the patch history while doing a " + operation + ": " +
        results.getError().getMessage());
  case TIMEOUT:
    return new Result<String>(null,
      "Timed out while determining patch history for a " + operation + ". Output was: " +
        results.getCapturedOutput());
  case ERROR:
    return new Result<String>(null,
      "Failed to determine the patch history for a " + operation + ". Returned error code was: " +
        results.getExitCode() + "\nOutput was: " + results.getCapturedOutput());
  }
  return new Result<String>(results.getCapturedOutput(), null);
}
origin: org.rhq/rhq-jboss-as-7-plugin

private String startServer(ASConnection connection, ServerControl control, BundleManagerProvider bmp, BundleResourceDeployment resourceDeployment) {
  audit(bmp, resourceDeployment, "Start", "Start", null, "Starting the server back up.");
  ProcessExecutionResults results = control.lifecycle().startServer();
  switch (handleExecutionResults(results, bmp, resourceDeployment, false)) {
  case EXECUTION_ERROR:
    return "Error trying to start the server. " + results.getError().getMessage();
  case ERROR:
    return "Starting the server failed with error code " + results.getExitCode() + " and output: " +
      results.getCapturedOutput();
  // ignore timeout, because starting the server actually would always be detected as doing it, because the start
  // script never stops...
  }
  try {
    waitForServerToStart(connection);
  } catch (InterruptedException e) {
    String message = "Interrupted while waiting for the server to start up after applying the patch";
    Thread.currentThread().interrupt();
    return message;
  }
  return null;
}
origin: org.rhq/rhq-jboss-as-7-plugin

private Result<Boolean> stopIfNeeded(ASConnection connection, ServerControl control,
  Configuration bundleDeploymentConfiguration, BundleManagerProvider bmp, BundleResourceDeployment resourceDeployment) {
  boolean doRestart = Boolean.valueOf(bundleDeploymentConfiguration.getSimpleValue("restart", "true"));
  if (doRestart && isServerUp(connection)) {
    audit(bmp, resourceDeployment, "Stop", "Stop", null,
      "The server is running. Stopping it before any operation on patches.");
    ProcessExecutionResults results = control.lifecycle().shutdownServer();
    switch (handleExecutionResults(results, bmp, resourceDeployment, true)) {
    case EXECUTION_ERROR:
      return new Result<Boolean>(false, "Error trying to shutdown the server: " + results.getError().getMessage());
    case TIMEOUT:
      return new Result<Boolean>(false, "Stopping the server timed out. Captured output: " +
        results.getCapturedOutput());
    case ERROR:
      return new Result<Boolean>(false, "Stopping the server failed with error code " + results.getExitCode() +
        " and output: " + results.getCapturedOutput());
    }
    return new Result<Boolean>(true, null);
  }
  return new Result<Boolean>(false, null);
}
origin: org.rhq/rhq-jboss-as-7-plugin

  .cli().disconnected(true).executeCliCommand("patch info");
if (results.getError() != null) {
  LOG.info("Failed to determine the list of installed patches on " + context.getResourceDetails() +
    ". The execution of JBoss CLI failed.", results.getError());
} else if (results.getExitCode() == null) {
  LOG.info("Failed to determine the list of installed patches on " + context.getResourceDetails() +
    ". The execution of JBoss CLI timed out.");
} else if (results.getExitCode() != 0) {
  LOG.info("Failed to determine the list of installed patches on " + context.getResourceDetails() +
    ". The execution of JBoss CLI exited with code " + results.getExitCode() + ".");
  String json = results.getCapturedOutput();
origin: org.jboss.on/jopr-tomcat-plugin

Throwable error = results.getError();
Integer exitCode = results.getExitCode();
AvailabilityType avail;
  String output = results.getCapturedOutput();
  String message = "Script returned error or non-zero exit code while starting the Tomcat instance - exitCode=["
    + ((exitCode != null) ? exitCode : "UNKNOWN") + "], output=[" + output + "].";
  throw new RuntimeException("Server failed to start: " + results.getCapturedOutput());
} else {
  return "Server has been started.";
origin: org.rhq/rhq-jboss-as-7-plugin

logExecutionResults(results);
if (results.getError() != null) {
  operationResult.setErrorMessage(results.getError().getMessage());
} else if (results.getExitCode() != null && results.getExitCode() != 0) {
  operationResult.setErrorMessage("Start failed with error code " + results.getExitCode() + ":\n"
    + results.getCapturedOutput());
} else {
origin: org.rhq/rhq-jboss-as-7-plugin

case EXECUTION_ERROR:
  return fullErrorMessage("Error trying to run patch rollback: " +
    results.getError().getMessage(), pids, i - 1, "rolled back");
case TIMEOUT:
  return fullErrorMessage("Patch rollback timed out. Captured output: " +
    results.getCapturedOutput(), pids, i - 1, "rolled back");
case ERROR:
  return fullErrorMessage("Patch rollback failed with error code " + results.getExitCode()
    + ".", pids, i - 1, "rolled back");
origin: org.rhq/rhq-jboss-as-7-plugin

result.setSimpleResult(results.getCapturedOutput());
if (results.getError() != null) {
  result.setErrorMessage(results.getError().getMessage());
  return result;
if (results.getExitCode() == null) {
  result.setErrorMessage("jboss-cli execution timed out");
  return result;
if (results.getExitCode() != 0) {
  result.setErrorMessage("jboss-cli execution failed with error code " + results.getExitCode());
  return result;
origin: org.rhq/rhq-jboss-as-7-plugin

  return
    Result.error("Failed to check availability of patch command using the 'help --commands' command. The error was: " +
      results.getError().getMessage());
case ERROR:
  return
    Result.error("Failed to check availability of patch command using the 'help --commands' command. The execution failed with an exit code " +
      results.getExitCode());
case TIMEOUT:
  return
    Result.error("Failed to check availability of patch command using the 'help --commands' command. The execution timed out with the output: " +
      results.getCapturedOutput());
case OK:
  if (results.getCapturedOutput() == null || !(results.getCapturedOutput().contains(" patch ") || results.getCapturedOutput().contains("\npatch"))) {
    return Result.error("The underlying server does not support the patch command. Cannot perform the patch operation.");
origin: org.rhq/rhq-jboss-as-7-plugin

case EXECUTION_ERROR:
  result
    .setErrorMessage("Error while trying to execute patch command: " + results.getError().getMessage());
  return result;
case TIMEOUT:
  result.setErrorMessage("Patch application timed out. Output was: " + results.getCapturedOutput());
  return result;
case ERROR:
  result.setErrorMessage("Patch application failed with error code " + results.getExitCode() + ".");
  return result;
org.rhq.core.systemProcessExecutionResults

Javadoc

Encapsulates the results of a process that was executed via SystemInfo#executeProcess(ProcessExecution).

Most used methods

  • getError
    An error that occurred, typically due to a startup failure.
  • getExitCode
    If the process finished, this is its exit code. Its numeric value has specific meaning that is custo
  • getCapturedOutput
    Returns the full output of the process (stdout plus stderr) as a String. This returnsnull if the pro
  • <init>
  • getProcess
  • setCapturedOutputStream
  • setError
  • setExitCode
  • setProcess

Popular in Java

  • Making http requests using okhttp
  • compareTo (BigDecimal)
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • onRequestPermissionsResult (Fragment)
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • LogFactory (org.apache.commons.logging)
    A minimal incarnation of Apache Commons Logging's LogFactory API, providing just the common Log look
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now