Search in sources :

Example 6 with PidUnavailableException

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

the class LocatorLauncher method statusWithWorkingDirectory.

private LocatorState statusWithWorkingDirectory() {
    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()) {
            LocatorLauncher runningLauncher = getInstance();
            if (runningLauncher != null) {
                return runningLauncher.status();
            }
        }
        final String statusJson = controller.status();
        return LocatorState.fromJson(statusJson);
    } 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 (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 (UnableToControlProcessException e) {
        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 (TimeoutException 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)

Aggregations

File (java.io.File)6 FileNotFoundException (java.io.FileNotFoundException)6 IOException (java.io.IOException)6 TimeoutException (java.util.concurrent.TimeoutException)6 ConnectionFailedException (org.apache.geode.internal.process.ConnectionFailedException)6 MBeanInvocationFailedException (org.apache.geode.internal.process.MBeanInvocationFailedException)6 PidUnavailableException (org.apache.geode.internal.process.PidUnavailableException)6 UnableToControlProcessException (org.apache.geode.internal.process.UnableToControlProcessException)6 ProcessController (org.apache.geode.internal.process.ProcessController)4 ProcessControllerFactory (org.apache.geode.internal.process.ProcessControllerFactory)4 UnknownHostException (java.net.UnknownHostException)2 MalformedObjectNameException (javax.management.MalformedObjectNameException)2 OptionException (joptsimple.OptionException)2 CacheServerLauncher (org.apache.geode.internal.cache.CacheServerLauncher)2 ControllableProcess (org.apache.geode.internal.process.ControllableProcess)2 FileAlreadyExistsException (org.apache.geode.internal.process.FileAlreadyExistsException)2 StartupStatusListener (org.apache.geode.internal.process.StartupStatusListener)2 AttachAPINotFoundException (org.apache.geode.lang.AttachAPINotFoundException)2 GfJsonException (org.apache.geode.management.internal.cli.json.GfJsonException)2 ConnectException (java.net.ConnectException)1