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); } }
/** * 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); } }
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; }
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; }
} 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() + ".");
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; }
logExecutionResults(results); Throwable error = results.getError(); Integer exitCode = results.getExitCode();
results.getCapturedOutput(), pids, i - 1, "rolled back"); case ERROR: return fullErrorMessage("Patch rollback failed with error code " + results.getExitCode() + ".", pids, i - 1, "rolled back");
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;
logExecutionResults(results); Throwable error = results.getError(); Integer exitCode = results.getExitCode(); AvailabilityType avail;
} else if (results.getExitCode() != null && results.getExitCode() != 0) { operationResult.setErrorMessage("Start failed with error code " + results.getExitCode() + ":\n" + results.getCapturedOutput()); } else {
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");
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); }
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); }
return result; case ERROR: result.setErrorMessage("Patch application failed with error code " + results.getExitCode() + "."); return result;
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