Package org.rhq.core.system

Examples of org.rhq.core.system.ProcessExecution


            String msg = "yum executable: not-found";
            log.error(msg);
            throw new Exception(msg);
        }

        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))) {
View Full Code Here


        // Continue with generic operations
        Operation operation = getOperation(name);
        File controlScriptPath = this.serverComponent.getControlScriptPath();
        validateScriptFile(controlScriptPath);
        ProcessExecution processExecution = ProcessExecutionUtility.createProcessExecution(controlScriptPath);
        processExecution.setWaitForCompletion(1000 * 30); // 30 seconds - should be plenty
        processExecution.setCaptureOutput(true); // essential, since we want to include the output in the result

        addDefaultArguments(processExecution);

        //we always add some arguments to the control script thus forcing the passthrough mode.
        //therefore no matter if we use httpd, Apache.exe or apachectl, the -k argument will always
        //be used to specify the operation to invoke.
        if (operation != Operation.CONFIG_TEST) {
            processExecution.getArguments().add("-k");
        }

        // request an avail check after a lifecycle operation
        boolean availCheck = true;

        switch (operation) {
        case START: {
            processExecution.getArguments().add("start");
            break;
        }

        case STOP: {
            processExecution.getArguments().add("stop");
            break;
        }

        case RESTART: {
            abortIfOsIsWindows(name);
            processExecution.getArguments().add("restart");
            break;
        }

        case START_SSL: {
            abortIfOsIsWindows(name);
            processExecution.getArguments().add("startssl");
            break;
        }

        case GRACEFUL_RESTART: {
            processExecution.getArguments().add((osIsWindows()) ? "restart" : "graceful");
            break;
        }

        case CONFIG_TEST: {
            // abortIfOsIsWindows(name);
            processExecution.getArguments().add("-t");
            availCheck = false;
            break;
        }

        default:
View Full Code Here

        BufferedReader is = null;

        try {
            compiledInDefines.clear();

            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();
            }
View Full Code Here

        try {

            compiledInModules.clear();

            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();
            }
View Full Code Here

    private String start(PropertyList environment) throws InterruptedException {
        Configuration pluginConfiguration = this.serverComponent.getPluginConfiguration();
        String controlMethodName = pluginConfiguration.getSimpleValue(
            TomcatServerComponent.PLUGIN_CONFIG_CONTROL_METHOD, ControlMethod.SCRIPT.name());
        ControlMethod controlMethod = ControlMethod.valueOf(controlMethodName);
        ProcessExecution processExecution = (controlMethod == ControlMethod.SCRIPT) ? getScriptStart(pluginConfiguration)
            : getRpmStart(pluginConfiguration);

        applyEnvironmentVars(environment, processExecution);

        long start = System.currentTimeMillis();
View Full Code Here

        validateScriptFile(startScriptFile, TomcatServerComponent.PLUGIN_CONFIG_START_SCRIPT);

        String prefix = pluginConfiguration.getSimple(TomcatServerComponent.PLUGIN_CONFIG_SCRIPT_PREFIX)
            .getStringValue();

        ProcessExecution processExecution;

        // prefix is either null or contains ONLY whitespace characters
        if (prefix == null || prefix.replaceAll("\\s", "").equals("")) {
            processExecution = ProcessExecutionUtility.createProcessExecution(startScriptFile);
        } else {
            // The process execution should be tied to the process represented as the prefix. If there are any other
            // tokens in the prefix, consider them arguments to the prefix process.
            StringTokenizer prefixTokenizer = new StringTokenizer(prefix);
            String processName = prefixTokenizer.nextToken();
            File prefixProcess = new File(processName);

            processExecution = ProcessExecutionUtility.createProcessExecution(prefixProcess);

            while (prefixTokenizer.hasMoreTokens()) {
                String prefixArgument = prefixTokenizer.nextToken();
                processExecution.getArguments().add(prefixArgument);
            }

            // Assemble the AS start script and its prefixes as one argument to the prefix
            String startScriptArgument = startScriptFile.getAbsolutePath();

            processExecution.getArguments().add(startScriptArgument);
        }

        initScriptProcessExecution(processExecution, startScriptFile);

        return processExecution;
View Full Code Here

        return processExecution;
    }

    private ProcessExecution getRpmStart(Configuration pluginConfiguration) {
        ProcessExecution processExecution;
        String rpm = getTomcatServiceNum();

        if (isWindows()) {
            processExecution = new ProcessExecution("net");
            // disable the executable existence check because it is a command on the supplied PATH
            processExecution.setCheckExecutableExists(false);
            processExecution.setArguments(new ArrayList<String>());
            processExecution.getArguments().add("start");
            processExecution.getArguments().add(rpm);
        } else {
            processExecution = new ProcessExecution("service");
            // disable the executable existence check because it is a command on the supplied PATH
            processExecution.setCheckExecutableExists(false);
            processExecution.setArguments(new ArrayList<String>());
            processExecution.getArguments().add(rpm);
            processExecution.getArguments().add("start");
        }

        Map<String, String> envVars = new LinkedHashMap<String, String>(System.getenv());
        processExecution.setEnvironmentVariables(envVars);

        initProcessExecution(processExecution);

        return processExecution;
    }
View Full Code Here

    private String doShutdown(PropertyList environment) {
        Configuration pluginConfiguration = this.serverComponent.getPluginConfiguration();
        // NOTE: In TomcatDiscoveryComponent.java we set TomcatServerComponent.PLUGIN_CONFIG_SHUTDOWN_SCRIPT (amongst others).
        String controlMethod = pluginConfiguration.getSimpleValue(TomcatServerComponent.PLUGIN_CONFIG_CONTROL_METHOD,
            ControlMethod.SCRIPT.name());
        ProcessExecution processExecution = (ControlMethod.SCRIPT.name().equals(controlMethod)) ? getScriptShutdown(pluginConfiguration)
            : getRpmShutdown();

        applyEnvironmentVars(environment, processExecution);

        if (log.isDebugEnabled()) {
View Full Code Here

    private ProcessExecution getScriptShutdown(Configuration pluginConfiguration) {
        File shutdownScriptFile = this.serverComponent.getShutdownScriptPath();
        validateScriptFile(shutdownScriptFile, TomcatServerComponent.PLUGIN_CONFIG_SHUTDOWN_SCRIPT);
        String prefix = pluginConfiguration.getSimple(TomcatServerComponent.PLUGIN_CONFIG_SCRIPT_PREFIX)
            .getStringValue();
        ProcessExecution processExecution = ProcessExecutionUtility.createProcessExecution(prefix, shutdownScriptFile);

        initScriptProcessExecution(processExecution, shutdownScriptFile);

        return processExecution;
    }
View Full Code Here

            rpm = TomcatDiscoveryComponent.EWS_TOMCAT_5;
        return rpm;
    }

    private ProcessExecution getRpmShutdown() {
        ProcessExecution processExecution;
        String rpm = getTomcatServiceNum();

        if (isWindows()) {
            processExecution = new ProcessExecution("net");
            // disable the executable existence check because it is a command on the supplied PATH
            processExecution.setCheckExecutableExists(false);
            processExecution.setArguments(new ArrayList<String>());
            processExecution.getArguments().add("stop");
            processExecution.getArguments().add(rpm);
        } else {
            processExecution = new ProcessExecution("service");
            // disable the executable existence check because it is a command on the supplied PATH
            processExecution.setCheckExecutableExists(false);
            processExecution.setArguments(new ArrayList<String>());
            processExecution.getArguments().add(rpm);
            processExecution.getArguments().add("stop");
        }

        Map<String, String> envVars = new LinkedHashMap<String, String>(System.getenv());
        log.info("Operation Envs: " + envVars);
        processExecution.setEnvironmentVariables(envVars);

        initProcessExecution(processExecution);

        return processExecution;
    }
View Full Code Here

TOP

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

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.