Package org.apache.ace.processlauncher

Examples of org.apache.ace.processlauncher.LaunchConfiguration


     * @param pid the PID of the process that was launched, cannot be <code>null</code>;
     * @param launcher the terminated process to handle, cannot be <code>null</code>.
     * @throws IOException in case of I/O problems during the respawn of a terminated process.
     */
    private boolean processNeedsToBeRespawned(String pid, ProcessLauncher launcher) throws IOException {
        LaunchConfiguration config = launcher.getLaunchConfiguration();
        Integer exitValue = launcher.getExitValue();

        // Is the process non-successfully terminated?
        if (isNonSuccessfullyTerminated(config, exitValue)) {
            // If so, does it need to be respawned?
            if (config.isRespawnAutomatically()) {
                // We need to respawn the process automatically!
                String logLine =
                    String.format("Process %s (%s) terminated with value %d;" + " respawning it as requested...", pid,
                        config.getExecutableName(), exitValue);
                m_logger.log(LogService.LOG_INFO, logLine);

                // Simply relaunch the process again...
                return true;
            }
            else {
                // Don't bother restarting the process...
                String logLine =
                    String.format("Process %s (%s) terminated with value %d.", pid, config.getExecutableName(),
                        exitValue);
                m_logger.log(LogService.LOG_INFO, logLine);
            }
        }
        else {
            // Process ended normally...
            String logLine = String.format("Process %s (%s) terminated normally.", pid, config.getExecutableName());
            m_logger.log(LogService.LOG_INFO, logLine);
        }

        return false;
    }
View Full Code Here


     *
     * @param pid the service PID that is to be deleted, never <code>null</code>.
     * @see org.osgi.service.cm.ManagedServiceFactory#deleted(java.lang.String)
     */
    public final void deleted(final String pid) {
        LaunchConfiguration oldLaunchConfig = null;

        synchronized (m_launchConfigurations) {
            oldLaunchConfig = m_launchConfigurations.remove(pid);
        }

View Full Code Here

     * @see org.osgi.service.cm.ManagedServiceFactory#updated(java.lang.String,
     *      java.util.Dictionary)
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public final void updated(final String pid, final Dictionary config) throws ConfigurationException {
        LaunchConfiguration oldLaunchConfig = null;
        LaunchConfiguration newLaunchConfig = null;

        if (config != null) {
            newLaunchConfig = createLaunchConfiguration(config);
        }

View Full Code Here

        // This test will not work on Windows!
        if (getOSName().contains("windows")) {
            return;
        }

        LaunchConfiguration launchConfig = createLaunchConfiguration("/bin/sh", "-c", "sleep 1 && exit 1");

        int processCountBefore = m_processManager.getRunningProcessesCount();

        m_processManager.launch("myPid", launchConfig);
View Full Code Here

        // This test will only work on Windows!
        if (!getOSName().contains("windows")) {
            return;
        }

        LaunchConfiguration launchConfig = createLaunchConfiguration("PING", "-n", "2", "127.0.0.1");

        int processCountBefore = m_processManager.getRunningProcessesCount();

        m_processManager.launch("myPid", launchConfig);
View Full Code Here

        // functionality works, as this currently checks for certain exit
        // values...
        String script =
            String.format("L=$(cat %1$s | wc -l)" + "&& echo $L >> %1$s && exit $((%2$d-$L))", tmpFilename, count);

        LaunchConfiguration launchConfig =
            createLaunchConfiguration(true /* respawnAutomatically */, "/bin/bash", "-c", script);

        int processCountBefore = m_processManager.getRunningProcessesCount();

        m_processManager.launch("myPid", launchConfig);
View Full Code Here

        // This test will not work on Windows!
        if (getOSName().contains("windows")) {
            return;
        }

        LaunchConfiguration launchConfig = createLaunchConfiguration("/bin/sh", "-c", "sleep 10");

        int processCountBefore = m_processManager.getRunningProcessesCount();

        for (int i = 0; i < 5; i++) {
            m_processManager.launch(String.format("myPid%d", i), launchConfig);
View Full Code Here

        // This test will only work on Windows!
        if (!getOSName().contains("windows")) {
            return;
        }

        LaunchConfiguration launchConfig = createLaunchConfiguration("PING", "-n", "11", "127.0.0.1");

        int processCountBefore = m_processManager.getRunningProcessesCount();

        for (int i = 0; i < 5; i++) {
            m_processManager.launch(String.format("myPid%d", i), launchConfig);
View Full Code Here

        // This test will not work on Windows!
        if (getOSName().contains("windows")) {
            return;
        }

        LaunchConfiguration launchConfig = createLaunchConfiguration("/bin/sh", "-c", "sleep 10");

        int processCountBefore = m_processManager.getRunningProcessesCount();

        final String pid = "myPid";
        m_processManager.launch(pid, launchConfig);
View Full Code Here

        // This test will not work on Windows!
        if (!getOSName().contains("windows")) {
            return;
        }

        LaunchConfiguration launchConfig = createLaunchConfiguration("PING", "-n", "11", "127.0.0.1");

        int processCountBefore = m_processManager.getRunningProcessesCount();

        final String pid = "myPid";
        m_processManager.launch(pid, launchConfig);
View Full Code Here

TOP

Related Classes of org.apache.ace.processlauncher.LaunchConfiguration

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.