Examples of StartScriptConfiguration


Examples of org.rhq.core.pluginapi.util.StartScriptConfiguration

        connection = new ASConnection(ASConnectionParams.createFrom(serverPluginConfig));
        setASHostName(findASDomainHostName());
        getAvailability();
        logFileEventDelegate = new LogFileEventResourceComponentHelper(context);
        logFileEventDelegate.startLogFileEventPollers();
        startScriptConfig = new StartScriptConfiguration(pluginConfiguration);
    }
View Full Code Here

Examples of org.rhq.core.pluginapi.util.StartScriptConfiguration

        this.pluginConfiguration = pluginConfiguration;
        this.serverMode = serverMode;
        this.systemInfo = systemInfo;
        serverPluginConfig = new ServerPluginConfiguration(pluginConfiguration);

        StartScriptConfiguration startScriptConfiguration = new StartScriptConfiguration(pluginConfiguration);

        startScriptPrefix = startScriptConfiguration.getStartScriptPrefix();

        startScriptEnv = startScriptConfiguration.getStartScriptEnv();
        for (String envVarName : startScriptEnv.keySet()) {
            String envVarValue = startScriptEnv.get(envVarName);
            envVarValue = PropertyReplacer.replacePropertyPatterns(envVarValue, pluginConfiguration);
            startScriptEnv.put(envVarName, envVarValue);
        }
View Full Code Here

Examples of org.rhq.core.pluginapi.util.StartScriptConfiguration

        /**
         * This command ignores the timeout set by the {@link #waitingFor(long)} method. It starts the process and returns
         * immediately. Other means have to be used to determine if the server finished starting up.
         */
        public ProcessExecutionResults startServer() {
            StartScriptConfiguration startScriptConfiguration = new StartScriptConfiguration(pluginConfiguration);
            File startScriptFile = startScriptConfiguration.getStartScript();

            if (startScriptFile == null) {
                startScriptFile = new File("bin", serverMode.getStartScriptFileName());
            }

            List<String> startScriptArgsL = startScriptConfiguration.getStartScriptArgs();
            String[] startScriptArgs = startScriptArgsL.toArray(new String[startScriptArgsL.size()]);

            for (int i = 0; i < startScriptArgs.length; ++i) {
                startScriptArgs[i] = PropertyReplacer.replacePropertyPatterns(startScriptArgs[i], pluginConfiguration);
            }
View Full Code Here

Examples of org.rhq.core.pluginapi.util.StartScriptConfiguration

        assertEquals(avail, AvailabilityType.DOWN);

        // Before restarting it, add some stuff to the 'startScriptEnv' and 'startScriptArgs' props so we can verify
        // they are used correctly by the Start op.
        Configuration pluginConfig = getServerResource().getPluginConfiguration();
        StartScriptConfiguration startScriptConfig = new StartScriptConfiguration(pluginConfig);

        // Add a var to the start script env.
        Map<String, String> env = startScriptConfig.getStartScriptEnv();
        env.put("FOO", "bar"); // uppercase env var name or Windows will do it for you
        startScriptConfig.setStartScriptEnv(env);

        // Add an arg to the start script args.
        List<String> args = startScriptConfig.getStartScriptArgs();
        args.add("-Dfoo=bar");
        startScriptConfig.setStartScriptArgs(args);

        // Restart the server ResourceComponent so it picks up the changes we just made to the plugin config.
        InventoryManager inventoryManager = this.pluginContainer.getInventoryManager();
        inventoryManager.deactivateResource(getServerResource());
        ResourceContainer serverContainer = inventoryManager.getResourceContainer(getServerResource());
View Full Code Here

Examples of org.rhq.core.pluginapi.util.StartScriptConfiguration

                    int beginIndex = expressionValue.indexOf("${jboss.default.multicast.address");
                    if (beginIndex >= 0) {
                        int endIndex = expressionValue.indexOf('}', beginIndex);
                        if (endIndex >= 0) {
                            String expression = expressionValue.substring(beginIndex + 2, endIndex);
                            StartScriptConfiguration startScriptConfig = getServerComponent()
                                .getStartScriptConfiguration();
                            List<String> startScriptArgs = startScriptConfig.getStartScriptArgs();
                            for (String startScriptArg : startScriptArgs) {
                                if (startScriptArg.startsWith("-Djboss.default.multicast.address=")) {
                                    multicastHost = startScriptArg.substring("-Djboss.default.multicast.address="
                                        .length());
                                    break;
View Full Code Here

Examples of org.rhq.core.pluginapi.util.StartScriptConfiguration

            + installInfo.getVersion(), description, pluginConfig, processInfo);
    }

    private void setStartScriptPluginConfigProps(ProcessInfo process, JavaCommandLine commandLine,
        Configuration pluginConfig) {
        StartScriptConfiguration startScriptConfig = new StartScriptConfiguration(pluginConfig);
        ProcessInfo parentProcess = process.getParentProcess();

        File startScript = ServerStartScriptDiscoveryUtility.getStartScript(parentProcess);
        // if we don't discover the start script then leave it empty and the operation code
        // will determine the OS-specific default when needed.
        if (startScript != null) {
            boolean exists = startScript.exists();

            if (!exists && !startScript.isAbsolute()) {
                File homeDir = new File(
                    pluginConfig.getSimpleValue(ApplicationServerPluginConfigurationProperties.HOME_DIR));
                File startScriptAbsolute = new File(homeDir, startScript.getPath());
                exists = startScriptAbsolute.exists();
            }
            if (!exists) {
                LOG.warn("Discovered startScriptFile ["
                    + startScript
                    + "] but failed to find it on disk. The start script may not be correct. The command line used for discovery is ["
                    + commandLine + "]");

            }
            startScriptConfig.setStartScript(startScript);
        }

        Map<String, String> startScriptEnv = ServerStartScriptDiscoveryUtility.getStartScriptEnv(process,
            parentProcess, START_SCRIPT_ENV_VAR_NAMES);
        startScriptConfig.setStartScriptEnv(startScriptEnv);

        List<String> startScriptArgs = ServerStartScriptDiscoveryUtility.getStartScriptArgs(parentProcess,
            commandLine.getClassArguments(), START_SCRIPT_OPTION_EXCLUDES);
        startScriptConfig.setStartScriptArgs(startScriptArgs);
    }
View Full Code Here

Examples of org.rhq.core.pluginapi.util.StartScriptConfiguration

            OperationResult result = new OperationResult();
            result.setErrorMessage("The server is already started.");
            return result;
        }
        Configuration pluginConfig = serverComponent.getResourceContext().getPluginConfiguration();
        StartScriptConfiguration startScriptConfig = new StartScriptConfiguration(pluginConfig);
        File startScriptFile = getStartScriptPath(startScriptConfig);
        validateScriptFile(startScriptFile, ApplicationServerPluginConfigurationProperties.START_SCRIPT_CONFIG_PROP);

        // The optional command prefix (e.g. sudo or nohup).
        String prefix = pluginConfig
            .getSimpleValue(ApplicationServerPluginConfigurationProperties.SCRIPT_PREFIX_CONFIG_PROP, null);
        if ((prefix != null) && prefix.replaceAll("\\s", "").equals("")) {
            // all whitespace - normalize to null
            prefix = null;
        }

        ProcessExecution processExecution = ProcessExecutionUtility.createProcessExecution(prefix, startScriptFile);
        addProcessExecutionArguments(processExecution, startScriptFile, startScriptConfig, false);

        // processExecution is initialized to the current process' env.  This isn't really right, it's the
        // rhq agent env.  Override this if the startScriptEnv property has been set.
        Map<String, String> startScriptEnv = startScriptConfig.getStartScriptEnv();
        if (!startScriptEnv.isEmpty()) {
            for (String envVarName : startScriptEnv.keySet()) {
                String envVarValue = startScriptEnv.get(envVarName);
                // TODO: If we migrate the AS7 util to a general util then hook it up
                // envVarValue = replacePropertyPatterns(envVarValue);
View Full Code Here

Examples of org.rhq.core.pluginapi.util.StartScriptConfiguration

        assertNull(operationResult.getSimpleResult());
       
        // Before restarting it, add some stuff to the 'startScriptEnv' and 'startScriptArgs' props so we can verify
        // they are used correctly by the Start op.
        pluginConfig = getServerResource().getPluginConfiguration();
        StartScriptConfiguration startScriptConfig = new StartScriptConfiguration(pluginConfig);

        // Add a var to the start script env.
        Map<String, String> env = startScriptConfig.getStartScriptEnv();
        env.put("FOO", "bar"); // uppercase env var name or Windows will do it for you
        startScriptConfig.setStartScriptEnv(env);

        // Add an arg to the start script args.
        List<String> args = startScriptConfig.getStartScriptArgs();
        args.add("-Dfoo=bar");
        startScriptConfig.setStartScriptArgs(args);

        // Restart the server ResourceComponent so it picks up the changes we just made to the plugin config.
        System.out.println("===== Updating Server Resource's plugin configuration: " + pluginConfig.toString(true));
        restartServerResourceComponent();
View Full Code Here

Examples of org.rhq.core.pluginapi.util.StartScriptConfiguration

        return new File(FileUtils.getCanonicalPath(homeDir.getPath()));
    }

    private void setStartScriptPluginConfigProps(ProcessInfo process, AS7CommandLine commandLine,
        Configuration pluginConfig, ProcessInfo agentProcess) {
        StartScriptConfiguration startScriptConfig = new StartScriptConfiguration(pluginConfig);
        ProcessInfo parentProcess = getPotentialStartScriptProcess(process);

        File startScript = ServerStartScriptDiscoveryUtility.getStartScript(parentProcess);
        if (startScript == null) {
            // The parent process is not a script - fallback to the default value (e.g. "bin/standalone.sh").
            String startScriptFileName = getMode().getStartScriptFileName();
            startScript = new File("bin", startScriptFileName);
        }
        if (!startScript.exists()) {
            if (!startScript.isAbsolute()) {
                File homeDir = new File(pluginConfig.getSimpleValue("homeDir"));
                File startScriptAbsolute = new File(homeDir, startScript.getPath());
                if (!startScriptAbsolute.exists()) {
                    LOG.warn("Failed to find start script file for AS7 server with command line [" + commandLine
                        + "] - defaulting 'startScripFile' plugin config prop to [" + startScript + "].");
                }
            }
        }
        startScriptConfig.setStartScript(startScript);

        String startScriptPrefix = ServerStartScriptDiscoveryUtility.getStartScriptPrefix(process, agentProcess);
        startScriptConfig.setStartScriptPrefix(startScriptPrefix);

        Map<String, String> startScriptEnv = ServerStartScriptDiscoveryUtility.getStartScriptEnv(process,
            parentProcess, START_SCRIPT_ENV_VAR_NAMES);
        startScriptConfig.setStartScriptEnv(startScriptEnv);

        List<String> startScriptArgs = ServerStartScriptDiscoveryUtility.getStartScriptArgs(parentProcess,
            commandLine.getAppServerArguments(), START_SCRIPT_OPTION_EXCLUDES);
        startScriptConfig.setStartScriptArgs(startScriptArgs);
    }
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.