/** * 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()); }
/** * Gets a File reference with the path to the PID file for the Locator. * * @return a File reference to the path of the Locator's PID file. */ protected File getLocatorPidFile() { return new File(getWorkingDirectory(), ProcessType.LOCATOR.getPidFileName()); }
/** * 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()); }
/** * Gets a File reference with the path to the PID file for the Locator. * * @return a File reference to the path of the Locator's PID file. */ protected File getLocatorPidFile() { return new File(getWorkingDirectory(), ProcessType.LOCATOR.getPidFileName()); }
public void testStatusWithEmptyPidFile() throws Exception { this.workingDirectory = new File(getUniqueName()); this.workingDirectory.mkdir(); assertTrue(this.workingDirectory.isDirectory() && this.workingDirectory.canWrite()); this.pidFile = new File(this.workingDirectory, ProcessType.SERVER.getPidFileName()); assertTrue(this.pidFile + " already exists", this.pidFile.createNewFile()); //writePid(pidFile, realPid); final ServerLauncher dirLauncher = new ServerLauncher.Builder() .setWorkingDirectory(this.workingDirectory.getCanonicalPath()) .build(); try { dirLauncher.status(); fail("Status should have thrown IllegalArgumentException"); } catch (IllegalArgumentException e) { String expected = "Invalid pid 'null' found in " + this.pidFile.getCanonicalPath(); assertEquals("Message was " + e.getMessage() + " instead of " + expected, expected, e.getMessage()); } } // testStatusWithEmptyPidFile
public void testStatusWithEmptyPidFile() throws Exception { this.workingDirectory = new File(getUniqueName()); this.workingDirectory.mkdir(); assertTrue(this.workingDirectory.isDirectory() && this.workingDirectory.canWrite()); this.pidFile = new File(this.workingDirectory, ProcessType.LOCATOR.getPidFileName()); assertTrue(this.pidFile + " already exists", this.pidFile.createNewFile()); //writePid(pidFile, realPid); final LocatorLauncher dirLauncher = new LocatorLauncher.Builder() .setWorkingDirectory(this.workingDirectory.getCanonicalPath()) .build(); try { dirLauncher.status(); fail("Status should have thrown IllegalArgumentException"); } catch (IllegalArgumentException e) { String expected = "Invalid pid 'null' found in " + this.pidFile.getCanonicalPath(); assertEquals("Message was " + e.getMessage() + " instead of " + expected, expected, e.getMessage()); } } // testStatusWithEmptyPidFile
public void testStatusWithStalePidFile() throws Exception { this.workingDirectory = new File(getUniqueName()); this.workingDirectory.mkdir(); assertTrue(this.workingDirectory.isDirectory() && this.workingDirectory.canWrite()); this.pidFile = new File(this.workingDirectory, ProcessType.SERVER.getPidFileName()); final int pid = 0; assertFalse(ProcessUtils.isProcessAlive(pid)); writePid(this.pidFile, pid); final ServerLauncher dirLauncher = new ServerLauncher.Builder() .setWorkingDirectory(workingDirectory.getCanonicalPath()) .build(); try { dirLauncher.status(); fail("Status should have thrown IllegalArgumentException"); } catch (IllegalArgumentException e) { String expected = "Invalid pid '" + pid + "' found in " + this.pidFile.getCanonicalPath(); assertEquals("Message was " + e.getMessage() + " instead of " + expected, expected, e.getMessage()); } } // testStatusWithStalePidFile
public void testStatusWithStalePidFile() throws Exception { this.workingDirectory = new File(getUniqueName()); this.workingDirectory.mkdir(); assertTrue(this.workingDirectory.isDirectory() && this.workingDirectory.canWrite()); this.pidFile = new File(this.workingDirectory, ProcessType.LOCATOR.getPidFileName()); final int pid = 0; assertFalse(ProcessUtils.isProcessAlive(pid)); writePid(this.pidFile, pid); final LocatorLauncher dirLauncher = new LocatorLauncher.Builder() .setWorkingDirectory(workingDirectory.getCanonicalPath()) .build(); try { dirLauncher.status(); fail("Status should have thrown IllegalArgumentException"); } catch (IllegalArgumentException e) { String expected = "Invalid pid '" + pid + "' found in " + this.pidFile.getCanonicalPath(); assertEquals("Message was " + e.getMessage() + " instead of " + expected, expected, e.getMessage()); } } // testStatusWithStalePidFile
public void testStartLocatorCapturesOutputOnError() throws IOException { final int locatorPort = AvailablePortHelper.getRandomAvailableTCPPort(); final String pathname = (getClass().getSimpleName() + "_" + testName); final File workingDirectory = new File(pathname); workingDirectory.mkdir(); assertTrue(workingDirectory.isDirectory()); final File pidFile = new File(workingDirectory, ProcessType.LOCATOR.getPidFileName()); pidFile.createNewFile(); final int readPid = Host.getHost(0).getVM(3).getPid(); writePid(pidFile, readPid); pidFile.deleteOnExit(); assertTrue(pidFile.isFile()); final CommandResult result = executeCommand(CliStrings.START_LOCATOR + " --name=" + pathname + " --dir=" + pathname + " --port=" + locatorPort + " --J=-Dgemfire.jmx-manager-http-port=0 --J=-Dgemfire.jmx-manager-port=" + AvailablePortHelper.getRandomAvailableTCPPort()); assertNotNull(result); assertEquals(Result.Status.ERROR, result.getStatus()); final String resultString = toString(result); assertTrue(resultString, resultString.contains( "Exception in thread \"main\" java.lang.RuntimeException: A PID file already exists and a Locator may be running in " + IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(workingDirectory))); assertTrue(resultString, resultString.contains( "Caused by: com.gemstone.gemfire.internal.process.FileAlreadyExistsException: Pid file already exists: " + IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(pidFile))); }
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(); return createNoResponseState(e, "Failed to find process file " + ProcessType.LOCATOR.getPidFileName() + " in " + getWorkingDirectory()); return createNoResponseState(e, "Failed to find usable process id within file " + ProcessType.LOCATOR.getPidFileName() + " in " + getWorkingDirectory()); return createNoResponseState(e, "Timed out trying to find usable process id within file " + ProcessType.LOCATOR.getPidFileName() + " in " + getWorkingDirectory());
private LocatorState stopWithWorkingDirectory() { int parsedPid = 0; try { final ProcessController controller = new ProcessControllerFactory().createProcessController(this.controllerParameters, new File(getWorkingDirectory()), ProcessType.LOCATOR.getPidFileName()); parsedPid = controller.getProcessId(); return createNoResponseState(e, "Failed to find process file " + ProcessType.LOCATOR.getPidFileName() + " in " + getWorkingDirectory()); return createNoResponseState(e, "Failed to find usable process id within file " + ProcessType.LOCATOR.getPidFileName() + " in " + getWorkingDirectory());
private LocatorState statusWithWorkingDirectory() { int parsedPid = 0; try { final ProcessController controller = new ProcessControllerFactory().createProcessController(this.controllerParameters, new File(getWorkingDirectory()), ProcessType.LOCATOR.getPidFileName()); parsedPid = controller.getProcessId(); return createNoResponseState(e, "Failed to find process file " + ProcessType.LOCATOR.getPidFileName() + " in " + getWorkingDirectory()); return createNoResponseState(e, "Failed to find usable process id within file " + ProcessType.LOCATOR.getPidFileName() + " in " + getWorkingDirectory());
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(); return createNoResponseState(e, "Failed to find process file " + ProcessType.LOCATOR.getPidFileName() + " in " + getWorkingDirectory()); return createNoResponseState(e, "Failed to find usable process id within file " + ProcessType.LOCATOR.getPidFileName() + " in " + getWorkingDirectory());
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(); return createNoResponseState(e, "Failed to find process file " + ProcessType.SERVER.getPidFileName() + " in " + getWorkingDirectory()); return createNoResponseState(e, "Failed to find usable process id within file " + ProcessType.SERVER.getPidFileName() + " in " + getWorkingDirectory());
private ServerState stopWithWorkingDirectory() { int parsedPid = 0; try { final ProcessController controller = new ProcessControllerFactory().createProcessController(this.controllerParameters, new File(getWorkingDirectory()), ProcessType.SERVER.getPidFileName()); parsedPid = controller.getProcessId(); return createNoResponseState(e, "Failed to find process file " + ProcessType.SERVER.getPidFileName() + " in " + getWorkingDirectory()); return createNoResponseState(e, "Failed to find usable process id within file " + ProcessType.SERVER.getPidFileName() + " in " + getWorkingDirectory());
public ControllableProcess(final ControlNotificationHandler handler, final File workingDir, final ProcessType processType, boolean force) throws FileAlreadyExistsException, IOException, PidUnavailableException { this.workingDir = workingDir; this.pidFile = new File(this.workingDir, processType.getPidFileName());
public ControllableProcess(final ControlNotificationHandler handler, final File workingDir, final ProcessType processType, boolean force) throws FileAlreadyExistsException, IOException, PidUnavailableException { this.workingDir = workingDir; this.pidFile = new File(this.workingDir, processType.getPidFileName());
this.pidFile = new File(ProcessType.SERVER.getPidFileName()); final int realPid = Host.getHost(0).getVM(3).invokeInt(ProcessUtils.class, "identifyPid"); assertFalse(realPid == ProcessUtils.identifyPid());
this.pidFile = new File(builder.getWorkingDirectory(), ProcessType.SERVER.getPidFileName()); assertTrue(this.pidFile.exists()); final int pid = readPid(this.pidFile);
this.pidFile = new File(builder.getWorkingDirectory(), ProcessType.LOCATOR.getPidFileName()); assertTrue(this.pidFile.exists()); final int pid = readPid(this.pidFile);