@Override public File getDirectory() { return new File(ServerLauncher.this.getWorkingDirectory()); }
/** * Gets a File reference with the path to the PID file for the Server. * * @return a File reference to the path of the Server's PID file. */ protected File getServerPidFile() { return new File(getWorkingDirectory(), ProcessType.SERVER.getPidFileName()); }
public ServerState(final ServerLauncher launcher, final Status status) { this(status, launcher.statusMessage, System.currentTimeMillis(), launcher.getId(), identifyPid(), ManagementFactory.getRuntimeMXBean().getUptime(), launcher.getWorkingDirectory(), ManagementFactory.getRuntimeMXBean().getInputArguments(), System.getProperty("java.class.path"), GemFireVersion.getGemFireVersion(), System.getProperty("java.version"), getServerLogFileCanonicalPath(launcher), getServerBindAddressAsString(launcher), getServerPortAsString(launcher), launcher.getMemberName()); }
public ServerState(final ServerLauncher launcher, final Status status, final String errorMessage) { this(status, // status errorMessage, // statusMessage System.currentTimeMillis(), // timestamp getServerLocation(launcher), // serverLocation null, // pid 0L, // uptime launcher.getWorkingDirectory(), // workingDirectory ManagementFactory.getRuntimeMXBean().getInputArguments(), // jvmArguments null, // classpath GemFireVersion.getGemFireVersion(), // gemfireVersion System.getProperty("java.version"), // javaVersion null, // logFile getServerBindAddressAsString(launcher), // host launcher.getServerPortAsString(), // port null);// memberName }
final ProcessController controller = new ProcessControllerFactory().createProcessController(this.controllerParameters, new File(getWorkingDirectory()), ProcessType.SERVER.getPidFileName()); parsedPid = controller.getProcessId(); + ProcessType.SERVER.getPidFileName() + " in " + getWorkingDirectory()); } catch (IOException | MBeanInvocationFailedException | UnableToControlProcessException handled) { + ProcessType.SERVER.getPidFileName() + " in " + getWorkingDirectory()); } catch (TimeoutException handled) { return createNoResponseState(handled, "Timed out trying to find usable process id within file " + ProcessType.SERVER.getPidFileName() + " in " + getWorkingDirectory());
final ProcessController controller = new ProcessControllerFactory().createProcessController(this.controllerParameters, new File(getWorkingDirectory()), ProcessType.SERVER.getPidFileName()); parsedPid = controller.getProcessId(); + ProcessType.SERVER.getPidFileName() + " in " + getWorkingDirectory()); } catch (IOException | MBeanInvocationFailedException | UnableToControlProcessException | TimeoutException handled) { + ProcessType.SERVER.getPidFileName() + " in " + getWorkingDirectory());
process = new ControllableProcess(this.controlHandler, new File(getWorkingDirectory()), ProcessType.SERVER, isForcing()); debug("Running Server on (%1$s) in (%2$s) as (%3$s)...", getId(), getWorkingDirectory(), getMember()); this.running.set(true); throw new RuntimeException( String.format("An IO error occurred while starting a %s in %s on %s: %s", getServiceName(), getWorkingDirectory(), getId(), e.getMessage()), e); } catch (FileAlreadyExistsException e) { throw new RuntimeException( String.format("A PID file already exists and a %s may be running in %s on %s.", getServiceName(), getWorkingDirectory(), getId()), e); } catch (PidUnavailableException e) { throw new RuntimeException( String.format("The process ID could not be determined while starting %s %s in %s: %s", getServiceName(), getId(), getWorkingDirectory(), e.getMessage()), e); } catch (RuntimeException | Error e) { throw new IllegalStateException( String.format("A %s is already running in %s on %s.", getServiceName(), getWorkingDirectory(), getId()));
/** * Invokes the 'status' command and operation to check the status of a GemFire server (a cache * server). */ public ServerState status() { final ServerLauncher launcher = getInstance(); // if this instance is running then return local status if (isStartingOrRunning()) { debug( "Getting status from the ServerLauncher instance that actually launched the GemFire Cache Server.%n"); return new ServerState(this, isRunning() ? Status.ONLINE : Status.STARTING); } else if (isPidInProcess() && launcher != null) { return launcher.statusInProcess(); } else if (getPid() != null) { debug("Getting Server status using process ID (%1$s)%n", getPid()); return statusWithPid(); } // attempt to get status using workingDirectory else if (getWorkingDirectory() != null) { debug("Getting Server status using working directory (%1$s)%n", getWorkingDirectory()); return statusWithWorkingDirectory(); } debug("This ServerLauncher was not the instance used to launch the GemFire Cache Server, and " + "neither PID nor working directory were specified; the Server's state is unknown.%n"); return new ServerState(this, Status.NOT_RESPONDING); }
/** * Invokes the 'stop' command and operation to stop a GemFire server (a cache server). */ public ServerState stop() { final ServerLauncher launcher = getInstance(); // if this instance is running then stop it if (isStoppable()) { return stopInProcess(); } // if in-process but difference instance of ServerLauncher else if (isPidInProcess() && launcher != null) { return launcher.stopInProcess(); } // attempt to stop using pid if provided else if (getPid() != null) { return stopWithPid(); } // attempt to stop using workingDirectory else if (getWorkingDirectory() != null) { return stopWithWorkingDirectory(); } return new ServerState(this, Status.NOT_RESPONDING); }