Search in sources :

Example 11 with ProcessControllerFactory

use of org.apache.geode.internal.process.ProcessControllerFactory in project geode by apache.

the class LocatorLauncherRemoteIntegrationTest method testIsAttachAPIFound.

@Test
public void testIsAttachAPIFound() throws Exception {
    final ProcessControllerFactory factory = new ProcessControllerFactory();
    assertTrue(factory.isAttachAPIFound());
}
Also used : ProcessControllerFactory(org.apache.geode.internal.process.ProcessControllerFactory) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 12 with ProcessControllerFactory

use of org.apache.geode.internal.process.ProcessControllerFactory in project geode by apache.

the class LocatorLauncher method stopWithWorkingDirectory.

private LocatorState stopWithWorkingDirectory() {
    int parsedPid = 0;
    try {
        final ProcessController controller = new ProcessControllerFactory().createProcessController(this.controllerParameters, new File(getWorkingDirectory()), ProcessType.LOCATOR.getPidFileName(), READ_PID_FILE_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
        parsedPid = controller.getProcessId();
        // NOTE in-process request will go infinite loop unless we do the following
        if (parsedPid == ProcessUtils.identifyPid()) {
            final LocatorLauncher runningLauncher = getInstance();
            if (runningLauncher != null) {
                return runningLauncher.stopInProcess();
            }
        }
        controller.stop();
        return new LocatorState(this, Status.STOPPED);
    } catch (ConnectionFailedException e) {
        // failed to attach to locator JVM
        return createNoResponseState(e, "Failed to connect to locator with process id " + parsedPid);
    } catch (FileNotFoundException e) {
        // could not find pid file
        return createNoResponseState(e, "Failed to find process file " + ProcessType.LOCATOR.getPidFileName() + " in " + getWorkingDirectory());
    } catch (IOException e) {
        // failed to open or read file or dir
        return createNoResponseState(e, "Failed to communicate with locator with process id " + parsedPid);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        return createNoResponseState(e, "Interrupted while trying to communicate with locator with process id " + parsedPid);
    } catch (MBeanInvocationFailedException e) {
        // MBean either doesn't exist or method or attribute don't exist
        return createNoResponseState(e, "Failed to communicate with locator with process id " + parsedPid);
    } catch (PidUnavailableException e) {
        // couldn't determine pid from within locator JVM
        return createNoResponseState(e, "Failed to find usable process id within file " + ProcessType.LOCATOR.getPidFileName() + " in " + getWorkingDirectory());
    } catch (TimeoutException e) {
        return createNoResponseState(e, "Timed out trying to find usable process id within file " + ProcessType.LOCATOR.getPidFileName() + " in " + getWorkingDirectory());
    } catch (UnableToControlProcessException e) {
        return createNoResponseState(e, "Failed to communicate with locator with process id " + parsedPid);
    }
}
Also used : ProcessControllerFactory(org.apache.geode.internal.process.ProcessControllerFactory) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) UnableToControlProcessException(org.apache.geode.internal.process.UnableToControlProcessException) ProcessController(org.apache.geode.internal.process.ProcessController) MBeanInvocationFailedException(org.apache.geode.internal.process.MBeanInvocationFailedException) PidUnavailableException(org.apache.geode.internal.process.PidUnavailableException) File(java.io.File) ConnectionFailedException(org.apache.geode.internal.process.ConnectionFailedException) TimeoutException(java.util.concurrent.TimeoutException)

Example 13 with ProcessControllerFactory

use of org.apache.geode.internal.process.ProcessControllerFactory in project geode by apache.

the class ServerLauncher method statusWithWorkingDirectory.

private ServerState statusWithWorkingDirectory() {
    int parsedPid = 0;
    try {
        final ProcessController controller = new ProcessControllerFactory().createProcessController(this.controllerParameters, new File(getWorkingDirectory()), ProcessType.SERVER.getPidFileName(), READ_PID_FILE_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
        parsedPid = controller.getProcessId();
        // note: in-process request will go infinite loop unless we do the following
        if (parsedPid == identifyPid()) {
            final ServerLauncher runningLauncher = getInstance();
            if (runningLauncher != null) {
                return runningLauncher.statusInProcess();
            }
        }
        final String statusJson = controller.status();
        return ServerState.fromJson(statusJson);
    } catch (ConnectionFailedException e) {
        // failed to attach to server JVM
        return createNoResponseState(e, "Failed to connect to server with process id " + parsedPid);
    } catch (FileNotFoundException e) {
        // could not find pid file
        return createNoResponseState(e, "Failed to find process file " + ProcessType.SERVER.getPidFileName() + " in " + getWorkingDirectory());
    } catch (IOException e) {
        // failed to open or read file or dir
        return createNoResponseState(e, "Failed to communicate with server with process id " + parsedPid);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        return createNoResponseState(e, "Interrupted while trying to communicate with server with process id " + parsedPid);
    } catch (MBeanInvocationFailedException e) {
        // MBean either doesn't exist or method or attribute don't exist
        return createNoResponseState(e, "Failed to communicate with server with process id " + parsedPid);
    } catch (PidUnavailableException e) {
        // couldn't determine pid from within server JVM
        return createNoResponseState(e, "Failed to find usable process id within file " + ProcessType.SERVER.getPidFileName() + " in " + getWorkingDirectory());
    } catch (UnableToControlProcessException e) {
        return createNoResponseState(e, "Failed to communicate with server with process id " + parsedPid);
    } catch (TimeoutException e) {
        return createNoResponseState(e, "Failed to communicate with server with process id " + parsedPid);
    }
}
Also used : ProcessControllerFactory(org.apache.geode.internal.process.ProcessControllerFactory) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) CacheServerLauncher(org.apache.geode.internal.cache.CacheServerLauncher) UnableToControlProcessException(org.apache.geode.internal.process.UnableToControlProcessException) ProcessController(org.apache.geode.internal.process.ProcessController) MBeanInvocationFailedException(org.apache.geode.internal.process.MBeanInvocationFailedException) PidUnavailableException(org.apache.geode.internal.process.PidUnavailableException) File(java.io.File) ConnectionFailedException(org.apache.geode.internal.process.ConnectionFailedException) TimeoutException(java.util.concurrent.TimeoutException)

Example 14 with ProcessControllerFactory

use of org.apache.geode.internal.process.ProcessControllerFactory in project geode by apache.

the class ServerLauncher method statusWithPid.

private ServerState statusWithPid() {
    try {
        final ProcessController controller = new ProcessControllerFactory().createProcessController(this.controllerParameters, getPid());
        controller.checkPidSupport();
        final String statusJson = controller.status();
        return ServerState.fromJson(statusJson);
    }// }
     catch (ConnectionFailedException e) {
        // failed to attach to server JVM
        return createNoResponseState(e, "Failed to connect to server with process id " + getPid());
    } catch (IOException e) {
        // failed to open or read file or dir
        return createNoResponseState(e, "Failed to communicate with server with process id " + getPid());
    }// }
     catch (MBeanInvocationFailedException e) {
        // MBean either doesn't exist or method or attribute don't exist
        return createNoResponseState(e, "Failed to communicate with server with process id " + getPid());
    }// }
     catch (UnableToControlProcessException e) {
        // TODO comment me
        return createNoResponseState(e, "Failed to communicate with server with process id " + getPid());
    } catch (InterruptedException e) {
        // TODO comment me
        return createNoResponseState(e, "Failed to communicate with server with process id " + getPid());
    } catch (TimeoutException e) {
        // TODO comment me
        return createNoResponseState(e, "Failed to communicate with server with process id " + getPid());
    }
}
Also used : ProcessControllerFactory(org.apache.geode.internal.process.ProcessControllerFactory) ProcessController(org.apache.geode.internal.process.ProcessController) MBeanInvocationFailedException(org.apache.geode.internal.process.MBeanInvocationFailedException) IOException(java.io.IOException) ConnectionFailedException(org.apache.geode.internal.process.ConnectionFailedException) UnableToControlProcessException(org.apache.geode.internal.process.UnableToControlProcessException) TimeoutException(java.util.concurrent.TimeoutException)

Example 15 with ProcessControllerFactory

use of org.apache.geode.internal.process.ProcessControllerFactory in project geode by apache.

the class ServerLauncher method stopWithWorkingDirectory.

private ServerState stopWithWorkingDirectory() {
    int parsedPid = 0;
    try {
        final ProcessController controller = new ProcessControllerFactory().createProcessController(this.controllerParameters, new File(getWorkingDirectory()), ProcessType.SERVER.getPidFileName(), READ_PID_FILE_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
        parsedPid = controller.getProcessId();
        // NOTE in-process request will go infinite loop unless we do the following
        if (parsedPid == identifyPid()) {
            final ServerLauncher runningLauncher = getInstance();
            if (runningLauncher != null) {
                return runningLauncher.stopInProcess();
            }
        }
        controller.stop();
        return new ServerState(this, Status.STOPPED);
    } catch (ConnectionFailedException e) {
        // failed to attach to server JVM
        return createNoResponseState(e, "Failed to connect to server with process id " + parsedPid);
    } catch (FileNotFoundException e) {
        // could not find pid file
        return createNoResponseState(e, "Failed to find process file " + ProcessType.SERVER.getPidFileName() + " in " + getWorkingDirectory());
    } catch (IOException e) {
        // failed to open or read file or dir
        return createNoResponseState(e, "Failed to communicate with server with process id " + parsedPid);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        return createNoResponseState(e, "Interrupted while trying to communicate with server with process id " + parsedPid);
    } catch (MBeanInvocationFailedException e) {
        // MBean either doesn't exist or method or attribute don't exist
        return createNoResponseState(e, "Failed to communicate with server with process id " + parsedPid);
    } catch (PidUnavailableException e) {
        // couldn't determine pid from within server JVM
        return createNoResponseState(e, "Failed to find usable process id within file " + ProcessType.SERVER.getPidFileName() + " in " + getWorkingDirectory());
    } catch (TimeoutException e) {
        return createNoResponseState(e, "Timed out trying to find usable process id within file " + ProcessType.SERVER.getPidFileName() + " in " + getWorkingDirectory());
    } catch (UnableToControlProcessException e) {
        return createNoResponseState(e, "Failed to communicate with server with process id " + parsedPid);
    }
}
Also used : ProcessControllerFactory(org.apache.geode.internal.process.ProcessControllerFactory) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) CacheServerLauncher(org.apache.geode.internal.cache.CacheServerLauncher) UnableToControlProcessException(org.apache.geode.internal.process.UnableToControlProcessException) ProcessController(org.apache.geode.internal.process.ProcessController) MBeanInvocationFailedException(org.apache.geode.internal.process.MBeanInvocationFailedException) PidUnavailableException(org.apache.geode.internal.process.PidUnavailableException) File(java.io.File) ConnectionFailedException(org.apache.geode.internal.process.ConnectionFailedException) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

ProcessControllerFactory (org.apache.geode.internal.process.ProcessControllerFactory)16 IOException (java.io.IOException)8 ConnectionFailedException (org.apache.geode.internal.process.ConnectionFailedException)8 MBeanInvocationFailedException (org.apache.geode.internal.process.MBeanInvocationFailedException)8 ProcessController (org.apache.geode.internal.process.ProcessController)8 UnableToControlProcessException (org.apache.geode.internal.process.UnableToControlProcessException)8 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)8 Test (org.junit.Test)8 TimeoutException (java.util.concurrent.TimeoutException)6 File (java.io.File)4 FileNotFoundException (java.io.FileNotFoundException)4 PidUnavailableException (org.apache.geode.internal.process.PidUnavailableException)4 CacheServerLauncher (org.apache.geode.internal.cache.CacheServerLauncher)2 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)2