use of org.apache.geode.distributed.LocatorLauncher.Builder in project geode by apache.
the class LocatorLauncherTest method testSetAndGetBindAddress.
@Test
public void testSetAndGetBindAddress() throws UnknownHostException {
final Builder builder = new Builder();
assertNull(builder.getBindAddress());
assertSame(builder, builder.setBindAddress(null));
assertNull(builder.getBindAddress());
assertSame(builder, builder.setBindAddress(""));
assertNull(builder.getBindAddress());
assertSame(builder, builder.setBindAddress(" "));
assertNull(builder.getBindAddress());
assertSame(builder, builder.setBindAddress(InetAddress.getLocalHost().getCanonicalHostName()));
assertEquals(InetAddress.getLocalHost(), builder.getBindAddress());
}
use of org.apache.geode.distributed.LocatorLauncher.Builder in project geode by apache.
the class LocatorLauncherAssemblyIntegrationTest method testLocatorStopsWhenJmxPortIsNonZero.
/*
* This test addresses GEODE-528
*/
@Test
public void testLocatorStopsWhenJmxPortIsNonZero() throws Throwable {
String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
final int jmxPort = AvailablePortHelper.getRandomAvailableTCPPorts(1)[0];
final Builder builder = new Builder().setMemberName(getUniqueName()).setPort(this.locatorPort).setRedirectOutput(false).setWorkingDirectory(rootFolder).set(LOG_LEVEL, "config").set(ENABLE_CLUSTER_CONFIGURATION, "false").set(JMX_MANAGER, "true").set(JMX_MANAGER_START, "true").set(JMX_MANAGER_PORT, Integer.toString(jmxPort));
performTest(builder);
}
use of org.apache.geode.distributed.LocatorLauncher.Builder in project geode by apache.
the class LocatorLauncherAssemblyIntegrationTest method testLocatorStopsWhenJmxPortIsZero.
/*
* This test addresses GEODE-528
*/
@Test
public void testLocatorStopsWhenJmxPortIsZero() throws Throwable {
String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
final Builder builder = new Builder().setMemberName(getUniqueName()).setPort(this.locatorPort).setRedirectOutput(false).setWorkingDirectory(rootFolder).set(LOG_LEVEL, "config").set(ENABLE_CLUSTER_CONFIGURATION, "false").set(JMX_MANAGER, "true").set(JMX_MANAGER_START, "true").set(JMX_MANAGER_PORT, "0");
performTest(builder);
}
use of org.apache.geode.distributed.LocatorLauncher.Builder in project geode by apache.
the class LauncherLifecycleCommandsDUnitTest method test011StopLocatorUsingMemberName.
@Test
public void test011StopLocatorUsingMemberName() throws IOException {
final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
final int jmxManagerPort = ports[0];
final int locatorPort = ports[1];
String pathname = (getClass().getSimpleName() + "_" + getTestMethodName());
File workingDirectory = temporaryFolder.newFolder(pathname);
try {
assertTrue(workingDirectory.isDirectory() || workingDirectory.mkdir());
CommandStringBuilder command = new CommandStringBuilder(CliStrings.START_LOCATOR);
command.addOption(CliStrings.START_LOCATOR__MEMBER_NAME, pathname);
command.addOption(CliStrings.START_LOCATOR__CONNECT, Boolean.FALSE.toString());
command.addOption(CliStrings.START_LOCATOR__DIR, workingDirectory.getCanonicalPath());
command.addOption(CliStrings.START_LOCATOR__PORT, String.valueOf(locatorPort));
command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, Boolean.FALSE.toString());
command.addOption(CliStrings.START_LOCATOR__FORCE, Boolean.TRUE.toString());
command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0");
command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + jmxManagerPort);
CommandResult result = executeCommand(command.toString());
assertNotNull(result);
assertEquals(Result.Status.OK, result.getStatus());
final LocatorLauncher locatorLauncher = new Builder().setCommand(Command.STOP).setBindAddress(null).setPort(locatorPort).setWorkingDirectory(workingDirectory.getPath()).build();
assertNotNull(locatorLauncher);
LocatorState locatorStatus = locatorLauncher.waitOnStatusResponse(60, 10, TimeUnit.SECONDS);
assertNotNull(locatorStatus);
assertEquals(Status.ONLINE, locatorStatus.getStatus());
result = executeCommand(String.format("%1$s --locator=localhost[%2$d]", CliStrings.CONNECT, locatorPort));
assertNotNull(result);
assertEquals(Result.Status.OK, result.getStatus());
result = executeCommand(String.format("%1$s --name=invalidLocatorMemberName", CliStrings.STOP_LOCATOR));
assertNotNull(result);
assertEquals(Result.Status.ERROR, result.getStatus());
assertEquals(CliStrings.format(CliStrings.STOP_LOCATOR__NO_LOCATOR_FOUND_FOR_MEMBER_ERROR_MESSAGE, "invalidLocatorMemberName"), StringUtils.trim(toString(result)));
locatorStatus = locatorLauncher.status();
assertNotNull(locatorStatus);
assertEquals(Status.ONLINE, locatorStatus.getStatus());
result = executeCommand(String.format("%1$s --name=%2$s", CliStrings.STOP_LOCATOR, pathname));
assertNotNull(result);
assertEquals(Result.Status.OK, result.getStatus());
// TODO figure out what output to assert and validate on now that 'stop locator' uses Gfsh's
// logger
// and standard err/out...
// assertIndexDetailsEquals(CliStrings.format(CliStrings.STOP_LOCATOR__SHUTDOWN_MEMBER_MESSAGE,
// pathname),
// StringUtils.trim(toString(result)));
WaitCriterion waitCriteria = new WaitCriterion() {
@Override
public boolean done() {
final LocatorState locatorStatus = locatorLauncher.status();
return (locatorStatus != null && Status.NOT_RESPONDING.equals(locatorStatus.getStatus()));
}
@Override
public String description() {
return "wait for the Locator to stop; the Locator will no longer respond after it stops";
}
};
waitForCriterion(waitCriteria, 15 * 1000, 5000, true);
locatorStatus = locatorLauncher.status();
assertNotNull(locatorStatus);
assertEquals(Status.NOT_RESPONDING, locatorStatus.getStatus());
} finally {
}
}
use of org.apache.geode.distributed.LocatorLauncher.Builder in project geode by apache.
the class LauncherLifecycleCommandsDUnitTest method test012StopLocatorUsingMemberId.
// @see Trac Bug # 46760
@Test
public void test012StopLocatorUsingMemberId() throws Exception {
final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
final int jmxManagerPort = ports[0];
final int locatorPort = ports[1];
String pathname = (getClass().getSimpleName() + "_" + getTestMethodName());
File workingDirectory = temporaryFolder.newFolder(pathname);
try {
assertTrue(workingDirectory.isDirectory() || workingDirectory.mkdir());
CommandStringBuilder command = new CommandStringBuilder(CliStrings.START_LOCATOR);
command.addOption(CliStrings.START_LOCATOR__MEMBER_NAME, pathname);
command.addOption(CliStrings.START_LOCATOR__CONNECT, Boolean.FALSE.toString());
command.addOption(CliStrings.START_LOCATOR__DIR, workingDirectory.getCanonicalPath());
command.addOption(CliStrings.START_LOCATOR__PORT, String.valueOf(locatorPort));
command.addOption(CliStrings.START_LOCATOR__ENABLE__SHARED__CONFIGURATION, Boolean.FALSE.toString());
command.addOption(CliStrings.START_LOCATOR__FORCE, Boolean.TRUE.toString());
command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "http-service-port=0");
command.addOption(CliStrings.START_LOCATOR__J, "-D" + DistributionConfig.GEMFIRE_PREFIX + "jmx-manager-port=" + jmxManagerPort);
CommandResult result = executeCommand(command.toString());
assertNotNull(result);
assertEquals(Result.Status.OK, result.getStatus());
final LocatorLauncher locatorLauncher = new Builder().setCommand(Command.STOP).setBindAddress(null).setPort(locatorPort).setWorkingDirectory(workingDirectory.getPath()).build();
assertNotNull(locatorLauncher);
LocatorState locatorState = locatorLauncher.waitOnStatusResponse(60, 10, TimeUnit.SECONDS);
assertNotNull(locatorState);
assertEquals(Status.ONLINE, locatorState.getStatus());
result = executeCommand(String.format("%1$s --locator=localhost[%2$d]", CliStrings.CONNECT, locatorPort));
assertNotNull(result);
assertEquals(Result.Status.OK, result.getStatus());
String memberId = getMemberId(jmxManagerPort, pathname);
result = executeCommand(String.format("%1$s --name=%2$s", CliStrings.STOP_LOCATOR, memberId));
assertNotNull(result);
assertEquals(Result.Status.OK, result.getStatus());
// TODO figure out what output to assert and validate on now that 'stop locator' uses Gfsh's
// logger
// and standard err/out...
// assertIndexDetailsEquals(CliStrings.format(CliStrings.STOP_LOCATOR__SHUTDOWN_MEMBER_MESSAGE,
// memberId),
// StringUtils.trim(toString(result)));
WaitCriterion waitCriteria = new WaitCriterion() {
@Override
public boolean done() {
LocatorState locatorState = locatorLauncher.status();
return (locatorState != null && Status.NOT_RESPONDING.equals(locatorState.getStatus()));
}
@Override
public String description() {
return "wait for the Locator to stop; the Locator will no longer respond after it stops";
}
};
waitForCriterion(waitCriteria, 15 * 1000, 5000, true);
locatorState = locatorLauncher.status();
assertNotNull(locatorState);
assertEquals(Status.NOT_RESPONDING, locatorState.getStatus());
} finally {
}
}
Aggregations