You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kh...@apache.org on 2017/08/29 17:39:29 UTC
[1/2] geode git commit: GEODE-3277: revert changes to Launcher bind
address and State constructors
Repository: geode
Updated Branches:
refs/heads/develop 4c5593813 -> 4ac5e65f7
http://git-wip-us.apache.org/repos/asf/geode/blob/4ac5e65f/geode-core/src/test/java/org/apache/geode/distributed/LauncherIntegrationTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/LauncherIntegrationTestCase.java b/geode-core/src/test/java/org/apache/geode/distributed/LauncherIntegrationTestCase.java
index e2d40ec..409a96d 100755
--- a/geode-core/src/test/java/org/apache/geode/distributed/LauncherIntegrationTestCase.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/LauncherIntegrationTestCase.java
@@ -30,9 +30,7 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.lang.management.ManagementFactory;
-import java.net.InetAddress;
import java.net.ServerSocket;
-import java.net.UnknownHostException;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -284,17 +282,9 @@ public abstract class LauncherIntegrationTestCase {
private void givenPortInUse(final int port) {
try {
- givenPortInUse(port, InetAddress.getLocalHost());
- } catch (UnknownHostException e) {
- throw new UncheckedIOException(e);
- }
- }
-
- private void givenPortInUse(final int port, InetAddress bindAddress) {
- try {
socket = SocketCreatorFactory
.createNonDefaultInstance(false, false, null, null, System.getProperties())
- .createServerSocket(port, 50, bindAddress, -1);
+ .createServerSocket(port, 50, null, -1);
assertThat(socket.isBound()).isTrue();
assertThat(socket.isClosed()).isFalse();
assertThat(isPortAvailable(port, SOCKET)).isFalse();
http://git-wip-us.apache.org/repos/asf/geode/blob/4ac5e65f/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java
index 085e4da..cc42a53 100755
--- a/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java
@@ -185,8 +185,8 @@ public class LocatorLauncherRemoteIntegrationTest extends LocatorLauncherRemoteI
assertThat(locatorState.getStatus()).isEqualTo(NOT_RESPONDING);
assertThat(locatorState.getClasspath()).isNull();
assertThat(locatorState.getGemFireVersion()).isEqualTo(GemFireVersion.getGemFireVersion());
- assertThat(locatorState.getHost()).isEqualTo(InetAddress.getLocalHost().getCanonicalHostName());
- assertThat(locatorState.getJavaVersion()).isEqualTo(System.getProperty("java.version"));
+ assertThat(locatorState.getHost()).isNull();
+ assertThat(locatorState.getJavaVersion()).isNull();
assertThat(locatorState.getLogFile()).isNull();
assertThat(locatorState.getMemberName()).isNull();
assertThat(locatorState.getPid()).isNull();
http://git-wip-us.apache.org/repos/asf/geode/blob/4ac5e65f/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTest.java
index 025ad5d..733a108 100755
--- a/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTest.java
@@ -244,9 +244,9 @@ public class ServerLauncherRemoteIntegrationTest extends ServerLauncherRemoteInt
assertThat(serverState.getWorkingDirectory()).isEqualTo(getWorkingDirectoryPath());
assertThat(serverState.getClasspath()).isNull();
assertThat(serverState.getGemFireVersion()).isEqualTo(GemFireVersion.getGemFireVersion());
- assertThat(serverState.getJavaVersion()).isEqualTo(System.getProperty("java.version"));
+ assertThat(serverState.getJavaVersion()).isNull();
assertThat(serverState.getLogFile()).isNull();
- assertThat(serverState.getHost()).isEqualTo(InetAddress.getLocalHost().getCanonicalHostName());
+ assertThat(serverState.getHost()).isNull();
assertThat(serverState.getMemberName()).isNull();
}
http://git-wip-us.apache.org/repos/asf/geode/blob/4ac5e65f/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherTest.java b/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherTest.java
index 61d0596..2bcd994 100755
--- a/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherTest.java
@@ -18,6 +18,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
@@ -270,7 +271,7 @@ public class ServerLauncherTest {
launcher.startCacheServer(cache);
- verify(cacheServer, times(1)).setBindAddress(anyString());
+ verify(cacheServer, times(1)).setBindAddress(isNull());
verify(cacheServer, times(1)).setPort(eq(11235));
verify(cacheServer, times(1)).start();
}
http://git-wip-us.apache.org/repos/asf/geode/blob/4ac5e65f/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/lifecycle/GfshStatusCommandsIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/lifecycle/GfshStatusCommandsIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/lifecycle/GfshStatusCommandsIntegrationTest.java
index 8537777..dd5841f 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/lifecycle/GfshStatusCommandsIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/lifecycle/GfshStatusCommandsIntegrationTest.java
@@ -19,13 +19,13 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.io.File;
import org.junit.Before;
+import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.rules.TemporaryFolder;
import org.junit.rules.TestName;
-import org.apache.geode.internal.DistributionLocator;
import org.apache.geode.management.internal.cli.result.CommandResult;
import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
import org.apache.geode.test.dunit.rules.LocatorStarterRule;
@@ -33,7 +33,8 @@ import org.apache.geode.test.junit.categories.IntegrationTest;
@Category(IntegrationTest.class)
public class GfshStatusCommandsIntegrationTest {
- private static final String LOCATOR_NAME = "locator1";
+ final private static String LOCATOR_NAME = "locator1";
+ // private int port;
@Rule
public LocatorStarterRule locator =
@@ -51,48 +52,37 @@ public class GfshStatusCommandsIntegrationTest {
@Before
public void connect() throws Exception {
+ // port = getRandomAvailablePort(SOCKET);
gfsh.connectAndVerify(locator);
}
@Test
- public void statusLocatorWithBadPort_statusNotResponding() throws Exception {
- String wrongPort = String.valueOf(locator.getLocator().getPort() - 1);
- CommandResult result =
- gfsh.executeCommand("status locator --host=localhost --port=" + wrongPort);
- assertThat(result.getContent().getString("message")).doesNotContain("null");
+ public void statusLocatorWithBadPortReportsNotResponding() throws Exception {
+ CommandResult result = gfsh.executeCommand("status locator --host=localhost --port="
+ + String.valueOf(locator.getLocator().getPort() - 1));
assertThat(result.getContent().getString("message")).contains("not responding");
- assertThat(result.getContent().getString("message")).contains(wrongPort);
}
@Test
- public void statusLocatorDefault_LocatorOnNonDefaultPort_statusNotResponding() throws Exception {
- CommandResult result = gfsh.executeCommand("status locator --host=localhost");
- assertThat(result.getContent().getString("message")).doesNotContain("null");
- assertThat(result.getContent().getString("message")).contains("not responding");
- assertThat(result.getContent().getString("message"))
- .contains(String.valueOf(DistributionLocator.DEFAULT_LOCATOR_PORT));
- }
-
- @Test
- public void statusLocatorWithActivePort_statusOnline() throws Exception {
+ public void statusLocatorWithActivePortReportsOnline() throws Exception {
CommandResult result = gfsh.executeCommand(
"status locator --host=localhost --port=" + String.valueOf(locator.getLocator().getPort()));
assertThat(result.getContent().getString("message")).contains("is currently online");
}
@Test
- public void statusServerNoServer_statusNotResponding() throws Exception {
+ public void statusServerWithWithNoOptions() throws Exception {
+ File serverDir = new File(temporaryFolder.getRoot(), "serverDir");
+ serverDir.mkdirs();
CommandResult result = gfsh.executeCommand("status server");
- assertThat(result.getContent().getString("message")).doesNotContain("null");
assertThat(result.getContent().getString("message")).contains("not responding");
}
@Test
- public void statusServerWithEmptyDir_statusNotResponding() throws Exception {
+ public void statusServerWithInvalidDirReturnsMeangingfulMessage() throws Exception {
File serverDir = new File(temporaryFolder.getRoot(), "serverDir");
serverDir.mkdirs();
CommandResult result = gfsh.executeCommand("status server --dir=" + serverDir.toString());
- assertThat(result.getContent().getString("message")).doesNotContain("null");
assertThat(result.getContent().getString("message")).contains("not responding");
}
}
http://git-wip-us.apache.org/repos/asf/geode/blob/4ac5e65f/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
index dc17d03..e7f17ef 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
@@ -44,12 +44,12 @@ import org.apache.geode.test.junit.rules.DescribedExternalResource;
*
* you can use this as Rule
*
- * @Rule GfshShellConnectionRule rule = new GfshShellConnectionRule(); then after you connect to a
+ * @Rule GfshShellConnectionRule rule = new GfshSheelConnectionRule(); then after you connect to a
* locator, you don't have to call disconnect() or close() at all, since the rule's after
* takes care of it for you.
*
* Or as a ClassRule
- * @ClassRule GfshShellConnectionRule rule = new GfshShellConnectionRule(); When using as a
+ * @ClassRule GfshShellConnectionRule rule = new GfshSheelConnectionRule(); When using as a
* ClassRule, if you call connect in a test, you will need to call disconnect after the
* test as well. See NetstatDUnitTest for example.
*
[2/2] geode git commit: GEODE-3277: revert changes to Launcher bind
address and State constructors
Posted by kh...@apache.org.
GEODE-3277: revert changes to Launcher bind address and State constructors
This reverts commit 73a847a4b22239414db0ae9d973673f6a03fdcf0.
This reverts commit 4a5c56eb8edd277b258e916212d41bec0b0e7b83.
This reverts commit f41ca9d7d2fa7c045ec439df9478335233f1d95e.
Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/4ac5e65f
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/4ac5e65f
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/4ac5e65f
Branch: refs/heads/develop
Commit: 4ac5e65f79ca7383cc7274c65c9a435d124b5d75
Parents: 4c55938
Author: Ken Howe <kh...@pivotal.io>
Authored: Tue Aug 29 10:31:46 2017 -0700
Committer: Ken Howe <kh...@pivotal.io>
Committed: Tue Aug 29 10:38:58 2017 -0700
----------------------------------------------------------------------
.../cli/commands/StatusLocatorRealGfshTest.java | 24 +-
.../geode/distributed/LocatorLauncher.java | 248 ++++++++---------
.../geode/distributed/ServerLauncher.java | 266 ++++++++-----------
.../LauncherIntegrationTestCase.java | 12 +-
.../LocatorLauncherRemoteIntegrationTest.java | 4 +-
.../ServerLauncherRemoteIntegrationTest.java | 4 +-
.../geode/distributed/ServerLauncherTest.java | 3 +-
.../GfshStatusCommandsIntegrationTest.java | 34 +--
.../dunit/rules/GfshShellConnectionRule.java | 4 +-
9 files changed, 251 insertions(+), 348 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/geode/blob/4ac5e65f/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/StatusLocatorRealGfshTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/StatusLocatorRealGfshTest.java b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/StatusLocatorRealGfshTest.java
index 02f49a6..3a98373 100644
--- a/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/StatusLocatorRealGfshTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/StatusLocatorRealGfshTest.java
@@ -14,12 +14,6 @@
*/
package org.apache.geode.management.internal.cli.commands;
-import static org.apache.geode.internal.AvailablePort.SOCKET;
-import static org.apache.geode.internal.AvailablePort.getRandomAvailablePort;
-
-import java.net.InetAddress;
-
-import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -33,26 +27,16 @@ public class StatusLocatorRealGfshTest {
@Rule
public GfshRule gfshRule = new GfshRule();
- private int port;
-
- @Before
- public void setup() {
- port = getRandomAvailablePort(SOCKET);
- }
-
@Test
public void statusLocatorSucceedsWhenConnected() throws Exception {
- GfshScript.of("start locator --name=locator1 --port=" + Integer.valueOf(port))
- .execute(gfshRule);
+ GfshScript.of("start locator --name=locator1").execute(gfshRule);
- GfshScript.of("connect --locator=" + InetAddress.getLocalHost().getHostAddress() + "["
- + Integer.valueOf(port) + "]", "status locator --name=locator1").execute(gfshRule);
+ GfshScript.of("connect", "status locator --name=locator1").execute(gfshRule);
}
@Test
- public void statusLocatorByNameFailsWhenNotConnected() throws Exception {
- GfshScript.of("start locator --name=locator1 --port=" + Integer.valueOf(port))
- .withName("start locator").execute(gfshRule);
+ public void statusLocatorFailsWhenNotConnected() throws Exception {
+ GfshScript.of("start locator --name=locator1").withName("start locator").execute(gfshRule);
GfshScript.of("status locator --name=locator1").withName("status locator").expectFailure()
.execute(gfshRule);
http://git-wip-us.apache.org/repos/asf/geode/blob/4ac5e65f/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java b/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java
index bc258be..83c1ab5 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java
@@ -74,16 +74,16 @@ import org.apache.geode.internal.process.ProcessControllerParameters;
import org.apache.geode.internal.process.ProcessLauncherContext;
import org.apache.geode.internal.process.ProcessType;
import org.apache.geode.internal.process.ProcessUtils;
+import org.apache.geode.internal.process.StartupStatusListener;
import org.apache.geode.internal.process.UnableToControlProcessException;
import org.apache.geode.lang.AttachAPINotFoundException;
import org.apache.geode.management.internal.cli.json.GfJsonArray;
import org.apache.geode.management.internal.cli.json.GfJsonException;
import org.apache.geode.management.internal.cli.json.GfJsonObject;
-import org.apache.geode.management.internal.cli.util.HostUtils;
/**
* The LocatorLauncher class is a launcher for a GemFire Locator.
- *
+ *
* @see org.apache.geode.distributed.AbstractLauncher
* @see org.apache.geode.distributed.ServerLauncher
* @since GemFire 7.0
@@ -183,7 +183,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Launches a GemFire Locator from the command-line configured with the given arguments.
- *
+ *
* @param args the command-line arguments used to configure the GemFire Locator at runtime.
*/
public static void main(final String... args) {
@@ -202,7 +202,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Gets the instance of the LocatorLauncher used to launch the GemFire Locator, or null if this VM
* does not have an instance of LocatorLauncher indicating no GemFire Locator is running.
- *
+ *
* @return the instance of LocatorLauncher used to launcher a GemFire Locator in this VM.
*/
public static LocatorLauncher getInstance() {
@@ -212,7 +212,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Gets the LocatorState for this process or null if this process was not launched using this VM's
* LocatorLauncher reference.
- *
+ *
* @return the LocatorState for this process or null.
*/
public static LocatorState getLocatorState() {
@@ -224,7 +224,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
* using a Builder. The Builder is used to configure a LocatorLauncher instance. The Builder can
* process user input from the command-line or be used to properly construct an instance of the
* LocatorLauncher programmatically using the API.
- *
+ *
* @param builder an instance of LocatorLauncher.Builder for configuring and constructing an
* instance of the LocatorLauncher.
* @see org.apache.geode.distributed.LocatorLauncher.Builder
@@ -281,7 +281,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Gets the reference to the Locator object representing the running GemFire Locator.
- *
+ *
* @return a reference to the Locator.
*/
InternalLocator getLocator() {
@@ -291,7 +291,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Gets an identifier that uniquely identifies and represents the Locator associated with this
* launcher.
- *
+ *
* @return a String value identifier to uniquely identify the Locator and it's launcher.
* @see #getBindAddressAsString()
* @see #getPortAsString()
@@ -303,7 +303,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Get the Locator launcher command used to invoke the Locator.
- *
+ *
* @return the Locator launcher command used to invoke the Locator.
* @see org.apache.geode.distributed.LocatorLauncher.Command
*/
@@ -314,7 +314,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Determines whether the PID file is allowed to be overwritten when the Locator is started and a
* PID file already exists in the Locator's specified working directory.
- *
+ *
* @return boolean indicating if force has been enabled.
*/
public boolean isForcing() {
@@ -326,7 +326,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
* the standard Locator launcher commands will be used to affect the state of the Locator. A
* launcher is said to be 'helping' if the user entered the "--help" option (switch) on the
* command-line.
- *
+ *
* @return a boolean value indicating if this launcher is used for displaying help information.
* @see org.apache.geode.distributed.LocatorLauncher.Command
*/
@@ -337,7 +337,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Determines whether this launcher will redirect output to system logs when starting a new
* Locator process.
- *
+ *
* @return a boolean value indicating if this launcher will redirect output to system logs when
* starting a new Locator process
*/
@@ -348,21 +348,12 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Gets the IP address of the NIC to which the Locator has bound itself listening for client
* requests.
- *
+ *
* @return an InetAddress object representing the configured bind address for the Locator.
* @see java.net.InetAddress
*/
public InetAddress getBindAddress() {
- try {
- if (bindAddress != null) {
- return bindAddress;
- }
- return SocketCreator.getLocalHost();
- } catch (UnknownHostException handled) {
- // Returning loopback implies the serverBindAddress was null and no IP address
- // for localhost could be found
- return InetAddress.getLoopbackAddress();
- }
+ return this.bindAddress;
}
/**
@@ -370,10 +361,10 @@ public class LocatorLauncher extends AbstractLauncher<String> {
* attempt is made to get the canonical hostname for IP address to which the Locator was bound for
* accepting client requests. If the bind address is null or localhost is unknown, then a default
* String value of "localhost/127.0.0.1" is returned.
- *
+ *
* Note, this information is purely information and should not be used to re-construct state or
* for other purposes.
- *
+ *
* @return the hostname or IP address of the host running the Locator, based on the bind-address,
* or 'localhost/127.0.0.1' if the bind address is null and localhost is unknown.
* @see java.net.InetAddress
@@ -389,7 +380,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
return localhost.getCanonicalHostName();
} catch (UnknownHostException handled) {
- // Returning localhost/127.0.0.1 implies the bindAddress was null and no IP address for
+ // NOTE returning localhost/127.0.0.1 implies the bindAddress was null and no IP address for
// localhost could be found
return "localhost/127.0.0.1";
}
@@ -397,7 +388,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Gets the hostname that clients will use to lookup the running Locator.
- *
+ *
* @return a String indicating the hostname used by clients to lookup the Locator.
*/
public String getHostnameForClients() {
@@ -406,7 +397,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Gets the name of the log file used to log information about this Locator.
- *
+ *
* @return a String value indicating the name of this Locator's log file.
*/
@Override
@@ -418,7 +409,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Gets the name of this member (this Locator) in the GemFire distributed system and determined by
* the 'name' GemFire property.
- *
+ *
* @return a String indicating the name of the member (this Locator) in the GemFire distributed
* system.
*/
@@ -430,7 +421,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Gets the user-specified process ID (PID) of the running Locator that LocatorLauncher uses to
* issue status and stop commands to the Locator.
- *
+ *
* @return an Integer value indicating the process ID (PID) of the running Locator.
*/
@Override
@@ -440,7 +431,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Gets the port number on which the Locator listens for client requests.
- *
+ *
* @return an Integer value indicating the port number on which the Locator is listening for
* client requests.
*/
@@ -455,7 +446,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Gets the port number represented as a String value. If the port number is null, the the default
* Locator port (10334) is returned;
- *
+ *
* @return the port number as a String value.
* @see #getPort()
*/
@@ -476,7 +467,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Gets the name for a GemFire Locator.
- *
+ *
* @return a String indicating the name for a GemFire Locator.
*/
@Override
@@ -486,7 +477,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Gets the working directory pathname in which the Locator will be run.
- *
+ *
* @return a String value indicating the pathname of the Locator's working directory.
*/
@Override
@@ -497,7 +488,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Displays help for the specified Locator launcher command to standard err. If the Locator
* launcher command is unspecified, then usage information is displayed instead.
- *
+ *
* @param command the Locator launcher command in which to display help information.
* @see #usage()
*/
@@ -521,7 +512,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Displays usage information on the proper invocation of the LocatorLauncher from the
* command-line to standard err.
- *
+ *
* @see #help(org.apache.geode.distributed.LocatorLauncher.Command)
*/
public void usage() {
@@ -538,7 +529,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
* The Runnable method used to launch the Locator with the specified command. If 'start' has been
* issued, then run will block as expected for the Locator to stop. The 'start' command is
* implemented with a call to start() followed by a call to waitOnLocator().
- *
+ *
* @see java.lang.Runnable
* @see LocatorLauncher.Command
* @see LocatorLauncher#start()
@@ -576,7 +567,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* 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() {
@@ -585,7 +576,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Determines whether a GemFire Locator can be started with this instance of LocatorLauncher.
- *
+ *
* @return a boolean indicating whether a GemFire Locator can be started with this instance of
* LocatorLauncher, which is true if the LocatorLauncher has not already started a Locator
* or a Locator is not already running.
@@ -599,19 +590,19 @@ public class LocatorLauncher extends AbstractLauncher<String> {
* Starts a Locator running on the specified port and bind address, as determined by getPort and
* getBindAddress respectively, defaulting to 10334 and 'localhost' if not specified, with both
* peer and server location enabled.
- *
+ *
* 'start' is an asynchronous invocation of the Locator. As such, this method makes no guarantees
* whether the Locator's location services (peer and server) are actually running before it
* returns. The Locator's location-based services are initiated in separate, daemon Threads and
* depends on the relative timing and scheduling of those Threads by the JVM. If the application
* using this API wishes for the Locator to continue running after normal application processing
* completes, then one must call <code>waitOnLocator</code>.
- *
+ *
* Given the nature of start, the Locator's status will be in either 1 of 2 possible states. If
* the 'request' to start the Locator proceeds without exception, the status will be 'STARTED'.
* However, if any exception is encountered during the normal startup sequence, then a
* RuntimeException is thrown and the status is set to 'STOPPED'.
- *
+ *
* @return a LocatorState to reflect the state of the Locator after start.
* @throws RuntimeException if the Locator failed to start for any reason.
* @throws IllegalStateException if the Locator is already running.
@@ -643,7 +634,12 @@ public class LocatorLauncher extends AbstractLauncher<String> {
assertPortAvailable(getBindAddress(), getPort());
ProcessLauncherContext.set(isRedirectingOutput(), getOverriddenDefaults(),
- statusMessage -> LocatorLauncher.this.statusMessage = statusMessage);
+ new StartupStatusListener() {
+ @Override
+ public void setStatus(final String statusMessage) {
+ LocatorLauncher.this.statusMessage = statusMessage;
+ }
+ });
try {
this.locator = InternalLocator.startLocator(getPort(), getLogFile(), null, null, null,
@@ -692,13 +688,14 @@ public class LocatorLauncher extends AbstractLauncher<String> {
@Override
protected Properties getDistributedSystemProperties() {
- return super.getDistributedSystemProperties(getProperties());
+ Properties properties = super.getDistributedSystemProperties(getProperties());
+ return properties;
}
/**
* A helper method to ensure the same sequence of actions are taken when the Locator fails to
* start caused by some exception.
- *
+ *
* @param cause the Throwable thrown during the startup or wait operation on the Locator.
*/
private void failOnStart(final Throwable cause) {
@@ -726,7 +723,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Waits on the Locator to stop causing the calling Thread to join with the Locator's
* location-based services Thread.
- *
+ *
* @return the Locator's status once it stops.
* @throws AssertionError if the Locator has not been started and the reference is null
* (assertions must be enabled for the error to be thrown).
@@ -765,15 +762,15 @@ public class LocatorLauncher extends AbstractLauncher<String> {
* time until the timeout expires. If the request to determine the Locator's status is successful,
* then the Locator is considered to be 'ONLINE'. Otherwise, the Locator is considered to be
* unresponsive to the status request.
- *
+ *
* However, this does not necessarily imply the Locator start was unsuccessful, only that a
* response was not received in the given time period.
- *
+ *
* Note, this method does not block or cause the Locator's location-based services (daemon
* Threads) to continue running in anyway if the main application Thread terminates when running
* the Locator in-process. If the caller wishes to start a Locator in an asynchronous manner
* within the application process, then a call should be made to <code>waitOnLocator</code>.
- *
+ *
* @param timeout a long value in time unit indicating when the period of time should expire in
* attempting to determine the Locator's status.
* @param interval a long value in time unit for how frequent the requests should be sent to the
@@ -825,17 +822,17 @@ public class LocatorLauncher extends AbstractLauncher<String> {
* MemberMXBean registered in the MBeanServer of the Locator's JVM, and invoking the 'status'
* operation. The same behavior occurs if the caller specified the Locator's GemFire member name
* or ID.
- *
+ *
* However, if 'dir' or 'pid' were not specified, then determining the Locator's status defaults
* to using the configured bind address and port. If the bind address or port was not specified
* when using the Builder to construct a LocatorLauncher instance, then the defaults for both bind
* address and port are used. In either case, an actual TCP/IP request is made to the Locator's
* ServerSocket to ensure it is listening for client requests. This is true even when the
* LocatorLauncher is used in-process by calling the API.
- *
+ *
* If the conditions above hold, then the Locator is deemed to be 'ONLINE', otherwise, the Locator
* is considered 'OFFLINE'.
- *
+ *
* @return the Locator's state.
* @see #start()
* @see #stop()
@@ -871,7 +868,8 @@ public class LocatorLauncher extends AbstractLauncher<String> {
return statusWithWorkingDirectory();
}
// attempt to get status using host and port (Note, bind address doubles as host when the
- // launcher is used to get the Locator's status).
+ // launcher
+ // is used to get the Locator's status).
else {
debug("Getting Locator status using host (%1$s) and port (%2$s)%n", getBindAddressAsString(),
getPortAsString());
@@ -919,8 +917,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
LocatorStatusResponse response = statusLocator(getPort(), getBindAddress());
return new LocatorState(this, Status.ONLINE, response);
} catch (Exception handled) {
- return createNoResponseState(handled, "Failed to connect to locator "
- + getBindAddress().getCanonicalHostName() + "[" + getPort() + "]");
+ return createNoResponseState(handled, "Failed to connect to locator " + getId());
}
}
@@ -968,7 +965,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Determines whether the Locator can be stopped in-process, such as when a Locator is embedded in
* an application and the LocatorLauncher API is being used.
- *
+ *
* @return a boolean indicating whether the Locator can be stopped in-process (the application's
* process with an embedded Locator).
*/
@@ -982,7 +979,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
* LocatorLauncher class from the command-line or from within GemFire shell (Gfsh). In every
* single case, stop sends a TCP/IP 'shutdown' request on the configured address/port to which the
* Locator is bound and listening.
- *
+ *
* If the "shutdown" request is successful, then the Locator will be 'STOPPED'. Otherwise, the
* Locator is considered 'OFFLINE' since the actual state cannot be fully assessed (as in the
* application process in which the Locator was hosted may still be running and the Locator object
@@ -990,7 +987,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
* is particularly important in cases where the system resources (such as Sockets) may not have
* been cleaned up yet. Therefore, by returning a status of 'OFFLINE', the value is meant to
* reflect this in-deterministic state.
- *
+ *
* @return a LocatorState indicating the state of the Locator after stop has been requested.
* @see #start()
* @see #status()
@@ -1013,6 +1010,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
return stopWithPid();
}
// attempt to stop Locator using the working directory...
+ // else if (this.workingDirectorySpecified) {
else if (getWorkingDirectory() != null) {
return stopWithWorkingDirectory();
} else {
@@ -1211,7 +1209,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
* Constructor used to create and configure an instance of the Builder class with the specified
* arguments, often passed from the command-line when launching an instance of this class from
* the command-line using the Java launcher.
- *
+ *
* @param args the array of arguments used to configure the Builder.
*/
public Builder(final String... args) {
@@ -1220,7 +1218,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Gets an instance of the JOpt Simple OptionParser to parse the command-line arguments.
- *
+ *
* @return an instance of the JOpt Simple OptionParser configured with the command-line options
* used by the Locator.
*/
@@ -1246,7 +1244,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
* Parses an array of arguments to configure this Builder with the intent of constructing a
* Locator launcher to invoke a Locator. This method is called to parse the arguments specified
* by the user on the command-line.
- *
+ *
* @param args the array of arguments used to configure this Builder and create an instance of
* LocatorLauncher.
*/
@@ -1300,7 +1298,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Iterates the list of arguments in search of the target Locator launcher command.
- *
+ *
* @param args an array of arguments from which to search for the Locator launcher command.
* @see org.apache.geode.distributed.LocatorLauncher.Command#valueOfName(String)
* @see #parseArguments(String...)
@@ -1324,7 +1322,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
* Iterates the list of arguments in search of the Locator's GemFire member name. If the
* argument does not start with '-' or is not the name of a Locator launcher command, then the
* value is presumed to be the member name for the Locator in GemFire.
- *
+ *
* @param args the array of arguments from which to search for the Locator's member name in
* GemFire.
* @see org.apache.geode.distributed.LocatorLauncher.Command#isCommand(String)
@@ -1343,7 +1341,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Gets the Locator launcher command used during the invocation of the LocatorLauncher.
- *
+ *
* @return the Locator launcher command used to invoke (run) the LocatorLauncher class.
* @see #setCommand(org.apache.geode.distributed.LocatorLauncher.Command)
* @see LocatorLauncher.Command
@@ -1354,7 +1352,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Sets the Locator launcher command used during the invocation of the LocatorLauncher
- *
+ *
* @param command the targeted Locator launcher command used during the invocation (run) of
* LocatorLauncher.
* @return this Builder instance.
@@ -1368,7 +1366,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Determines whether the new instance of the LocatorLauncher will be set to debug mode.
- *
+ *
* @return a boolean value indicating whether debug mode is enabled or disabled.
* @see #setDebug(Boolean)
*/
@@ -1378,7 +1376,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Sets whether the new instance of the LocatorLauncher will be set to debug mode.
- *
+ *
* @param debug a boolean value indicating whether debug mode is to be enabled or disabled.
* @return this Builder instance.
* @see #getDebug()
@@ -1428,7 +1426,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Gets the boolean value used by the Locator to determine if it should overwrite the PID file
* if it already exists.
- *
+ *
* @return the boolean value specifying whether or not to overwrite the PID file if it already
* exists.
* @see #setForce(Boolean)
@@ -1440,7 +1438,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Sets the boolean value used by the Locator to determine if it should overwrite the PID file
* if it already exists.
- *
+ *
* @param force a boolean value indicating whether to overwrite the PID file when it already
* exists.
* @return this Builder instance.
@@ -1455,7 +1453,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Determines whether the new instance of LocatorLauncher will be used to output help
* information for either a specific command, or for using LocatorLauncher in general.
- *
+ *
* @return a boolean value indicating whether help will be output during the invocation of
* LocatorLauncher.
* @see #setHelp(Boolean)
@@ -1466,7 +1464,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Determines whether help has been enabled.
- *
+ *
* @return a boolean indicating if help was enabled.
*/
private boolean isHelping() {
@@ -1476,7 +1474,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Sets whether the new instance of LocatorLauncher will be used to output help information for
* either a specific command, or for using LocatorLauncher in general.
- *
+ *
* @param help a boolean indicating whether help information is to be displayed during
* invocation of LocatorLauncher.
* @return this Builder instance.
@@ -1494,7 +1492,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Gets the IP address to which the Locator has bound itself listening for client requests.
- *
+ *
* @return an InetAddress with the IP address or hostname on which the Locator is bound and
* listening.
* @see #setBindAddress(String)
@@ -1507,7 +1505,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Sets the IP address as an java.net.InetAddress to which the Locator has bound itself
* listening for client requests.
- *
+ *
* @param bindAddress the InetAddress with the IP address or hostname on which the Locator is
* bound and listening.
* @return this Builder instance.
@@ -1541,7 +1539,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Gets the hostname used by clients to lookup the Locator.
- *
+ *
* @return a String indicating the hostname Locator binding used in client lookups.
* @see #setHostnameForClients(String)
*/
@@ -1551,7 +1549,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Sets the hostname used by clients to lookup the Locator.
- *
+ *
* @param hostnameForClients a String indicating the hostname Locator binding used in client
* lookups.
* @return this Builder instance.
@@ -1572,7 +1570,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Gets the member name of this Locator in GemFire.
- *
+ *
* @return a String indicating the member name of this Locator in GemFire.
* @see #setMemberName(String)
*/
@@ -1582,7 +1580,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Sets the member name of the Locator in GemFire.
- *
+ *
* @param memberName a String indicating the member name of this Locator in GemFire.
* @return this Builder instance.
* @throws IllegalArgumentException if the member name is invalid.
@@ -1602,7 +1600,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
* Gets the process ID (PID) of the running Locator indicated by the user as an argument to the
* LocatorLauncher. This PID is used by the Locator launcher to determine the Locator's status,
* or invoke shutdown on the Locator.
- *
+ *
* @return a user specified Integer value indicating the process ID of the running Locator.
* @see #setPid(Integer)
*/
@@ -1614,7 +1612,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
* Sets the process ID (PID) of the running Locator indicated by the user as an argument to the
* LocatorLauncher. This PID will be used by the Locator launcher to determine the Locator's
* status, or invoke shutdown on the Locator.
- *
+ *
* @param pid a user specified Integer value indicating the process ID of the running Locator.
* @return this Builder instance.
* @throws IllegalArgumentException if the process ID (PID) is not valid (greater than zero if
@@ -1637,7 +1635,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Gets the port number used by the Locator to listen for client requests. If the port was not
* specified, then the default Locator port (10334) is returned.
- *
+ *
* @return the specified Locator port or the default port if unspecified.
* @see #setPort(Integer)
*/
@@ -1648,7 +1646,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Sets the port number used by the Locator to listen for client requests. The port number must
* be between 1 and 65535 inclusive.
- *
+ *
* @param port an Integer value indicating the port used by the Locator to listen for client
* requests.
* @return this Builder instance.
@@ -1671,9 +1669,10 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Determines whether the new instance of LocatorLauncher will redirect output to system logs
* when starting a Locator.
- *
+ *
* @return a boolean value indicating if output will be redirected to system logs when starting
* a Locator
+ *
* @see #setRedirectOutput(Boolean)
*/
public Boolean getRedirectOutput() {
@@ -1682,7 +1681,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Determines whether redirecting of output has been enabled.
- *
+ *
* @return a boolean indicating if redirecting of output was enabled.
*/
private boolean isRedirectingOutput() {
@@ -1692,7 +1691,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Sets whether the new instance of LocatorLauncher will redirect output to system logs when
* starting a Locator.
- *
+ *
* @param redirectOutput a boolean value indicating if output will be redirected to system logs
* when starting a Locator.
* @return this Builder instance.
@@ -1710,7 +1709,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Gets the working directory pathname in which the Locator will be ran. If the directory is
* unspecified, then working directory defaults to the current directory.
- *
+ *
* @return a String indicating the working directory pathname.
* @see #setWorkingDirectory(String)
*/
@@ -1723,7 +1722,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
* Sets the working directory in which the Locator will be ran. This also the directory in which
* all Locator files (such as log and license files) will be written. If the directory is
* unspecified, then the working directory defaults to the current directory.
- *
+ *
* @param workingDirectory a String indicating the pathname of the directory in which the
* Locator will be ran.
* @return this Builder instance.
@@ -1765,7 +1764,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
* specified the pathname to the gemfire.properties file before validate is called. It is then
* assumed, but not further validated, that the user has specified the Locator's member name in
* the properties file.
- *
+ *
* @throws IllegalStateException if the Builder is not properly configured.
*/
protected void validate() {
@@ -1779,7 +1778,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Validates the arguments passed to the Builder when the 'start' command has been issued.
- *
+ *
* @see org.apache.geode.distributed.LocatorLauncher.Command#START
*/
protected void validateOnStart() {
@@ -1803,7 +1802,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Validates the arguments passed to the Builder when the 'status' command has been issued.
- *
+ *
* @see org.apache.geode.distributed.LocatorLauncher.Command#STATUS
*/
protected void validateOnStatus() {
@@ -1813,7 +1812,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Validates the arguments passed to the Builder when the 'stop' command has been issued.
- *
+ *
* @see org.apache.geode.distributed.LocatorLauncher.Command#STOP
*/
protected void validateOnStop() {
@@ -1824,7 +1823,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Validates the Builder configuration settings and then constructs an instance of the
* LocatorLauncher class to invoke operations on a GemFire Locator.
- *
+ *
* @return a newly constructed instance of LocatorLauncher configured with this Builder.
* @see #validate()
* @see org.apache.geode.distributed.LocatorLauncher
@@ -1838,7 +1837,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* An enumerated type representing valid commands to the Locator launcher.
*/
- public enum Command {
+ public static enum Command {
START("start", "bind-address", "hostname-for-clients", "port", "force", "debug", "help"),
STATUS("status", "bind-address", "port", "member", "pid", "dir", "debug", "help"),
STOP("stop", "member", "pid", "dir", "debug", "help"),
@@ -1853,13 +1852,13 @@ public class LocatorLauncher extends AbstractLauncher<String> {
assert isNotBlank(name) : "The name of the locator launcher command must be specified!";
this.name = name;
this.options = (options != null ? Collections.unmodifiableList(Arrays.asList(options))
- : Collections.emptyList());
+ : Collections.<String>emptyList());
}
/**
* Determines whether the specified name refers to a valid Locator launcher command, as defined
* by this enumerated type.
- *
+ *
* @param name a String value indicating the potential name of a Locator launcher command.
* @return a boolean indicating whether the specified name for a Locator launcher command is
* valid.
@@ -1871,7 +1870,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Determines whether the given Locator launcher command has been properly specified. The
* command is deemed unspecified if the reference is null or the Command is UNSPECIFIED.
- *
+ *
* @param command the Locator launcher command.
* @return a boolean value indicating whether the Locator launcher command is unspecified.
* @see Command#UNSPECIFIED
@@ -1883,7 +1882,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Looks up a Locator launcher command by name. The equality comparison on name is
* case-insensitive.
- *
+ *
* @param name a String value indicating the name of the Locator launcher command.
* @return an enumerated type representing the command name or null if the no such command with
* the specified name exists.
@@ -1900,7 +1899,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Gets the name of the Locator launcher command.
- *
+ *
* @return a String value indicating the name of the Locator launcher command.
*/
public String getName() {
@@ -1910,7 +1909,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Gets a set of valid options that can be used with the Locator launcher command when used from
* the command-line.
- *
+ *
* @return a Set of Strings indicating the names of the options available to the Locator
* launcher command.
*/
@@ -1920,7 +1919,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Determines whether this Locator launcher command has the specified command-line option.
- *
+ *
* @param option a String indicating the name of the command-line option to this command.
* @return a boolean value indicating whether this command has the specified named command-line
* option.
@@ -1931,7 +1930,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Convenience method for determining whether this is the UNSPECIFIED Locator launcher command.
- *
+ *
* @return a boolean indicating if this command is UNSPECIFIED.
* @see #UNSPECIFIED
*/
@@ -1941,7 +1940,7 @@ public class LocatorLauncher extends AbstractLauncher<String> {
/**
* Gets the String representation of this Locator launcher command.
- *
+ *
* @return a String value representing this Locator launcher command.
*/
@Override
@@ -1954,14 +1953,14 @@ public class LocatorLauncher extends AbstractLauncher<String> {
* The LocatorState is an immutable type representing the state of the specified Locator at any
* given moment in time. The state of the Locator is assessed at the exact moment an instance of
* this class is constructed.
- *
+ *
* @see org.apache.geode.distributed.AbstractLauncher.ServiceState
*/
public static class LocatorState extends ServiceState<String> {
/**
* Unmarshals a LocatorState instance from the JSON String.
- *
+ *
* @return a LocatorState value unmarshalled from the JSON String.
*/
public static LocatorState fromJson(final String json) {
@@ -2015,41 +2014,26 @@ public class LocatorLauncher extends AbstractLauncher<String> {
this(status, // status
errorMessage, // statusMessage
System.currentTimeMillis(), // timestamp
- getLocatorLocation(launcher), // locatorLocation
+ null, // locatorLocation
null, // pid
0L, // uptime
launcher.getWorkingDirectory(), // workingDirectory
- ManagementFactory.getRuntimeMXBean().getInputArguments(), // jvmArguments
+ Collections.<String>emptyList(), // jvmArguments
null, // classpath
GemFireVersion.getGemFireVersion(), // gemfireVersion
- System.getProperty("java.version"), // javaVersion
+ null, // javaVersion
null, // logFile
- getBindAddress(launcher).getCanonicalHostName(), // host
- launcher.getPortAsString(), // port
+ null, // host
+ null, // port
null);// memberName
}
- /*
- * Guards against throwing NPEs due to incorrect or missing host information while constructing
- * error states
- */
- private static String getLocatorLocation(LocatorLauncher launcher) {
- if (launcher.getPort() == null) {
- return launcher.getId();
- }
- if (launcher.getBindAddress() == null) {
- return HostUtils.getLocatorId(HostUtils.getLocalHost(), launcher.getPort());
- }
- return HostUtils.getLocatorId(launcher.getBindAddress().getCanonicalHostName(),
- launcher.getPort());
- }
-
private static String getBindAddressAsString(LocatorLauncher launcher) {
if (InternalLocator.hasLocator()) {
final InternalLocator locator = InternalLocator.getLocator();
final InetAddress bindAddress = locator.getBindAddress();
if (bindAddress != null) {
- if (isNotBlank(bindAddress.getHostAddress())) {
+ if (isBlank(bindAddress.getHostAddress())) {
return bindAddress.getHostAddress();
}
}
@@ -2057,17 +2041,6 @@ public class LocatorLauncher extends AbstractLauncher<String> {
return launcher.getBindAddressAsString();
}
- private static InetAddress getBindAddress(LocatorLauncher launcher) {
- if (InternalLocator.hasLocator()) {
- final InternalLocator locator = InternalLocator.getLocator();
- final InetAddress bindAddress = locator.getBindAddress();
- if (bindAddress != null) {
- return bindAddress;
- }
- }
- return launcher.getBindAddress();
- }
-
private static String getLogFileCanonicalPath(LocatorLauncher launcher) {
if (InternalLocator.hasLocator()) {
final InternalLocator locator = InternalLocator.getLocator();
@@ -2076,7 +2049,8 @@ public class LocatorLauncher extends AbstractLauncher<String> {
if (logFile != null && logFile.isFile()) {
final String logFileCanonicalPath = tryGetCanonicalPathElseGetAbsolutePath(logFile);
if (isNotBlank(logFileCanonicalPath)) { // this is probably not need but a
- // safe check none-the-less.
+ // safe
+ // check none-the-less.
return logFileCanonicalPath;
}
}
http://git-wip-us.apache.org/repos/asf/geode/blob/4ac5e65f/geode-core/src/main/java/org/apache/geode/distributed/ServerLauncher.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/ServerLauncher.java b/geode-core/src/main/java/org/apache/geode/distributed/ServerLauncher.java
index a5548d1..ae64691 100755
--- a/geode-core/src/main/java/org/apache/geode/distributed/ServerLauncher.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/ServerLauncher.java
@@ -30,7 +30,6 @@ import static org.apache.geode.internal.util.IOUtils.tryGetCanonicalPathElseGetA
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
-import java.io.UncheckedIOException;
import java.lang.management.ManagementFactory;
import java.net.InetAddress;
import java.net.UnknownHostException;
@@ -82,13 +81,13 @@ import org.apache.geode.internal.process.ProcessControllerFactory;
import org.apache.geode.internal.process.ProcessControllerParameters;
import org.apache.geode.internal.process.ProcessLauncherContext;
import org.apache.geode.internal.process.ProcessType;
+import org.apache.geode.internal.process.StartupStatusListener;
import org.apache.geode.internal.process.UnableToControlProcessException;
import org.apache.geode.lang.AttachAPINotFoundException;
import org.apache.geode.management.internal.cli.i18n.CliStrings;
import org.apache.geode.management.internal.cli.json.GfJsonArray;
import org.apache.geode.management.internal.cli.json.GfJsonException;
import org.apache.geode.management.internal.cli.json.GfJsonObject;
-import org.apache.geode.management.internal.cli.util.HostUtils;
import org.apache.geode.pdx.PdxSerializer;
import org.apache.geode.security.AuthenticationRequiredException;
import org.apache.geode.security.GemFireSecurityException;
@@ -96,7 +95,7 @@ import org.apache.geode.security.GemFireSecurityException;
/**
* The ServerLauncher class is a launcher class with main method to start a GemFire Server (implying
* a GemFire Cache Server process).
- *
+ *
* @see org.apache.geode.distributed.AbstractLauncher
* @see org.apache.geode.distributed.LocatorLauncher
* @since GemFire 7.0
@@ -218,7 +217,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Launches a GemFire Server from the command-line configured with the given arguments.
- *
+ *
* @param args the command-line arguments used to configure the GemFire Server at runtime.
*/
public static void main(final String... args) {
@@ -238,7 +237,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
* Gets the instance of the ServerLauncher used to launch the GemFire Cache Server, or null if
* this VM does not have an instance of ServerLauncher indicating no GemFire Cache Server is
* running.
- *
+ *
* @return the instance of ServerLauncher used to launcher a GemFire Cache Server in this VM.
*/
public static ServerLauncher getInstance() {
@@ -248,7 +247,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Gets the ServerState for this process or null if this process was not launched using this VM's
* ServerLauncher reference .
- *
+ *
* @return the ServerState for this process or null.
*/
public static ServerState getServerState() {
@@ -260,7 +259,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
* using a Builder. The Builder is used to configure a ServerLauncher instance. The Builder can
* process user input from the command-line or be used programmatically to properly construct an
* instance of the ServerLauncher using the API.
- *
+ *
* @param builder an instance of ServerLauncher.Builder for configuring and constructing an
* instance of the ServerLauncher.
* @see org.apache.geode.distributed.ServerLauncher.Builder
@@ -319,7 +318,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Gets a reference to the Cache that was created when the GemFire Server was started.
- *
+ *
* @return a reference to the Cache created by the GemFire Server start operation.
* @see org.apache.geode.cache.Cache
*/
@@ -352,7 +351,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Gets an identifier that uniquely identifies and represents the Server associated with this
* launcher.
- *
+ *
* @return a String value identifier to uniquely identify the Server and it's launcher.
* @see #getServerBindAddressAsString()
* @see #getServerPortAsString()
@@ -370,7 +369,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Get the Server launcher command used to invoke the Server.
- *
+ *
* @return the Server launcher command used to invoke the Server.
* @see org.apache.geode.distributed.ServerLauncher.Command
*/
@@ -381,7 +380,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Determines whether buckets should be assigned to partitioned regions in the cache upon Server
* start.
- *
+ *
* @return a boolean indicating if buckets should be assigned upon Server start.
*/
public boolean isAssignBuckets() {
@@ -390,7 +389,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Determines whether a default cache server will be added when the GemFire Server comes online.
- *
+ *
* @return a boolean value indicating whether to add a default cache server.
*/
public boolean isDisableDefaultServer() {
@@ -400,7 +399,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Determines whether the PID file is allowed to be overwritten when the Server is started and a
* PID file already exists in the Server's specified working directory.
- *
+ *
* @return boolean indicating if force has been enabled.
*/
public boolean isForcing() {
@@ -412,7 +411,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
* the standard Server launcher commands will be used to affect the state of the Server. A
* launcher is said to be 'helping' if the user entered the "--help" option (switch) on the
* command-line.
- *
+ *
* @return a boolean value indicating if this launcher is used for displaying help information.
* @see org.apache.geode.distributed.ServerLauncher.Command
*/
@@ -423,7 +422,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Determines whether a rebalance operation on the cache will occur upon starting the GemFire
* server using this launcher.
- *
+ *
* @return a boolean indicating if the cache will be rebalance when the GemFire server starts.
*/
public boolean isRebalancing() {
@@ -433,7 +432,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Determines whether this launcher will redirect output to system logs when starting a new
* Locator process.
- *
+ *
* @return a boolean value indicating if this launcher will redirect output to system logs when
* starting a new Locator process
*/
@@ -443,7 +442,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Gets the name of the log file used to log information about this Server.
- *
+ *
* @return a String value indicating the name of this Server's log file.
*/
@Override
@@ -454,7 +453,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Gets the name of this member (this Server) in the GemFire distributed system as determined by
* the 'name' GemFire property.
- *
+ *
* @return a String indicating the name of the member (this Server) in the GemFire distributed
* system.
*/
@@ -466,7 +465,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Gets the user-specified process ID (PID) of the running Server that ServerLauncher uses to
* issue status and stop commands to the Server.
- *
+ *
* @return an Integer value indicating the process ID (PID) of the running Server.
*/
@Override
@@ -490,22 +489,12 @@ public class ServerLauncher extends AbstractLauncher<String> {
* connections. This property should not be confused with 'bindAddress' ServerLauncher property,
* which is the port for binding the Server's ServerSocket used in distribution and messaging
* between the peers of the GemFire distributed system.
- *
+ *
* @return an InetAddress indicating the IP address that the Server is bound to listening for and
* accepting cache client connections in a client/server topology.
*/
public InetAddress getServerBindAddress() {
- if (serverBindAddress != null) {
- return this.serverBindAddress;
- }
-
- try {
- return SocketCreator.getLocalHost();
- } catch (UnknownHostException handled) {
- // Returning loopback implies the serverBindAddress was null and no IP address
- // for localhost could be found
- return InetAddress.getLoopbackAddress();
- }
+ return this.serverBindAddress;
}
/**
@@ -513,10 +502,10 @@ public class ServerLauncher extends AbstractLauncher<String> {
* attempt is made to get the canonical hostname for IP address to which the Server was bound for
* accepting client requests. If the server bind address is null or localhost is unknown, then a
* default String value of "localhost/127.0.0.1" is returned.
- *
+ *
* Note, this information is purely information and should not be used to re-construct state or
* for other purposes.
- *
+ *
* @return the hostname or IP address of the host running the Server, based on the bind-address,
* or 'localhost/127.0.0.1' if the bind address is null and localhost is unknown.
* @see java.net.InetAddress
@@ -532,7 +521,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
return localhost.getCanonicalHostName();
} catch (UnknownHostException handled) {
- // Returning localhost/127.0.0.1 implies the serverBindAddress was null and no IP address
+ // NOTE returning localhost/127.0.0.1 implies the serverBindAddress was null and no IP address
// for localhost could be found
return "localhost/127.0.0.1";
}
@@ -543,7 +532,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
* should not be confused with the 'port' ServerLauncher property, which is used by the Server to
* set the 'tcp-port' distribution config property and is used by the ServerSocket for peer
* distribution and messaging.
- *
+ *
* @return an Integer value indicating the port the Server is listening on for cache client
* connections in the client/server topology.
*/
@@ -554,7 +543,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Gets the server port on which the Server is listening for client requests represented as a
* String value.
- *
+ *
* @return a String representing the server port on which the Server is listening for client
* requests.
* @see #getServerPort()
@@ -565,7 +554,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Gets the name for a GemFire Server.
- *
+ *
* @return a String indicating the name for a GemFire Server.
*/
@Override
@@ -577,7 +566,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
* Gets the location of the Spring XML configuration meta-data file used to bootstrap, configure
* and initialize the GemFire Server on start.
* <p>
- *
+ *
* @return a String indicating the location of the Spring XML configuration file.
* @see org.apache.geode.distributed.ServerLauncher.Builder#getSpringXmlLocation()
*/
@@ -589,7 +578,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
* Determines whether this GemFire Server was configured and initialized with Spring configuration
* meta-data.
* <p>
- *
+ *
* @return a boolean value indicating whether this GemFire Server was configured with Spring
* configuration meta-data.
*/
@@ -599,7 +588,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Gets the working directory pathname in which the Server will be run.
- *
+ *
* @return a String value indicating the pathname of the Server's working directory.
*/
@Override
@@ -650,7 +639,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Displays help for the specified Server launcher command to standard err. If the Server launcher
* command is unspecified, then usage information is displayed instead.
- *
+ *
* @param command the Server launcher command in which to display help information.
* @see #usage()
*/
@@ -674,7 +663,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Displays usage information on the proper invocation of the ServerLauncher from the command-line
* to standard err.
- *
+ *
* @see #help(org.apache.geode.distributed.ServerLauncher.Command)
*/
public void usage() {
@@ -691,7 +680,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
* A Runnable method used to invoke the GemFire server (cache server) with the specified command.
* From run, a user can invoke 'start', 'status', 'stop' and 'version'. Note, that 'version' is
* also a command-line option, but can be treated as a "command" as well.
- *
+ *
* @see java.lang.Runnable
*/
@Override
@@ -721,7 +710,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* 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() {
@@ -762,9 +751,12 @@ public class ServerLauncher extends AbstractLauncher<String> {
SystemFailure.setExitOK(true);
ProcessLauncherContext.set(isRedirectingOutput(), getOverriddenDefaults(),
- (String statusMessage) -> {
- debug("Callback setStatus(String) called with message (%1$s)...", statusMessage);
- ServerLauncher.this.statusMessage = statusMessage;
+ new StartupStatusListener() {
+ @Override
+ public void setStatus(final String statusMessage) {
+ debug("Callback setStatus(String) called with message (%1$s)...", statusMessage);
+ ServerLauncher.this.statusMessage = statusMessage;
+ }
});
try {
@@ -857,7 +849,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* A helper method to ensure the same sequence of actions are taken when the Server fails to start
* caused by some exception.
- *
+ *
* @param cause the Throwable thrown during the startup operation on the Server.
*/
private void failOnStart(final Throwable cause) {
@@ -877,7 +869,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Determines whether the specified Cache has any CacheServers.
- *
+ *
* @param cache the Cache to check for existing CacheServers.
* @return a boolean value indicating if any CacheServers were added to the Cache.
*/
@@ -887,7 +879,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Determines whether to continue waiting and keep the GemFire non-Server data member running.
- *
+ *
* @param cache the Cache associated with this GemFire (non-Server) data member.
* @return a boolean value indicating whether the GemFire data member should continue running, as
* determined by the running flag and a connection to the distributed system (GemFire
@@ -930,7 +922,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
* by the absence of specifying the --disable-default-server command-line option (switch). In
* addition, a default cache server is started only if no cache servers have been added to the
* Cache by way of cache.xml.
- *
+ *
* @param cache the reference to the Cache to check for any existing cache servers.
* @return a boolean indicating whether a default server should be added to the Cache.
* @see #isDisableDefaultServer()
@@ -943,7 +935,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
* If the default server (cache server) has not been disabled and no prior cache servers were
* added to the cache, then this method will add a cache server to the Cache and start the server
* Thread on the specified bind address and port.
- *
+ *
* @param cache the Cache to which the server will be added.
* @throws IOException if the Cache server fails to start due to IO error.
*/
@@ -990,7 +982,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Causes a rebalance operation to occur on the given Cache.
- *
+ *
* @param cache the reference to the Cache to rebalance.
* @see org.apache.geode.cache.control.ResourceManager#createRebalanceFactory()
*/
@@ -1005,7 +997,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
* using the --assign-buckets command-line option (switch) at the command-line as well as whether
* the option is technically allowed. The option is only allowed if the instance of the Cache is
* the internal GemFireCacheImpl at present.
- *
+ *
* @param cache the Cache reference to check for instance type.
* @return a boolean indicating if bucket assignment is both enabled and allowed.
* @see #isAssignBuckets()
@@ -1016,7 +1008,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Assigns buckets to individual Partitioned Regions of the Cache.
- *
+ *
* @param cache the Cache who's Partitioned Regions are accessed to assign buckets to.
* @see PartitionRegionHelper#assignBucketsToPartitions(org.apache.geode.cache.Region)
*/
@@ -1030,7 +1022,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Determines whether the Server is the process of starting or is already running.
- *
+ *
* @return a boolean indicating if the Server is starting or is already running.
*/
protected boolean isStartingOrRunning() {
@@ -1059,8 +1051,10 @@ public class ServerLauncher extends AbstractLauncher<String> {
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");
+
+ debug(
+ "This ServerLauncher was not the instance used to launch the GemFire Cache Server, and neither PID "
+ .concat("nor working directory were specified; the Server's state is unknown.%n"));
return new ServerState(this, Status.NOT_RESPONDING);
}
@@ -1137,7 +1131,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Determines whether the Server can be stopped in-process, such as when a Server is embedded in
* an application and the ServerLauncher API is being used.
- *
+ *
* @return a boolean indicating whether the Server can be stopped in-process (the application's
* process with an embedded Server).
*/
@@ -1395,7 +1389,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
* Constructor used to create and configure an instance of the Builder class with the specified
* arguments, passed in from the command-line when launching an instance of this class from the
* command-line using the Java launcher.
- *
+ *
* @param args the array of arguments used to configure the Builder.
* @see #parseArguments(String...)
*/
@@ -1406,7 +1400,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Gets an instance of the JOptSimple OptionParser to parse the command-line arguments for
* Server.
- *
+ *
* @return an instance of the JOptSimple OptionParser configured with the command-line options
* used by the Server.
*/
@@ -1454,7 +1448,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
* Parses the list of arguments to configure this Builder with the intent of constructing a
* Server launcher to invoke a Cache Server. This method is called to parse the arguments
* specified by the user on the command-line.
- *
+ *
* @param args the array of arguments used to configure this Builder and create an instance of
* ServerLauncher.
*/
@@ -1599,7 +1593,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Iterates the list of arguments in search of the target Server launcher command.
- *
+ *
* @param args an array of arguments from which to search for the Server launcher command.
* @see org.apache.geode.distributed.ServerLauncher.Command#valueOfName(String)
* @see #parseArguments(String...)
@@ -1620,7 +1614,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
* Iterates the list of arguments in search of the Server's GemFire member name. If the argument
* does not start with '-' or is not the name of a Server launcher command, then the value is
* presumed to be the member name for the Server in GemFire.
- *
+ *
* @param args the array of arguments from which to search for the Server's member name in
* GemFire.
* @see org.apache.geode.distributed.ServerLauncher.Command#isCommand(String)
@@ -1648,7 +1642,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Gets the Server launcher command used during the invocation of the ServerLauncher.
- *
+ *
* @return the Server launcher command used to invoke (run) the ServerLauncher class.
* @see #setCommand(org.apache.geode.distributed.ServerLauncher.Command)
* @see org.apache.geode.distributed.ServerLauncher.Command
@@ -1659,7 +1653,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Sets the Sever launcher command used during the invocation of the ServerLauncher
- *
+ *
* @param command the targeted Server launcher command used during the invocation (run) of
* ServerLauncher.
* @return this Builder instance.
@@ -1674,7 +1668,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Determines whether buckets should be assigned to partitioned regions in the cache upon Server
* start.
- *
+ *
* @return a boolean indicating if buckets should be assigned upon Server start.
* @see #setAssignBuckets(Boolean)
*/
@@ -1685,7 +1679,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Sets whether buckets should be assigned to partitioned regions in the cache upon Server
* start.
- *
+ *
* @param assignBuckets a boolean indicating if buckets should be assigned upon Server start.
* @return this Builder instance.
* @see #getAssignBuckets()
@@ -1708,7 +1702,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Determines whether the new instance of the ServerLauncher will be set to debug mode.
- *
+ *
* @return a boolean value indicating whether debug mode is enabled or disabled.
* @see #setDebug(Boolean)
*/
@@ -1718,7 +1712,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Sets whether the new instance of the ServerLauncher will be set to debug mode.
- *
+ *
* @param debug a boolean value indicating whether debug mode is to be enabled or disabled.
* @return this Builder instance.
* @see #getDebug()
@@ -1756,7 +1750,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Determines whether a default cache server will be added when the Geode Server comes online.
- *
+ *
* @return a boolean value indicating whether to add a default cache server.
* @see #setDisableDefaultServer(Boolean)
*/
@@ -1767,7 +1761,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Sets a boolean value indicating whether to add a default cache when the GemFire Server comes
* online.
- *
+ *
* @param disableDefaultServer a boolean value indicating whether to add a default cache server.
* @return this Builder instance.
* @see #getDisableDefaultServer()
@@ -1791,7 +1785,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Gets the boolean value used by the Server to determine if it should overwrite the PID file if
* it already exists.
- *
+ *
* @return the boolean value specifying whether or not to overwrite the PID file if it already
* exists.
* @see #setForce(Boolean)
@@ -1803,7 +1797,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Sets the boolean value used by the Server to determine if it should overwrite the PID file if
* it already exists.
- *
+ *
* @param force a boolean value indicating whether to overwrite the PID file when it already
* exists.
* @return this Builder instance.
@@ -1817,7 +1811,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Determines whether the new instance of the ServerLauncher will be used to output help
* information for either a specific command, or for using ServerLauncher in general.
- *
+ *
* @return a boolean value indicating whether help will be output during the invocation of the
* ServerLauncher.
* @see #setHelp(Boolean)
@@ -1828,7 +1822,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Determines whether help has been enabled.
- *
+ *
* @return a boolean indicating if help was enabled.
*/
protected boolean isHelping() {
@@ -1838,7 +1832,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Sets whether the new instance of ServerLauncher will be used to output help information for
* either a specific command, or for using ServerLauncher in general.
- *
+ *
* @param help a boolean indicating whether help information is to be displayed during
* invocation of ServerLauncher.
* @return this Builder instance.
@@ -1852,7 +1846,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Determines whether a rebalance operation on the cache will occur upon starting the GemFire
* server.
- *
+ *
* @return a boolean indicating if the cache will be rebalance when the GemFire server starts.
* @see #setRebalance(Boolean)
*/
@@ -1863,7 +1857,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Set a boolean value indicating whether a rebalance operation on the cache should occur upon
* starting the GemFire server.
- *
+ *
* @param rebalance a boolean indicating if the cache will be rebalanced when the GemFire server
* starts.
* @return this Builder instance.
@@ -1876,7 +1870,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Gets the member name of this Server in GemFire.
- *
+ *
* @return a String indicating the member name of this Server in GemFire.
* @see #setMemberName(String)
*/
@@ -1886,7 +1880,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Sets the member name of the Server in GemFire.
- *
+ *
* @param memberName a String indicating the member name of this Server in GemFire.
* @return this Builder instance.
* @throws IllegalArgumentException if the member name is invalid.
@@ -1906,7 +1900,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
* Gets the process ID (PID) of the running Server indicated by the user as an argument to the
* ServerLauncher. This PID is used by the Server launcher to determine the Server's status, or
* invoke shutdown on the Server.
- *
+ *
* @return a user specified Integer value indicating the process ID of the running Server.
* @see #setPid(Integer)
*/
@@ -1918,7 +1912,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
* Sets the process ID (PID) of the running Server indicated by the user as an argument to the
* ServerLauncher. This PID will be used by the Server launcher to determine the Server's
* status, or invoke shutdown on the Server.
- *
+ *
* @param pid a user specified Integer value indicating the process ID of the running Server.
* @return this Builder instance.
* @throws IllegalArgumentException if the process ID (PID) is not valid (greater than zero if
@@ -1937,9 +1931,10 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Determines whether the new instance of ServerLauncher will redirect output to system logs
* when starting a Server.
- *
+ *
* @return a boolean value indicating if output will be redirected to system logs when starting
* a Server
+ *
* @see #setRedirectOutput(Boolean)
*/
public Boolean getRedirectOutput() {
@@ -1948,7 +1943,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Determines whether redirecting of output has been enabled.
- *
+ *
* @return a boolean indicating if redirecting of output was enabled.
*/
private boolean isRedirectingOutput() {
@@ -1958,7 +1953,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Sets whether the new instance of ServerLauncher will redirect output to system logs when
* starting a Server.
- *
+ *
* @param redirectOutput a boolean value indicating if output will be redirected to system logs
* when starting a Server.
* @return this Builder instance.
@@ -1972,7 +1967,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Gets the IP address to which the Server will be bound listening for and accepting cache
* client connections in a client/server topology.
- *
+ *
* @return an InetAddress indicating the IP address that the Server is bound to listening for
* and accepting cache client connections in a client/server topology.
* @see #setServerBindAddress(String)
@@ -1988,7 +1983,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Sets the IP address to which the Server will be bound listening for and accepting cache
* client connections in a client/server topology.
- *
+ *
* @param serverBindAddress a String specifying the IP address or hostname that the Server will
* be bound to listen for and accept cache client connections in a client/server
* topology.
@@ -2026,7 +2021,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Gets the port on which the Server will listen for and accept cache client connections in a
* client/server topology.
- *
+ *
* @return an Integer value specifying the port the Server will listen on and accept cache
* client connections in a client/server topology.
* @see #setServerPort(Integer)
@@ -2042,7 +2037,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Sets the port on which the Server will listen for and accept cache client connections in a
* client/server topology.
- *
+ *
* @param serverPort an Integer value specifying the port the Server will listen on and accept
* cache client connections in a client/server topology.
* @return this Builder instance.
@@ -2064,7 +2059,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
* Gets the location of the Spring XML configuration meta-data file used to bootstrap, configure
* and initialize the GemFire Server on start.
* <p>
- *
+ *
* @return a String indicating the location of the Spring XML configuration file.
* @see #setSpringXmlLocation(String)
*/
@@ -2076,7 +2071,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
* Sets the location of the Spring XML configuration meta-data file used to bootstrap, configure
* and initialize the GemFire Server on start.
* <p>
- *
+ *
* @param springXmlLocation a String indicating the location of the Spring XML configuration
* file.
* @return this Builder instance.
@@ -2090,7 +2085,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Gets the working directory pathname in which the Server will be ran. If the directory is
* unspecified, then working directory defaults to the current directory.
- *
+ *
* @return a String indicating the working directory pathname.
* @see #setWorkingDirectory(String)
*/
@@ -2103,7 +2098,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
* Sets the working directory in which the Server will be ran. This also the directory in which
* all Server files (such as log and license files) will be written. If the directory is
* unspecified, then the working directory defaults to the current directory.
- *
+ *
* @param workingDirectory a String indicating the pathname of the directory in which the Server
* will be ran.
* @return this Builder instance.
@@ -2266,6 +2261,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
}
+
/**
* Sets a GemFire Distributed System Property.
*
@@ -2347,7 +2343,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
* user must specify the member name for the Server in the GemFire distributed system as a
* command-line argument, or by setting the memberName property programmatically using the
* corresponding setter method.
- *
+ *
* @throws IllegalStateException if the Builder is not properly configured.
*/
protected void validate() {
@@ -2360,7 +2356,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Validates the arguments passed to the Builder when the 'start' command has been issued.
- *
+ *
* @see org.apache.geode.distributed.ServerLauncher.Command#START
*/
void validateOnStart() {
@@ -2384,7 +2380,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Validates the arguments passed to the Builder when the 'status' command has been issued.
- *
+ *
* @see org.apache.geode.distributed.ServerLauncher.Command#STATUS
*/
void validateOnStatus() {
@@ -2395,7 +2391,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Validates the arguments passed to the Builder when the 'stop' command has been issued.
- *
+ *
* @see org.apache.geode.distributed.ServerLauncher.Command#STOP
*/
void validateOnStop() {
@@ -2407,7 +2403,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Validates the Builder configuration settings and then constructs an instance of the
* ServerLauncher class to invoke operations on a GemFire Server.
- *
+ *
* @return a newly constructed instance of the ServerLauncher configured with this Builder.
* @see #validate()
* @see org.apache.geode.distributed.ServerLauncher
@@ -2437,13 +2433,13 @@ public class ServerLauncher extends AbstractLauncher<String> {
assert isNotBlank(name) : "The name of the command must be specified!";
this.name = name;
this.options = options != null ? Collections.unmodifiableList(Arrays.asList(options))
- : Collections.emptyList();
+ : Collections.<String>emptyList();
}
/**
* Determines whether the specified name refers to a valid Server launcher command, as defined
* by this enumerated type.
- *
+ *
* @param name a String value indicating the potential name of a Server launcher command.
* @return a boolean indicating whether the specified name for a Server launcher command is
* valid.
@@ -2455,7 +2451,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Determines whether the given Server launcher command has been properly specified. The command
* is deemed unspecified if the reference is null or the Command is UNSPECIFIED.
- *
+ *
* @param command the Server launcher command.
* @return a boolean value indicating whether the Server launcher command is unspecified.
* @see Command#UNSPECIFIED
@@ -2467,7 +2463,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Looks up a Server launcher command by name. The equality comparison on name is
* case-insensitive.
- *
+ *
* @param name a String value indicating the name of the Server launcher command.
* @return an enumerated type representing the command name or null if the no such command with
* the specified name exists.
@@ -2484,7 +2480,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Gets the name of the Server launcher command.
- *
+ *
* @return a String value indicating the name of the Server launcher command.
*/
public String getName() {
@@ -2494,7 +2490,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Gets a set of valid options that can be used with the Server launcher command when used from
* the command-line.
- *
+ *
* @return a Set of Strings indicating the names of the options available to the Server launcher
* command.
*/
@@ -2504,7 +2500,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Determines whether this Server launcher command has the specified command-line option.
- *
+ *
* @param option a String indicating the name of the command-line option to this command.
* @return a boolean value indicating whether this command has the specified named command-line
* option.
@@ -2515,7 +2511,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Convenience method for determining whether this is the UNSPECIFIED Server launcher command.
- *
+ *
* @return a boolean indicating if this command is UNSPECIFIED.
* @see #UNSPECIFIED
*/
@@ -2525,7 +2521,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
/**
* Gets the String representation of this Server launcher command.
- *
+ *
* @return a String value representing this Server launcher command.
*/
@Override
@@ -2538,14 +2534,14 @@ public class ServerLauncher extends AbstractLauncher<String> {
* The ServerState is an immutable type representing the state of the specified Server at any
* given moment in time. The state of the Server is assessed at the exact moment an instance of
* this class is constructed.
- *
+ *
* @see org.apache.geode.distributed.AbstractLauncher.ServiceState
*/
public static class ServerState extends ServiceState<String> {
/**
* Unmarshals a ServerState instance from the JSON String.
- *
+ *
* @return a ServerState value unmarshalled from the JSON String.
*/
public static ServerState fromJson(final String json) {
@@ -2596,35 +2592,20 @@ public class ServerLauncher extends AbstractLauncher<String> {
this(status, // status
errorMessage, // statusMessage
System.currentTimeMillis(), // timestamp
- getServerLocation(launcher), // serverLocation
+ null, // serverLocation
null, // pid
0L, // uptime
launcher.getWorkingDirectory(), // workingDirectory
- ManagementFactory.getRuntimeMXBean().getInputArguments(), // jvmArguments
+ Collections.<String>emptyList(), // jvmArguments
null, // classpath
GemFireVersion.getGemFireVersion(), // gemfireVersion
- System.getProperty("java.version"), // javaVersion
+ null, // javaVersion
null, // logFile
- getServerBindAddress(launcher).getCanonicalHostName(), // host
- launcher.getServerPortAsString(), // port
+ null, // host
+ null, // port
null);// memberName
}
- /*
- * Guards against throwing NPEs due to incorrect or missing host information while constructing
- * error states
- */
- private static String getServerLocation(ServerLauncher launcher) {
- if (launcher.getServerPort() == null) {
- return launcher.getId();
- }
- if (launcher.getServerBindAddress() == null) {
- return HostUtils.getLocatorId(HostUtils.getLocalHost(), launcher.getServerPort());
- }
- return HostUtils.getLocatorId(launcher.getServerBindAddress().getCanonicalHostName(),
- launcher.getServerPort());
- }
-
protected ServerState(final Status status, final String statusMessage, final long timestamp,
final String serverLocation, final Integer pid, final Long uptime,
final String workingDirectory, final List<String> jvmArguments, final String classpath,
@@ -2646,6 +2627,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
}
}
}
+
return launcher.getLogFileCanonicalPath();
}
@@ -2663,28 +2645,8 @@ public class ServerLauncher extends AbstractLauncher<String> {
}
}
}
- return launcher.getServerBindAddressAsString();
- }
-
- private static InetAddress getServerBindAddress(final ServerLauncher launcher) {
- final InternalCache internalCache = GemFireCacheImpl.getInstance();
- if (internalCache != null) {
- final List<CacheServer> csList = internalCache.getCacheServers();
- if (csList != null && !csList.isEmpty()) {
- final CacheServer cs = csList.get(0);
- final InetAddress serverBindAddress;
- try {
- serverBindAddress = InetAddress.getByName(cs.getBindAddress());
- } catch (UnknownHostException e) {
- throw new UncheckedIOException(e);
- }
- if (serverBindAddress != null) {
- return serverBindAddress;
- }
- }
- }
- return launcher.getServerBindAddress();
+ return launcher.getServerBindAddressAsString();
}
@SuppressWarnings("unchecked")
@@ -2701,6 +2663,7 @@ public class ServerLauncher extends AbstractLauncher<String> {
}
}
}
+
return launcher.isDisableDefaultServer() ? EMPTY : launcher.getServerPortAsString();
}
@@ -2709,4 +2672,5 @@ public class ServerLauncher extends AbstractLauncher<String> {
return SERVER_SERVICE_NAME;
}
}
+
}