@Test public void testReadPid() throws IOException { final int expectedPid = 12345; final File pidFile = new File(getClass().getSimpleName().concat("_testReadPid.pid")); pidFile.createNewFile(); pidFile.deleteOnExit(); writePid(pidFile, expectedPid); final int actualPid = getLauncherLifecycleCommands().readPid(pidFile); assertEquals(expectedPid, actualPid); }
@Test public void testReadPidWithNonExistingFile() { assertEquals(LauncherLifecycleCommands.INVALID_PID, getLauncherLifecycleCommands().readPid( new File("/path/to/non_existing/pid.file"))); }
@Test(expected = AssertionError.class) public void testReadPidWithNull() { try { getLauncherLifecycleCommands().readPid(null); } catch (AssertionError expected) { assertEquals("The file from which to read the process ID (pid) cannot be null!", expected.getMessage()); throw expected; } }
protected LocatorState locatorStatus(final File locatorPidFile, final int oldPid, final String memberName) { final int newPid = readPid(locatorPidFile); if (newPid != INVALID_PID && newPid != oldPid) { final LocatorState locatorState = new LocatorLauncher.Builder().setPid(newPid).build().status(); if (ObjectUtils.equals(locatorState.getMemberName(), memberName)) { return locatorState; } } return new LocatorState(new LocatorLauncher.Builder().build(), Status.NOT_RESPONDING); }
protected LocatorState locatorStatus(final File locatorPidFile, final int oldPid, final String memberName) { final int newPid = readPid(locatorPidFile); if (newPid != INVALID_PID && newPid != oldPid) { LocatorState locatorState = new LocatorLauncher.Builder().setPid(newPid).build().status(); if (ObjectUtils.equals(locatorState.getMemberName(), memberName)) { return locatorState; } } return new LocatorState(new LocatorLauncher.Builder().build(), Status.NOT_RESPONDING); }
protected ServerState serverStatus(final File serverPidFile, final int oldPid, final String memberName) { final int newPid = readPid(serverPidFile); if (newPid != INVALID_PID && newPid != oldPid) { final ServerState serverState = new ServerLauncher.Builder().setPid(newPid) .setDisableDefaultServer(true).build().status(); if (ObjectUtils.equals(serverState.getMemberName(), memberName)) { return serverState; } } return new ServerState(new ServerLauncher.Builder().build(), Status.NOT_RESPONDING); }
protected ServerState serverStatus(final File serverPidFile, final int oldPid, final String memberName) { final int newPid = readPid(serverPidFile); if (newPid != INVALID_PID && newPid != oldPid) { ServerState serverState = new ServerLauncher.Builder().setPid(newPid).setDisableDefaultServer(true) .build().status(); if (ObjectUtils.equals(serverState.getMemberName(), memberName)) { return serverState; } } return new ServerState(new ServerLauncher.Builder().build(), Status.NOT_RESPONDING); }
final int oldPid = readPid(serverPidFile);
final int oldPid = readPid(locatorPidFile);
final int oldPid = readPid(locatorPidFile);