Package org.rhq.core.system

Examples of org.rhq.core.system.ProcessExecutionResults


            if (log.isDebugEnabled()) {
                log.debug(processExecution);
            }

            ProcessExecutionResults processExecutionResults = systemInfo.executeProcess(processExecution);
            if (processExecutionResults.getError() != null) {
                throw new Exception(processExecutionResults.getError());
            }

            Integer exitCode = processExecutionResults.getExitCode();
            String output = processExecutionResults.getCapturedOutput(); // NOTE: this is stdout + stderr

            Configuration complexResults = operationResult.getComplexResults();
            complexResults.put(new PropertySimple(EXIT_CODE_RESULT_PROP, exitCode));
            complexResults.put(new PropertySimple(OUTPUT_RESULT_PROP, output));
            if (exitCode != null && exitCode != 0) {
View Full Code Here


    public void init(ResourceContext resourceContext) {
        this.resourceContext = resourceContext;
        ProcessExecution processExecution = new ProcessExecution("/usr/bin/which");
        processExecution.setArguments(new String[] { "yum" });
        processExecution.setCaptureOutput(true);
        ProcessExecutionResults executionResults = resourceContext.getSystemInformation().executeProcess(
            processExecution);
        String capturedOutput = executionResults.getCapturedOutput();
        yum = (((capturedOutput == null) || "".equals(capturedOutput)) ? null : capturedOutput.trim());
        log.info("Using (yum) found at: " + yum);
    }
View Full Code Here

        ProcessExecution installPackages = new ProcessExecution(yum);
        installPackages.setArguments(args);
        installPackages.setCaptureOutput(true);
        installPackages.setWaitForCompletion(1000L * 60 * 30); // wait for it to finish in 30mins
        ProcessExecutionResults result = this.resourceContext.getSystemInformation().executeProcess(installPackages);
        String output = result.getCapturedOutput();
        Integer exitCode = result.getExitCode();
        log.info("yum result: " + exitCode + "\n" + output);
        if ((output == null) && ((exitCode == null) || (result.getExitCode() != 0))) {
            throw new Exception(output);
        }

        return output;
    }
View Full Code Here

        default:
            availCheck = false;
        }

        ProcessExecutionResults processExecutionResults = this.systemInfo.executeProcess(processExecution);
        Integer exitCode = processExecutionResults.getExitCode();

        // If this operation could have affected availability, ask for a check
        if (availCheck) {
            this.serverComponent.getResourceContext().getAvailabilityContext().requestAvailabilityCheck();
        }

        // Do some more aggressive result code checking, as otherwise errors are not reported as such
        // in the GUI -- see RHQ-627
        // We might want to investigate this again later.
        if (processExecutionResults.getError() != null || (exitCode != null && exitCode != 0)) {
            String msg =
                "Operation " + operation + " failed. Exit code: [" + exitCode + "]\n, Output : ["
                    + processExecutionResults.getCapturedOutput() + "]\n" + "Error: ["
                    + processExecutionResults.getError() + "]";
            throw new Exception(msg);
        }

        return createOperationResult(processExecutionResults);
    }
View Full Code Here

            ProcessExecution processExecution = new ProcessExecution(binaryPath);
            processExecution.setArguments(new String[] { "-V" });
            processExecution.setWaitForCompletion(10000L);
            processExecution.setCaptureOutput(true);
            ProcessExecutionResults results = systemInfo.executeProcess(processExecution);

            if (results.getError() != null) {
                throw results.getError();
            }

            String line;
            is = new BufferedReader(new StringReader(results.getCapturedOutput()));

            while ((line = is.readLine()) != null) {
                line = line.trim();
                if (line.startsWith(SERVER_BUILT)) {
                    line = line.substring(SERVER_BUILT.length()).trim();
View Full Code Here

            ProcessExecution processExecution = new ProcessExecution(binaryPath);
            processExecution.setArguments(new String[] { "-l" });
            processExecution.setWaitForCompletion(10000L);
            processExecution.setCaptureOutput(true);
            ProcessExecutionResults results = systemInfo.executeProcess(processExecution);

            if (results.getError() != null) {
                throw results.getError();
            }

            String line;
            is = new BufferedReader(new StringReader(results.getCapturedOutput()));
            boolean firstLine = true;
            while ((line = is.readLine()) != null) {
                if (firstLine) {
                    firstLine = false;
                    continue;
View Full Code Here

        long start = System.currentTimeMillis();
        if (log.isDebugEnabled()) {
            log.debug("About to execute the following process: [" + processExecution + "]");
        }
        ProcessExecutionResults results = this.systemInfo.executeProcess(processExecution);
        logExecutionResults(results);
        Throwable error = results.getError();
        Integer exitCode = results.getExitCode();
        AvailabilityType avail;

        if (startScriptFailed(controlMethod, error, exitCode, isWindows())) {
            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 + "].";
            if (error == null) {
                log.error(message);
            } else {
                log.error(message, error);
            }
            avail = this.serverComponent.getAvailability();
        } else {
            avail = waitForServerToStart(start);
        }

        // If, after the loop, the Server is still down, consider the start to be a failure.
        if (avail == AvailabilityType.DOWN) {
            throw new RuntimeException("Server failed to start: " + results.getCapturedOutput());
        } else {
            return "Server has been started.";
        }
    }
View Full Code Here

        applyEnvironmentVars(environment, processExecution);

        if (log.isDebugEnabled()) {
            log.debug("About to execute the following process: [" + processExecution + "]");
        }
        ProcessExecutionResults results = this.systemInfo.executeProcess(processExecution);
        logExecutionResults(results);
        Throwable error = results.getError();
        Integer exitCode = results.getExitCode();

        if ((null != error) || ((null != exitCode) && (0 != exitCode))) {
            String message = "Script returned error or non-zero exit code while shutting down the Tomcat instance. Exit code ["
                + exitCode + "]";
            if (null == error) {
View Full Code Here

        long start = System.currentTimeMillis();
        if (log.isDebugEnabled()) {
            log.debug("About to execute the following process: [" + processExecution + "]");
        }
        SystemInfo systemInfo = serverComponent.getResourceContext().getSystemInformation();
        ProcessExecutionResults results = systemInfo.executeProcess(processExecution);
        logExecutionResults(results);

        if (results.getError() == null) {
            avail = waitForServerToStart(start);
        } else {
            log.error(
                "Error from process execution while starting the AS instance. Exit code [" + results.getExitCode()
                    + "]", results.getError());
            avail = this.serverComponent.getAvailability();
        }

        // If, after the loop, the Server is still down, consider the start to be a failure.
        OperationResult result;
        if (avail == AvailabilityType.DOWN) {
            result = new OperationResult();
            result.setErrorMessage("The server failed to start: " + results.getCapturedOutput());
        } else {
            result = new OperationResult("The server has been started.");
        }
        return result;
    }
View Full Code Here

        if (log.isDebugEnabled()) {
            log.debug("About to execute the following process: [" + processExecution + "]");
        }
        SystemInfo systemInfo = serverComponent.getResourceContext().getSystemInformation();
        ProcessExecutionResults results = systemInfo.executeProcess(processExecution);
        logExecutionResults(results);

        if (results.getError() != null || (results.getExitCode() != null && results.getExitCode() != 0)) {
            throw new ExecutionFailedException(
                "Error executing shutdown script while stopping AS instance. Shutdown script returned exit code ["
                    + results.getExitCode() + "]"
                    + (results.getError() != null ? ": " + results.getError().getMessage() : ""), results.getError());
        }

        return "The server has been shut down.";
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.system.ProcessExecutionResults

Copyright © 2018 www.massapicom. 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.