You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2017/03/10 00:32:43 UTC
[3/3] geode git commit: Remove Attach API usage from AbstractLauncher
Remove Attach API usage from AbstractLauncher
Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/568b49b4
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/568b49b4
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/568b49b4
Branch: refs/heads/feature/GEODE-2594
Commit: 568b49b499e59e7345040e39a1680a9360fb5487
Parents: 38cf13f
Author: Kirk Lund <kl...@apache.org>
Authored: Wed Mar 8 14:13:14 2017 -0800
Committer: Kirk Lund <kl...@apache.org>
Committed: Thu Mar 9 16:32:24 2017 -0800
----------------------------------------------------------------------
geode-assembly/src/main/dist/bin/gfsh | 14 -
geode-assembly/src/main/dist/bin/gfsh.bat | 8 -
...auncherLifecycleCommandsIntegrationTest.java | 4 +-
.../LauncherLifecycleCommandsJUnitTest.java | 647 -------------------
.../commands/LauncherLifecycleCommandsTest.java | 647 +++++++++++++++++++
.../geode/distributed/AbstractLauncher.java | 62 +-
.../cli/commands/LauncherLifecycleCommands.java | 58 +-
.../internal/cli/i18n/CliStrings.java | 9 +-
.../geode/distributed/AbstractLauncherTest.java | 33 +-
.../commands/HelpCommandsIntegrationTest.java | 3 +-
.../cli/commands/golden-help-offline.properties | 12 +-
11 files changed, 672 insertions(+), 825 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/geode/blob/568b49b4/geode-assembly/src/main/dist/bin/gfsh
----------------------------------------------------------------------
diff --git a/geode-assembly/src/main/dist/bin/gfsh b/geode-assembly/src/main/dist/bin/gfsh
index 309723e..51533c3 100755
--- a/geode-assembly/src/main/dist/bin/gfsh
+++ b/geode-assembly/src/main/dist/bin/gfsh
@@ -110,20 +110,6 @@ if [ "x$GF_JAVA_PATH" == "x" ]; then
echo "ERROR: Could not find java executable in the path. Please set JAVA_HOME to point to the JDK directory or point GF_JAVA to java executable from JDK."
exit 1
fi
-GF_JAVA_PARENT=`dirname "$GF_JAVA_PATH"`
-GF_JAVA_PARENT=`dirname "$GF_JAVA_PARENT"`
-TOOLS_JAR="$GF_JAVA_PARENT/lib/tools.jar"
-if [ ! -f "$TOOLS_JAR" ]; then
- # Now consider java is from JRE in JDK
- TOOLS_JAR="$GF_JAVA_PARENT/../lib/tools.jar"
- if [ ! -f "$TOOLS_JAR" ]; then
- TOOLS_JAR=
- fi
-fi
-
-if [ "x$TOOLS_JAR" != "x" ]; then
- CLASSPATH="$CLASSPATH:$TOOLS_JAR"
-fi
if [ "${UNAME}" = "cygwin" ]; then
CLASSPATH=$( cygpath -w -p "$CLASSPATH" )
http://git-wip-us.apache.org/repos/asf/geode/blob/568b49b4/geode-assembly/src/main/dist/bin/gfsh.bat
----------------------------------------------------------------------
diff --git a/geode-assembly/src/main/dist/bin/gfsh.bat b/geode-assembly/src/main/dist/bin/gfsh.bat
index 5a40141..b55ffd7 100755
--- a/geode-assembly/src/main/dist/bin/gfsh.bat
+++ b/geode-assembly/src/main/dist/bin/gfsh.bat
@@ -68,14 +68,6 @@ REM @if not exist "%USERPROFILE%\.gemfire" (
REM @mkdir "%USERPROFILE%\.gemfire"
REM )
-REM Expect to find the tools.jar from the JDK
-@set TOOLS_JAR=%JAVA_HOME%\lib\tools.jar
-@IF EXIST "%TOOLS_JAR%" (
- @set DEPENDENCIES=%DEPENDENCIES%;%TOOLS_JAR%
-) ELSE (
- set TOOLS_JAR=
-)
-
@set LAUNCHER=org.apache.geode.management.internal.cli.Launcher
@if defined JAVA_ARGS (
@set JAVA_ARGS="%JAVA_ARGS%"
http://git-wip-us.apache.org/repos/asf/geode/blob/568b49b4/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsIntegrationTest.java b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsIntegrationTest.java
index 1872a84..b51505a 100644
--- a/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsIntegrationTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsIntegrationTest.java
@@ -40,8 +40,8 @@ import org.apache.geode.internal.util.IOUtils;
import org.apache.geode.test.junit.categories.IntegrationTest;
/**
- * The LauncherLifecycleCommandsJUnitTest class is a test suite of test cases testing the contract
- * and functionality of the lifecycle launcher GemFire shell (Gfsh) commands.
+ * The LauncherLifecycleCommandsIntegrationTest class is a test suite of test cases testing the
+ * contract and functionality of the lifecycle launcher GemFire shell (Gfsh) commands.
*
* @see org.apache.geode.management.internal.cli.commands.LauncherLifecycleCommands
* @see org.junit.Assert
http://git-wip-us.apache.org/repos/asf/geode/blob/568b49b4/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsJUnitTest.java b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsJUnitTest.java
deleted file mode 100755
index 947da42..0000000
--- a/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsJUnitTest.java
+++ /dev/null
@@ -1,647 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.management.internal.cli.commands;
-
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-import java.util.Stack;
-
-import org.apache.geode.distributed.LocatorLauncher;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.GemFireException;
-import org.apache.geode.cache.server.CacheServer;
-import org.apache.geode.distributed.ServerLauncher;
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.internal.DistributionLocator;
-import org.apache.geode.internal.lang.StringUtils;
-import org.apache.geode.internal.lang.SystemUtils;
-import org.apache.geode.internal.util.IOUtils;
-import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.test.junit.categories.UnitTest;
-
-/**
- * The LauncherLifecycleCommandsJUnitTest class is a test suite of test cases testing the contract
- * and functionality of the lifecycle launcher GemFire shell (Gfsh) commands.
- *
- * @see org.apache.geode.management.internal.cli.commands.LauncherLifecycleCommands
- * @see org.junit.Assert
- * @see org.junit.Test
- * @since GemFire 7.0
- */
-@Category(UnitTest.class)
-@SuppressWarnings("unused")
-public class LauncherLifecycleCommandsJUnitTest {
-
- private LauncherLifecycleCommands launcherCommands;
-
- @Before
- public void setup() {
- launcherCommands = new LauncherLifecycleCommands();
- }
-
- @After
- public void tearDown() {
- launcherCommands = null;
- }
-
- @Test
- public void testAddGemFirePropertyFileToCommandLine() {
- final List<String> commandLine = new ArrayList<>();
-
- assertTrue(commandLine.isEmpty());
-
- getLauncherLifecycleCommands().addGemFirePropertyFile(commandLine, null);
-
- assertTrue(commandLine.isEmpty());
-
- getLauncherLifecycleCommands().addGemFirePropertyFile(commandLine, StringUtils.EMPTY_STRING);
-
- assertTrue(commandLine.isEmpty());
-
- getLauncherLifecycleCommands().addGemFirePropertyFile(commandLine, " ");
-
- assertTrue(commandLine.isEmpty());
-
- getLauncherLifecycleCommands().addGemFirePropertyFile(commandLine,
- "/path/to/gemfire.properties");
-
- assertFalse(commandLine.isEmpty());
- assertTrue(commandLine.contains("-DgemfirePropertyFile=/path/to/gemfire.properties"));
- }
-
- @Test
- public void testAddGemFireSystemPropertiesToCommandLine() {
- final List<String> commandLine = new ArrayList<>();
-
- assertTrue(commandLine.isEmpty());
-
- getLauncherLifecycleCommands().addGemFireSystemProperties(commandLine, new Properties());
-
- assertTrue(commandLine.isEmpty());
-
- final Properties gemfireProperties = new Properties();
-
- gemfireProperties.setProperty(LOCATORS, "localhost[11235]");
- gemfireProperties.setProperty(LOG_LEVEL, "config");
- gemfireProperties.setProperty(LOG_FILE, StringUtils.EMPTY_STRING);
- gemfireProperties.setProperty(MCAST_PORT, "0");
- gemfireProperties.setProperty(NAME, "machine");
-
- getLauncherLifecycleCommands().addGemFireSystemProperties(commandLine, gemfireProperties);
-
- assertFalse(commandLine.isEmpty());
- assertEquals(4, commandLine.size());
-
- for (final String propertyName : gemfireProperties.stringPropertyNames()) {
- final String propertyValue = gemfireProperties.getProperty(propertyName);
- if (StringUtils.isBlank(propertyValue)) {
- for (final String systemProperty : commandLine) {
- assertFalse(systemProperty.startsWith(
- "-D" + DistributionConfig.GEMFIRE_PREFIX + "".concat(propertyName).concat("=")));
- }
- } else {
- assertTrue(commandLine.contains("-D" + DistributionConfig.GEMFIRE_PREFIX
- + "".concat(propertyName).concat("=").concat(propertyValue)));
- }
- }
- }
-
-
- @Test
- public void testAddGemFireSystemPropertiesToCommandLineWithRestAPI() {
- final List<String> commandLine = new ArrayList<>();
-
- assertTrue(commandLine.isEmpty());
-
- getLauncherLifecycleCommands().addGemFireSystemProperties(commandLine, new Properties());
-
- assertTrue(commandLine.isEmpty());
-
- final Properties gemfireProperties = new Properties();
-
- gemfireProperties.setProperty(LOCATORS, "localhost[11235]");
- gemfireProperties.setProperty(LOG_LEVEL, "config");
- gemfireProperties.setProperty(LOG_FILE, StringUtils.EMPTY_STRING);
- gemfireProperties.setProperty(MCAST_PORT, "0");
- gemfireProperties.setProperty(NAME, "machine");
-
- gemfireProperties.setProperty(START_DEV_REST_API, "true");
- gemfireProperties.setProperty(HTTP_SERVICE_PORT, "8080");
- gemfireProperties.setProperty(HTTP_SERVICE_BIND_ADDRESS, "localhost");
-
-
- getLauncherLifecycleCommands().addGemFireSystemProperties(commandLine, gemfireProperties);
-
- assertFalse(commandLine.isEmpty());
- assertEquals(7, commandLine.size());
-
- for (final String propertyName : gemfireProperties.stringPropertyNames()) {
- final String propertyValue = gemfireProperties.getProperty(propertyName);
- if (StringUtils.isBlank(propertyValue)) {
- for (final String systemProperty : commandLine) {
- assertFalse(systemProperty.startsWith(
- "-D" + DistributionConfig.GEMFIRE_PREFIX + "".concat(propertyName).concat("=")));
- }
- } else {
- assertTrue(commandLine.contains("-D" + DistributionConfig.GEMFIRE_PREFIX
- + "".concat(propertyName).concat("=").concat(propertyValue)));
- }
- }
- }
-
- @Test
- public void testAddInitialHeapToCommandLine() {
- final List<String> commandLine = new ArrayList<>();
-
- assertTrue(commandLine.isEmpty());
-
- getLauncherLifecycleCommands().addInitialHeap(commandLine, null);
-
- assertTrue(commandLine.isEmpty());
-
- getLauncherLifecycleCommands().addInitialHeap(commandLine, StringUtils.EMPTY_STRING);
-
- assertTrue(commandLine.isEmpty());
-
- getLauncherLifecycleCommands().addInitialHeap(commandLine, " ");
-
- assertTrue(commandLine.isEmpty());
-
- getLauncherLifecycleCommands().addInitialHeap(commandLine, "512M");
-
- assertFalse(commandLine.isEmpty());
- assertEquals("-Xms512M", commandLine.get(0));
- }
-
- @Test
- public void testAddJvmArgumentsAndOptionsToCommandLine() {
- final List<String> commandLine = new ArrayList<>();
-
- assertTrue(commandLine.isEmpty());
-
- getLauncherLifecycleCommands().addJvmArgumentsAndOptions(commandLine, null);
-
- assertTrue(commandLine.isEmpty());
-
- getLauncherLifecycleCommands().addJvmArgumentsAndOptions(commandLine, new String[] {});
-
- assertTrue(commandLine.isEmpty());
-
- getLauncherLifecycleCommands().addJvmArgumentsAndOptions(commandLine,
- new String[] {"-DmyProp=myVal", "-d64", "-server", "-Xprof"});
-
- assertFalse(commandLine.isEmpty());
- assertEquals(4, commandLine.size());
- assertEquals("-DmyProp=myVal", commandLine.get(0));
- assertEquals("-d64", commandLine.get(1));
- assertEquals("-server", commandLine.get(2));
- assertEquals("-Xprof", commandLine.get(3));
- }
-
- // Fix for Bug #47192 - "Making GemFire (JVM) to exit in case of OutOfMemory"
- @Test
- public void testAddJvmOptionsForOutOfMemoryErrors() {
- final List<String> jvmOptions = new ArrayList<>(1);
-
- getLauncherLifecycleCommands().addJvmOptionsForOutOfMemoryErrors(jvmOptions);
-
- if (SystemUtils.isHotSpotVM()) {
- if (SystemUtils.isWindows()) {
- assertTrue(jvmOptions.contains("-XX:OnOutOfMemoryError=taskkill /F /PID %p"));
- } else {
- assertTrue(jvmOptions.contains("-XX:OnOutOfMemoryError=kill -KILL %p"));
- }
- } else if (SystemUtils.isJ9VM()) {
- assertEquals(1, jvmOptions.size());
- assertTrue(jvmOptions.contains("-Xcheck:memory"));
- } else if (SystemUtils.isJRockitVM()) {
- assertEquals(1, jvmOptions.size());
- assertTrue(jvmOptions.contains("-XXexitOnOutOfMemory"));
- } else {
- assertTrue(jvmOptions.isEmpty());
- }
- }
-
- @Test
- public void testAddMaxHeapToCommandLine() {
- final List<String> commandLine = new ArrayList<>();
-
- assertTrue(commandLine.isEmpty());
-
- getLauncherLifecycleCommands().addMaxHeap(commandLine, null);
-
- assertTrue(commandLine.isEmpty());
-
- getLauncherLifecycleCommands().addMaxHeap(commandLine, StringUtils.EMPTY_STRING);
-
- assertTrue(commandLine.isEmpty());
-
- getLauncherLifecycleCommands().addMaxHeap(commandLine, " ");
-
- assertTrue(commandLine.isEmpty());
-
- getLauncherLifecycleCommands().addMaxHeap(commandLine, "1024M");
-
- assertFalse(commandLine.isEmpty());
- assertEquals(3, commandLine.size());
- assertEquals("-Xmx1024M", commandLine.get(0));
- assertEquals("-XX:+UseConcMarkSweepGC", commandLine.get(1));
- assertEquals("-XX:CMSInitiatingOccupancyFraction="
- + LauncherLifecycleCommands.CMS_INITIAL_OCCUPANCY_FRACTION, commandLine.get(2));
- }
-
- @Test(expected = AssertionError.class)
- public void testReadPidWithNull() {
- try {
- getLauncherLifecycleCommands().readPid(null);
- } catch (AssertionError expected) {
- assertEquals("The file from which to read the process ID (pid) cannot be null!",
- expected.getMessage());
- throw expected;
- }
- }
-
- @Test
- @SuppressWarnings("deprecation")
- public void testGetClasspath() {
- assertEquals(System.getProperty("java.class.path"),
- getLauncherLifecycleCommands().getClasspath(null));
- }
-
- @Test
- @SuppressWarnings("deprecation")
- public void testGetClasspathWithUserDefinedClasspath() {
- assertEquals(
- System.getProperty("java.class.path") + File.pathSeparator + "/path/to/user/classes",
- getLauncherLifecycleCommands().getClasspath("/path/to/user/classes"));
- }
-
- @Test
- public void testGetSystemClasspath() {
- assertEquals(System.getProperty("java.class.path"),
- getLauncherLifecycleCommands().getSystemClasspath());
- }
-
- @Test
- public void testLocatorClasspathOrder() {
- String userClasspath = "/path/to/user/lib/app.jar:/path/to/user/classes";
-
- String expectedClasspath = launcherCommands.getGemFireJarPath().concat(File.pathSeparator)
- .concat(userClasspath).concat(File.pathSeparator)
- .concat(System.getProperty("java.class.path")).concat(File.pathSeparator)
- .concat(LauncherLifecycleCommands.CORE_DEPENDENCIES_JAR_PATHNAME);
-
- String actualClasspath = launcherCommands.getLocatorClasspath(true, userClasspath);
-
- assertEquals(expectedClasspath, actualClasspath);
- }
-
- @Test
- public void testServerClasspathOrder() {
- String userClasspath = "/path/to/user/lib/app.jar:/path/to/user/classes";
-
- String expectedClasspath = launcherCommands.getGemFireJarPath().concat(File.pathSeparator)
- .concat(userClasspath).concat(File.pathSeparator)
- .concat(LauncherLifecycleCommands.CORE_DEPENDENCIES_JAR_PATHNAME);
-
- String actualClasspath = launcherCommands.getServerClasspath(false, userClasspath);
-
- assertEquals(expectedClasspath, actualClasspath);
- }
-
- @Test
- public void testToClasspath() {
- final boolean EXCLUDE_SYSTEM_CLASSPATH = false;
- final boolean INCLUDE_SYSTEM_CLASSPATH = true;
-
- String[] jarFilePathnames =
- {"/path/to/user/libs/A.jar", "/path/to/user/libs/B.jar", "/path/to/user/libs/C.jar"};
-
- String[] userClasspaths = {"/path/to/classes:/path/to/libs/1.jar:/path/to/libs/2.jar",
- "/path/to/ext/libs/1.jar:/path/to/ext/classes:/path/to/ext/lib/10.jar"};
-
- String expectedClasspath = LauncherLifecycleCommands.GEODE_JAR_PATHNAME
- .concat(File.pathSeparator).concat(toClasspath(userClasspaths)).concat(File.pathSeparator)
- .concat(toClasspath(jarFilePathnames));
-
- assertEquals(expectedClasspath, getLauncherLifecycleCommands()
- .toClasspath(EXCLUDE_SYSTEM_CLASSPATH, jarFilePathnames, userClasspaths));
-
- expectedClasspath = LauncherLifecycleCommands.GEODE_JAR_PATHNAME.concat(File.pathSeparator)
- .concat(toClasspath(userClasspaths)).concat(File.pathSeparator)
- .concat(System.getProperty("java.class.path")).concat(File.pathSeparator)
- .concat(toClasspath(jarFilePathnames));
-
- assertEquals(expectedClasspath, getLauncherLifecycleCommands()
- .toClasspath(INCLUDE_SYSTEM_CLASSPATH, jarFilePathnames, userClasspaths));
-
- expectedClasspath = LauncherLifecycleCommands.GEODE_JAR_PATHNAME.concat(File.pathSeparator)
- .concat(System.getProperty("java.class.path"));
-
- assertEquals(expectedClasspath, getLauncherLifecycleCommands()
- .toClasspath(INCLUDE_SYSTEM_CLASSPATH, null, (String[]) null));
-
- assertEquals(LauncherLifecycleCommands.GEODE_JAR_PATHNAME, getLauncherLifecycleCommands()
- .toClasspath(EXCLUDE_SYSTEM_CLASSPATH, null, (String[]) null));
-
- assertEquals(LauncherLifecycleCommands.GEODE_JAR_PATHNAME,
- getLauncherLifecycleCommands().toClasspath(EXCLUDE_SYSTEM_CLASSPATH, new String[0], ""));
- }
-
- @Test
- public void testToClassPathOrder() {
- String userClasspathOne = "/path/to/user/lib/a.jar:/path/to/user/classes";
- String userClasspathTwo =
- "/path/to/user/lib/x.jar:/path/to/user/lib/y.jar:/path/to/user/lib/z.jar";
-
- String expectedClasspath = launcherCommands.getGemFireJarPath().concat(File.pathSeparator)
- .concat(userClasspathOne).concat(File.pathSeparator).concat(userClasspathTwo)
- .concat(File.pathSeparator).concat(System.getProperty("java.class.path"))
- .concat(File.pathSeparator).concat(LauncherLifecycleCommands.CORE_DEPENDENCIES_JAR_PATHNAME)
- .concat(File.pathSeparator)
- .concat(LauncherLifecycleCommands.CORE_DEPENDENCIES_JAR_PATHNAME);
-
- String actualClasspath = launcherCommands.toClasspath(true,
- new String[] {LauncherLifecycleCommands.CORE_DEPENDENCIES_JAR_PATHNAME,
- LauncherLifecycleCommands.CORE_DEPENDENCIES_JAR_PATHNAME},
- userClasspathOne, userClasspathTwo);
-
- assertEquals(expectedClasspath, actualClasspath);
- }
-
- @Test
- public void testGetJavaPathname() {
- assertEquals(
- IOUtils.appendToPath(System.getProperty("java.home"), "bin",
- "java" + LauncherLifecycleCommands.getExecutableSuffix()),
- getLauncherLifecycleCommands().getJdkToolPathname(
- "java" + LauncherLifecycleCommands.getExecutableSuffix(), new GemFireException() {}));
- }
-
- @Test(expected = NullPointerException.class)
- public void testGetJdkToolPathnameWithNullPathnames() {
- try {
- getLauncherLifecycleCommands().getJdkToolPathname((Stack<String>) null,
- new GemFireException() {});
- } catch (NullPointerException expected) {
- assertEquals("The JDK tool executable pathnames cannot be null!", expected.getMessage());
- throw expected;
- }
- }
-
- @Test(expected = NullPointerException.class)
- public void testGetJdkToolPathnameWithNullGemFireException() {
- try {
- getLauncherLifecycleCommands().getJdkToolPathname(new Stack<String>(), null);
- } catch (NullPointerException expected) {
- assertEquals("The GemFireException cannot be null!", expected.getMessage());
- throw expected;
- }
- }
-
- @Test
- public void testGetJdkToolPathnameForNonExistingTool() {
- try {
- final GemFireException expected = new GemFireException() {
- @Override
- public String getMessage() {
- return "expected";
- }
- };
-
- getLauncherLifecycleCommands().getJdkToolPathname("nonExistingTool.exe", expected);
- } catch (GemFireException expected) {
- assertEquals("expected", expected.getMessage());
- }
- }
-
- @Test
- public void testGetLocatorId() {
- assertEquals("machine[11235]", getLauncherLifecycleCommands().getLocatorId("machine", 11235));
- assertEquals("machine.domain.org[11235]",
- getLauncherLifecycleCommands().getLocatorId("machine.domain.org", 11235));
- assertEquals("machine[" + DistributionLocator.DEFAULT_LOCATOR_PORT + "]",
- getLauncherLifecycleCommands().getLocatorId("machine", null));
- }
-
- @Test
- public void testGetServerId() {
- assertEquals("machine[12480]", getLauncherLifecycleCommands().getServerId("machine", 12480));
- assertEquals("machine.domain.org[12480]",
- getLauncherLifecycleCommands().getServerId("machine.domain.org", 12480));
- assertEquals("machine[" + CacheServer.DEFAULT_PORT + "]",
- getLauncherLifecycleCommands().getServerId("machine", null));
- }
-
- @Test
- public void testCreateJmxServerUrlWithMemberName() {
- assertEquals("service:jmx:rmi://localhost:8192/jndi/rmi://localhost:8192/jmxrmi",
- getLauncherLifecycleCommands().getJmxServiceUrlAsString("localhost[8192]"));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCreateJmxServiceUrlWithInvalidMemberName() {
- try {
- System.err.println(getLauncherLifecycleCommands().getJmxServiceUrlAsString("memberOne[]"));
- } catch (IllegalArgumentException expected) {
- assertEquals(CliStrings.START_JCONSOLE__CONNECT_BY_MEMBER_NAME_ID_ERROR_MESSAGE,
- expected.getMessage());
- throw expected;
- }
- }
-
- @Test
- public void testCreateServerCommandLine() throws Exception {
- ServerLauncher serverLauncher = new ServerLauncher.Builder()
- .setCommand(ServerLauncher.Command.START).setDisableDefaultServer(true)
- .setMemberName("testCreateServerCommandLine").setRebalance(true)
- // .setServerBindAddress("localhost")
- .setServerPort(41214).setCriticalHeapPercentage(95.5f).setEvictionHeapPercentage(85.0f)
- .setSocketBufferSize(1024 * 1024).setMessageTimeToLive(93).build();
-
- String[] commandLineElements = launcherCommands.createStartServerCommandLine(serverLauncher,
- null, null, new Properties(), null, false, new String[0], false, null, null);
-
- assertNotNull(commandLineElements);
- assertTrue(commandLineElements.length > 0);
-
- Set<String> expectedCommandLineElements = new HashSet<>(6);
-
- expectedCommandLineElements.add(serverLauncher.getCommand().getName());
- expectedCommandLineElements.add("--disable-default-server");
- expectedCommandLineElements.add(serverLauncher.getMemberName().toLowerCase());
- expectedCommandLineElements.add("--rebalance");
- // expectedCommandLineElements.add(String.format("--server-bind-address=%1$s",
- // serverLauncher.getServerBindAddress().getHostName()));
- expectedCommandLineElements
- .add(String.format("--server-port=%1$d", serverLauncher.getServerPort()));
- expectedCommandLineElements.add(String.format("--critical-heap-percentage=%1$s",
- serverLauncher.getCriticalHeapPercentage()));
- expectedCommandLineElements.add(String.format("--eviction-heap-percentage=%1$s",
- serverLauncher.getEvictionHeapPercentage()));
- expectedCommandLineElements
- .add(String.format("--socket-buffer-size=%1$d", serverLauncher.getSocketBufferSize()));
- expectedCommandLineElements
- .add(String.format("--message-time-to-live=%1$d", serverLauncher.getMessageTimeToLive()));
-
- for (String commandLineElement : commandLineElements) {
- expectedCommandLineElements.remove(commandLineElement.toLowerCase());
- }
-
- assertTrue(String.format("Expected ([]); but was (%1$s)", expectedCommandLineElements),
- expectedCommandLineElements.isEmpty());
- }
-
- @Test
- public void testCreateServerCommandLineWithRestAPI() throws Exception {
- ServerLauncher serverLauncher = new ServerLauncher.Builder()
- .setCommand(ServerLauncher.Command.START).setDisableDefaultServer(true)
- .setMemberName("testCreateServerCommandLine").setRebalance(true)
- // .setServerBindAddress("localhost")
- .setServerPort(41214).setCriticalHeapPercentage(95.5f).setEvictionHeapPercentage(85.0f)
- .build();
-
- Properties gemfireProperties = new Properties();
- gemfireProperties.setProperty(START_DEV_REST_API, "true");
- gemfireProperties.setProperty(HTTP_SERVICE_PORT, "8080");
- gemfireProperties.setProperty(HTTP_SERVICE_BIND_ADDRESS, "localhost");
-
-
- String[] commandLineElements = launcherCommands.createStartServerCommandLine(serverLauncher,
- null, null, gemfireProperties, null, false, new String[0], false, null, null);
-
- assertNotNull(commandLineElements);
- assertTrue(commandLineElements.length > 0);
-
- Set<String> expectedCommandLineElements = new HashSet<>(6);
-
- expectedCommandLineElements.add(serverLauncher.getCommand().getName());
- expectedCommandLineElements.add("--disable-default-server");
- expectedCommandLineElements.add(serverLauncher.getMemberName().toLowerCase());
- expectedCommandLineElements.add("--rebalance");
- // expectedCommandLineElements.add(String.format("--server-bind-address=%1$s",
- // serverLauncher.getServerBindAddress().getHostName()));
- expectedCommandLineElements
- .add(String.format("--server-port=%1$d", serverLauncher.getServerPort()));
- expectedCommandLineElements.add(String.format("--critical-heap-percentage=%1$s",
- serverLauncher.getCriticalHeapPercentage()));
- expectedCommandLineElements.add(String.format("--eviction-heap-percentage=%1$s",
- serverLauncher.getEvictionHeapPercentage()));
-
- expectedCommandLineElements
- .add("-d" + DistributionConfig.GEMFIRE_PREFIX + "" + START_DEV_REST_API + "=" + "true");
- expectedCommandLineElements
- .add("-d" + DistributionConfig.GEMFIRE_PREFIX + "" + HTTP_SERVICE_PORT + "=" + "8080");
- expectedCommandLineElements.add("-d" + DistributionConfig.GEMFIRE_PREFIX + ""
- + HTTP_SERVICE_BIND_ADDRESS + "=" + "localhost");
-
-
- for (String commandLineElement : commandLineElements) {
- expectedCommandLineElements.remove(commandLineElement.toLowerCase());
- }
-
- assertTrue(String.format("Expected ([]); but was (%1$s)", expectedCommandLineElements),
- expectedCommandLineElements.isEmpty());
- }
-
- /**
- * Verify commandline parameters passed for starting locator
- *
- * @throws Exception
- */
- @Test
- public void testLocatorCommandLineWithRestAPI() throws Exception {
- LocatorLauncher locatorLauncher =
- new LocatorLauncher.Builder().setCommand(LocatorLauncher.Command.START)
- .setMemberName("testLocatorCommandLineWithRestAPI").setBindAddress("localhost")
- .setPort(11111).build();
-
- Properties gemfireProperties = new Properties();
- gemfireProperties.setProperty(HTTP_SERVICE_PORT, "8089");
- gemfireProperties.setProperty(HTTP_SERVICE_BIND_ADDRESS, "localhost");
-
-
- String[] commandLineElements = launcherCommands.createStartLocatorCommandLine(locatorLauncher,
- null, null, gemfireProperties, null, false, new String[0], null, null);
-
- assertNotNull(commandLineElements);
- assertTrue(commandLineElements.length > 0);
-
- Set<String> expectedCommandLineElements = new HashSet<>(6);
-
- expectedCommandLineElements.add(locatorLauncher.getCommand().getName());
- expectedCommandLineElements.add(locatorLauncher.getMemberName().toLowerCase());
- expectedCommandLineElements.add(String.format("--port=%1$d", locatorLauncher.getPort()));
- expectedCommandLineElements
- .add("-d" + DistributionConfig.GEMFIRE_PREFIX + "" + HTTP_SERVICE_PORT + "=" + "8089");
- expectedCommandLineElements.add("-d" + DistributionConfig.GEMFIRE_PREFIX + ""
- + HTTP_SERVICE_BIND_ADDRESS + "=" + "localhost");
-
-
- for (String commandLineElement : commandLineElements) {
- expectedCommandLineElements.remove(commandLineElement.toLowerCase());
- }
-
- assertTrue(String.format("Expected ([]); but was (%1$s)", expectedCommandLineElements),
- expectedCommandLineElements.isEmpty());
- }
-
-
- @Test
- public void testReadPidWithNonExistingFile() {
- assertEquals(LauncherLifecycleCommands.INVALID_PID,
- getLauncherLifecycleCommands().readPid(new File("/path/to/non_existing/pid.file")));
- }
-
- private LauncherLifecycleCommands getLauncherLifecycleCommands() {
- return launcherCommands;
- }
-
- private String toClasspath(final String... jarFilePathnames) {
- String classpath = StringUtils.EMPTY_STRING;
-
- if (jarFilePathnames != null) {
- for (final String jarFilePathname : jarFilePathnames) {
- classpath += (classpath.isEmpty() ? StringUtils.EMPTY_STRING : File.pathSeparator);
- classpath += jarFilePathname;
- }
- }
-
- return classpath;
- }
-
- private String toPath(Object... pathElements) {
- String path = "";
-
- for (Object pathElement : pathElements) {
- path += (path.isEmpty() ? StringUtils.EMPTY_STRING : File.pathSeparator);
- path += pathElement;
- }
-
- return path;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/geode/blob/568b49b4/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsTest.java b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsTest.java
new file mode 100755
index 0000000..0554f69
--- /dev/null
+++ b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsTest.java
@@ -0,0 +1,647 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.management.internal.cli.commands;
+
+import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.Stack;
+
+import org.apache.geode.distributed.LocatorLauncher;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.GemFireException;
+import org.apache.geode.cache.server.CacheServer;
+import org.apache.geode.distributed.ServerLauncher;
+import org.apache.geode.distributed.internal.DistributionConfig;
+import org.apache.geode.internal.DistributionLocator;
+import org.apache.geode.internal.lang.StringUtils;
+import org.apache.geode.internal.lang.SystemUtils;
+import org.apache.geode.internal.util.IOUtils;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.test.junit.categories.UnitTest;
+
+/**
+ * The LauncherLifecycleCommandsTest class is a test suite of test cases testing the contract and
+ * functionality of the lifecycle launcher GemFire shell (Gfsh) commands.
+ *
+ * @see org.apache.geode.management.internal.cli.commands.LauncherLifecycleCommands
+ * @see org.junit.Assert
+ * @see org.junit.Test
+ * @since GemFire 7.0
+ */
+@Category(UnitTest.class)
+@SuppressWarnings("unused")
+public class LauncherLifecycleCommandsTest {
+
+ private LauncherLifecycleCommands launcherCommands;
+
+ @Before
+ public void setup() {
+ launcherCommands = new LauncherLifecycleCommands();
+ }
+
+ @After
+ public void tearDown() {
+ launcherCommands = null;
+ }
+
+ @Test
+ public void testAddGemFirePropertyFileToCommandLine() {
+ final List<String> commandLine = new ArrayList<>();
+
+ assertTrue(commandLine.isEmpty());
+
+ getLauncherLifecycleCommands().addGemFirePropertyFile(commandLine, null);
+
+ assertTrue(commandLine.isEmpty());
+
+ getLauncherLifecycleCommands().addGemFirePropertyFile(commandLine, StringUtils.EMPTY_STRING);
+
+ assertTrue(commandLine.isEmpty());
+
+ getLauncherLifecycleCommands().addGemFirePropertyFile(commandLine, " ");
+
+ assertTrue(commandLine.isEmpty());
+
+ getLauncherLifecycleCommands().addGemFirePropertyFile(commandLine,
+ "/path/to/gemfire.properties");
+
+ assertFalse(commandLine.isEmpty());
+ assertTrue(commandLine.contains("-DgemfirePropertyFile=/path/to/gemfire.properties"));
+ }
+
+ @Test
+ public void testAddGemFireSystemPropertiesToCommandLine() {
+ final List<String> commandLine = new ArrayList<>();
+
+ assertTrue(commandLine.isEmpty());
+
+ getLauncherLifecycleCommands().addGemFireSystemProperties(commandLine, new Properties());
+
+ assertTrue(commandLine.isEmpty());
+
+ final Properties gemfireProperties = new Properties();
+
+ gemfireProperties.setProperty(LOCATORS, "localhost[11235]");
+ gemfireProperties.setProperty(LOG_LEVEL, "config");
+ gemfireProperties.setProperty(LOG_FILE, StringUtils.EMPTY_STRING);
+ gemfireProperties.setProperty(MCAST_PORT, "0");
+ gemfireProperties.setProperty(NAME, "machine");
+
+ getLauncherLifecycleCommands().addGemFireSystemProperties(commandLine, gemfireProperties);
+
+ assertFalse(commandLine.isEmpty());
+ assertEquals(4, commandLine.size());
+
+ for (final String propertyName : gemfireProperties.stringPropertyNames()) {
+ final String propertyValue = gemfireProperties.getProperty(propertyName);
+ if (StringUtils.isBlank(propertyValue)) {
+ for (final String systemProperty : commandLine) {
+ assertFalse(systemProperty.startsWith(
+ "-D" + DistributionConfig.GEMFIRE_PREFIX + "".concat(propertyName).concat("=")));
+ }
+ } else {
+ assertTrue(commandLine.contains("-D" + DistributionConfig.GEMFIRE_PREFIX
+ + "".concat(propertyName).concat("=").concat(propertyValue)));
+ }
+ }
+ }
+
+
+ @Test
+ public void testAddGemFireSystemPropertiesToCommandLineWithRestAPI() {
+ final List<String> commandLine = new ArrayList<>();
+
+ assertTrue(commandLine.isEmpty());
+
+ getLauncherLifecycleCommands().addGemFireSystemProperties(commandLine, new Properties());
+
+ assertTrue(commandLine.isEmpty());
+
+ final Properties gemfireProperties = new Properties();
+
+ gemfireProperties.setProperty(LOCATORS, "localhost[11235]");
+ gemfireProperties.setProperty(LOG_LEVEL, "config");
+ gemfireProperties.setProperty(LOG_FILE, StringUtils.EMPTY_STRING);
+ gemfireProperties.setProperty(MCAST_PORT, "0");
+ gemfireProperties.setProperty(NAME, "machine");
+
+ gemfireProperties.setProperty(START_DEV_REST_API, "true");
+ gemfireProperties.setProperty(HTTP_SERVICE_PORT, "8080");
+ gemfireProperties.setProperty(HTTP_SERVICE_BIND_ADDRESS, "localhost");
+
+
+ getLauncherLifecycleCommands().addGemFireSystemProperties(commandLine, gemfireProperties);
+
+ assertFalse(commandLine.isEmpty());
+ assertEquals(7, commandLine.size());
+
+ for (final String propertyName : gemfireProperties.stringPropertyNames()) {
+ final String propertyValue = gemfireProperties.getProperty(propertyName);
+ if (StringUtils.isBlank(propertyValue)) {
+ for (final String systemProperty : commandLine) {
+ assertFalse(systemProperty.startsWith(
+ "-D" + DistributionConfig.GEMFIRE_PREFIX + "".concat(propertyName).concat("=")));
+ }
+ } else {
+ assertTrue(commandLine.contains("-D" + DistributionConfig.GEMFIRE_PREFIX
+ + "".concat(propertyName).concat("=").concat(propertyValue)));
+ }
+ }
+ }
+
+ @Test
+ public void testAddInitialHeapToCommandLine() {
+ final List<String> commandLine = new ArrayList<>();
+
+ assertTrue(commandLine.isEmpty());
+
+ getLauncherLifecycleCommands().addInitialHeap(commandLine, null);
+
+ assertTrue(commandLine.isEmpty());
+
+ getLauncherLifecycleCommands().addInitialHeap(commandLine, StringUtils.EMPTY_STRING);
+
+ assertTrue(commandLine.isEmpty());
+
+ getLauncherLifecycleCommands().addInitialHeap(commandLine, " ");
+
+ assertTrue(commandLine.isEmpty());
+
+ getLauncherLifecycleCommands().addInitialHeap(commandLine, "512M");
+
+ assertFalse(commandLine.isEmpty());
+ assertEquals("-Xms512M", commandLine.get(0));
+ }
+
+ @Test
+ public void testAddJvmArgumentsAndOptionsToCommandLine() {
+ final List<String> commandLine = new ArrayList<>();
+
+ assertTrue(commandLine.isEmpty());
+
+ getLauncherLifecycleCommands().addJvmArgumentsAndOptions(commandLine, null);
+
+ assertTrue(commandLine.isEmpty());
+
+ getLauncherLifecycleCommands().addJvmArgumentsAndOptions(commandLine, new String[] {});
+
+ assertTrue(commandLine.isEmpty());
+
+ getLauncherLifecycleCommands().addJvmArgumentsAndOptions(commandLine,
+ new String[] {"-DmyProp=myVal", "-d64", "-server", "-Xprof"});
+
+ assertFalse(commandLine.isEmpty());
+ assertEquals(4, commandLine.size());
+ assertEquals("-DmyProp=myVal", commandLine.get(0));
+ assertEquals("-d64", commandLine.get(1));
+ assertEquals("-server", commandLine.get(2));
+ assertEquals("-Xprof", commandLine.get(3));
+ }
+
+ // Fix for Bug #47192 - "Making GemFire (JVM) to exit in case of OutOfMemory"
+ @Test
+ public void testAddJvmOptionsForOutOfMemoryErrors() {
+ final List<String> jvmOptions = new ArrayList<>(1);
+
+ getLauncherLifecycleCommands().addJvmOptionsForOutOfMemoryErrors(jvmOptions);
+
+ if (SystemUtils.isHotSpotVM()) {
+ if (SystemUtils.isWindows()) {
+ assertTrue(jvmOptions.contains("-XX:OnOutOfMemoryError=taskkill /F /PID %p"));
+ } else {
+ assertTrue(jvmOptions.contains("-XX:OnOutOfMemoryError=kill -KILL %p"));
+ }
+ } else if (SystemUtils.isJ9VM()) {
+ assertEquals(1, jvmOptions.size());
+ assertTrue(jvmOptions.contains("-Xcheck:memory"));
+ } else if (SystemUtils.isJRockitVM()) {
+ assertEquals(1, jvmOptions.size());
+ assertTrue(jvmOptions.contains("-XXexitOnOutOfMemory"));
+ } else {
+ assertTrue(jvmOptions.isEmpty());
+ }
+ }
+
+ @Test
+ public void testAddMaxHeapToCommandLine() {
+ final List<String> commandLine = new ArrayList<>();
+
+ assertTrue(commandLine.isEmpty());
+
+ getLauncherLifecycleCommands().addMaxHeap(commandLine, null);
+
+ assertTrue(commandLine.isEmpty());
+
+ getLauncherLifecycleCommands().addMaxHeap(commandLine, StringUtils.EMPTY_STRING);
+
+ assertTrue(commandLine.isEmpty());
+
+ getLauncherLifecycleCommands().addMaxHeap(commandLine, " ");
+
+ assertTrue(commandLine.isEmpty());
+
+ getLauncherLifecycleCommands().addMaxHeap(commandLine, "1024M");
+
+ assertFalse(commandLine.isEmpty());
+ assertEquals(3, commandLine.size());
+ assertEquals("-Xmx1024M", commandLine.get(0));
+ assertEquals("-XX:+UseConcMarkSweepGC", commandLine.get(1));
+ assertEquals("-XX:CMSInitiatingOccupancyFraction="
+ + LauncherLifecycleCommands.CMS_INITIAL_OCCUPANCY_FRACTION, commandLine.get(2));
+ }
+
+ @Test(expected = AssertionError.class)
+ public void testReadPidWithNull() {
+ try {
+ getLauncherLifecycleCommands().readPid(null);
+ } catch (AssertionError expected) {
+ assertEquals("The file from which to read the process ID (pid) cannot be null!",
+ expected.getMessage());
+ throw expected;
+ }
+ }
+
+ @Test
+ @SuppressWarnings("deprecation")
+ public void testGetClasspath() {
+ assertEquals(System.getProperty("java.class.path"),
+ getLauncherLifecycleCommands().getClasspath(null));
+ }
+
+ @Test
+ @SuppressWarnings("deprecation")
+ public void testGetClasspathWithUserDefinedClasspath() {
+ assertEquals(
+ System.getProperty("java.class.path") + File.pathSeparator + "/path/to/user/classes",
+ getLauncherLifecycleCommands().getClasspath("/path/to/user/classes"));
+ }
+
+ @Test
+ public void testGetSystemClasspath() {
+ assertEquals(System.getProperty("java.class.path"),
+ getLauncherLifecycleCommands().getSystemClasspath());
+ }
+
+ @Test
+ public void testLocatorClasspathOrder() {
+ String userClasspath = "/path/to/user/lib/app.jar:/path/to/user/classes";
+
+ String expectedClasspath = launcherCommands.getGemFireJarPath().concat(File.pathSeparator)
+ .concat(userClasspath).concat(File.pathSeparator)
+ .concat(System.getProperty("java.class.path")).concat(File.pathSeparator)
+ .concat(LauncherLifecycleCommands.CORE_DEPENDENCIES_JAR_PATHNAME);
+
+ String actualClasspath = launcherCommands.getLocatorClasspath(true, userClasspath);
+
+ assertEquals(expectedClasspath, actualClasspath);
+ }
+
+ @Test
+ public void testServerClasspathOrder() {
+ String userClasspath = "/path/to/user/lib/app.jar:/path/to/user/classes";
+
+ String expectedClasspath = launcherCommands.getGemFireJarPath().concat(File.pathSeparator)
+ .concat(userClasspath).concat(File.pathSeparator)
+ .concat(LauncherLifecycleCommands.CORE_DEPENDENCIES_JAR_PATHNAME);
+
+ String actualClasspath = launcherCommands.getServerClasspath(false, userClasspath);
+
+ assertEquals(expectedClasspath, actualClasspath);
+ }
+
+ @Test
+ public void testToClasspath() {
+ final boolean EXCLUDE_SYSTEM_CLASSPATH = false;
+ final boolean INCLUDE_SYSTEM_CLASSPATH = true;
+
+ String[] jarFilePathnames =
+ {"/path/to/user/libs/A.jar", "/path/to/user/libs/B.jar", "/path/to/user/libs/C.jar"};
+
+ String[] userClasspaths = {"/path/to/classes:/path/to/libs/1.jar:/path/to/libs/2.jar",
+ "/path/to/ext/libs/1.jar:/path/to/ext/classes:/path/to/ext/lib/10.jar"};
+
+ String expectedClasspath = LauncherLifecycleCommands.GEODE_JAR_PATHNAME
+ .concat(File.pathSeparator).concat(toClasspath(userClasspaths)).concat(File.pathSeparator)
+ .concat(toClasspath(jarFilePathnames));
+
+ assertEquals(expectedClasspath, getLauncherLifecycleCommands()
+ .toClasspath(EXCLUDE_SYSTEM_CLASSPATH, jarFilePathnames, userClasspaths));
+
+ expectedClasspath = LauncherLifecycleCommands.GEODE_JAR_PATHNAME.concat(File.pathSeparator)
+ .concat(toClasspath(userClasspaths)).concat(File.pathSeparator)
+ .concat(System.getProperty("java.class.path")).concat(File.pathSeparator)
+ .concat(toClasspath(jarFilePathnames));
+
+ assertEquals(expectedClasspath, getLauncherLifecycleCommands()
+ .toClasspath(INCLUDE_SYSTEM_CLASSPATH, jarFilePathnames, userClasspaths));
+
+ expectedClasspath = LauncherLifecycleCommands.GEODE_JAR_PATHNAME.concat(File.pathSeparator)
+ .concat(System.getProperty("java.class.path"));
+
+ assertEquals(expectedClasspath, getLauncherLifecycleCommands()
+ .toClasspath(INCLUDE_SYSTEM_CLASSPATH, null, (String[]) null));
+
+ assertEquals(LauncherLifecycleCommands.GEODE_JAR_PATHNAME, getLauncherLifecycleCommands()
+ .toClasspath(EXCLUDE_SYSTEM_CLASSPATH, null, (String[]) null));
+
+ assertEquals(LauncherLifecycleCommands.GEODE_JAR_PATHNAME,
+ getLauncherLifecycleCommands().toClasspath(EXCLUDE_SYSTEM_CLASSPATH, new String[0], ""));
+ }
+
+ @Test
+ public void testToClassPathOrder() {
+ String userClasspathOne = "/path/to/user/lib/a.jar:/path/to/user/classes";
+ String userClasspathTwo =
+ "/path/to/user/lib/x.jar:/path/to/user/lib/y.jar:/path/to/user/lib/z.jar";
+
+ String expectedClasspath = launcherCommands.getGemFireJarPath().concat(File.pathSeparator)
+ .concat(userClasspathOne).concat(File.pathSeparator).concat(userClasspathTwo)
+ .concat(File.pathSeparator).concat(System.getProperty("java.class.path"))
+ .concat(File.pathSeparator).concat(LauncherLifecycleCommands.CORE_DEPENDENCIES_JAR_PATHNAME)
+ .concat(File.pathSeparator)
+ .concat(LauncherLifecycleCommands.CORE_DEPENDENCIES_JAR_PATHNAME);
+
+ String actualClasspath = launcherCommands.toClasspath(true,
+ new String[] {LauncherLifecycleCommands.CORE_DEPENDENCIES_JAR_PATHNAME,
+ LauncherLifecycleCommands.CORE_DEPENDENCIES_JAR_PATHNAME},
+ userClasspathOne, userClasspathTwo);
+
+ assertEquals(expectedClasspath, actualClasspath);
+ }
+
+ @Test
+ public void testGetJavaPathname() {
+ assertEquals(
+ IOUtils.appendToPath(System.getProperty("java.home"), "bin",
+ "java" + LauncherLifecycleCommands.getExecutableSuffix()),
+ getLauncherLifecycleCommands().getJdkToolPathname(
+ "java" + LauncherLifecycleCommands.getExecutableSuffix(), new GemFireException() {}));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testGetJdkToolPathnameWithNullPathnames() {
+ try {
+ getLauncherLifecycleCommands().getJdkToolPathname((Stack<String>) null,
+ new GemFireException() {});
+ } catch (NullPointerException expected) {
+ assertEquals("The JDK tool executable pathnames cannot be null!", expected.getMessage());
+ throw expected;
+ }
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testGetJdkToolPathnameWithNullGemFireException() {
+ try {
+ getLauncherLifecycleCommands().getJdkToolPathname(new Stack<String>(), null);
+ } catch (NullPointerException expected) {
+ assertEquals("The GemFireException cannot be null!", expected.getMessage());
+ throw expected;
+ }
+ }
+
+ @Test
+ public void testGetJdkToolPathnameForNonExistingTool() {
+ try {
+ final GemFireException expected = new GemFireException() {
+ @Override
+ public String getMessage() {
+ return "expected";
+ }
+ };
+
+ getLauncherLifecycleCommands().getJdkToolPathname("nonExistingTool.exe", expected);
+ } catch (GemFireException expected) {
+ assertEquals("expected", expected.getMessage());
+ }
+ }
+
+ @Test
+ public void testGetLocatorId() {
+ assertEquals("machine[11235]", getLauncherLifecycleCommands().getLocatorId("machine", 11235));
+ assertEquals("machine.domain.org[11235]",
+ getLauncherLifecycleCommands().getLocatorId("machine.domain.org", 11235));
+ assertEquals("machine[" + DistributionLocator.DEFAULT_LOCATOR_PORT + "]",
+ getLauncherLifecycleCommands().getLocatorId("machine", null));
+ }
+
+ @Test
+ public void testGetServerId() {
+ assertEquals("machine[12480]", getLauncherLifecycleCommands().getServerId("machine", 12480));
+ assertEquals("machine.domain.org[12480]",
+ getLauncherLifecycleCommands().getServerId("machine.domain.org", 12480));
+ assertEquals("machine[" + CacheServer.DEFAULT_PORT + "]",
+ getLauncherLifecycleCommands().getServerId("machine", null));
+ }
+
+ @Test
+ public void testCreateJmxServerUrlWithMemberName() {
+ assertEquals("service:jmx:rmi://localhost:8192/jndi/rmi://localhost:8192/jmxrmi",
+ getLauncherLifecycleCommands().getJmxServiceUrlAsString("localhost[8192]"));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testCreateJmxServiceUrlWithInvalidMemberName() {
+ try {
+ System.err.println(getLauncherLifecycleCommands().getJmxServiceUrlAsString("memberOne[]"));
+ } catch (IllegalArgumentException expected) {
+ assertEquals(CliStrings.START_JCONSOLE__CONNECT_BY_MEMBER_NAME_ID_ERROR_MESSAGE,
+ expected.getMessage());
+ throw expected;
+ }
+ }
+
+ @Test
+ public void testCreateServerCommandLine() throws Exception {
+ ServerLauncher serverLauncher = new ServerLauncher.Builder()
+ .setCommand(ServerLauncher.Command.START).setDisableDefaultServer(true)
+ .setMemberName("testCreateServerCommandLine").setRebalance(true)
+ // .setServerBindAddress("localhost")
+ .setServerPort(41214).setCriticalHeapPercentage(95.5f).setEvictionHeapPercentage(85.0f)
+ .setSocketBufferSize(1024 * 1024).setMessageTimeToLive(93).build();
+
+ String[] commandLineElements = launcherCommands.createStartServerCommandLine(serverLauncher,
+ null, null, new Properties(), null, false, new String[0], false, null, null);
+
+ assertNotNull(commandLineElements);
+ assertTrue(commandLineElements.length > 0);
+
+ Set<String> expectedCommandLineElements = new HashSet<>(6);
+
+ expectedCommandLineElements.add(serverLauncher.getCommand().getName());
+ expectedCommandLineElements.add("--disable-default-server");
+ expectedCommandLineElements.add(serverLauncher.getMemberName().toLowerCase());
+ expectedCommandLineElements.add("--rebalance");
+ // expectedCommandLineElements.add(String.format("--server-bind-address=%1$s",
+ // serverLauncher.getServerBindAddress().getHostName()));
+ expectedCommandLineElements
+ .add(String.format("--server-port=%1$d", serverLauncher.getServerPort()));
+ expectedCommandLineElements.add(String.format("--critical-heap-percentage=%1$s",
+ serverLauncher.getCriticalHeapPercentage()));
+ expectedCommandLineElements.add(String.format("--eviction-heap-percentage=%1$s",
+ serverLauncher.getEvictionHeapPercentage()));
+ expectedCommandLineElements
+ .add(String.format("--socket-buffer-size=%1$d", serverLauncher.getSocketBufferSize()));
+ expectedCommandLineElements
+ .add(String.format("--message-time-to-live=%1$d", serverLauncher.getMessageTimeToLive()));
+
+ for (String commandLineElement : commandLineElements) {
+ expectedCommandLineElements.remove(commandLineElement.toLowerCase());
+ }
+
+ assertTrue(String.format("Expected ([]); but was (%1$s)", expectedCommandLineElements),
+ expectedCommandLineElements.isEmpty());
+ }
+
+ @Test
+ public void testCreateServerCommandLineWithRestAPI() throws Exception {
+ ServerLauncher serverLauncher = new ServerLauncher.Builder()
+ .setCommand(ServerLauncher.Command.START).setDisableDefaultServer(true)
+ .setMemberName("testCreateServerCommandLine").setRebalance(true)
+ // .setServerBindAddress("localhost")
+ .setServerPort(41214).setCriticalHeapPercentage(95.5f).setEvictionHeapPercentage(85.0f)
+ .build();
+
+ Properties gemfireProperties = new Properties();
+ gemfireProperties.setProperty(START_DEV_REST_API, "true");
+ gemfireProperties.setProperty(HTTP_SERVICE_PORT, "8080");
+ gemfireProperties.setProperty(HTTP_SERVICE_BIND_ADDRESS, "localhost");
+
+
+ String[] commandLineElements = launcherCommands.createStartServerCommandLine(serverLauncher,
+ null, null, gemfireProperties, null, false, new String[0], false, null, null);
+
+ assertNotNull(commandLineElements);
+ assertTrue(commandLineElements.length > 0);
+
+ Set<String> expectedCommandLineElements = new HashSet<>(6);
+
+ expectedCommandLineElements.add(serverLauncher.getCommand().getName());
+ expectedCommandLineElements.add("--disable-default-server");
+ expectedCommandLineElements.add(serverLauncher.getMemberName().toLowerCase());
+ expectedCommandLineElements.add("--rebalance");
+ // expectedCommandLineElements.add(String.format("--server-bind-address=%1$s",
+ // serverLauncher.getServerBindAddress().getHostName()));
+ expectedCommandLineElements
+ .add(String.format("--server-port=%1$d", serverLauncher.getServerPort()));
+ expectedCommandLineElements.add(String.format("--critical-heap-percentage=%1$s",
+ serverLauncher.getCriticalHeapPercentage()));
+ expectedCommandLineElements.add(String.format("--eviction-heap-percentage=%1$s",
+ serverLauncher.getEvictionHeapPercentage()));
+
+ expectedCommandLineElements
+ .add("-d" + DistributionConfig.GEMFIRE_PREFIX + "" + START_DEV_REST_API + "=" + "true");
+ expectedCommandLineElements
+ .add("-d" + DistributionConfig.GEMFIRE_PREFIX + "" + HTTP_SERVICE_PORT + "=" + "8080");
+ expectedCommandLineElements.add("-d" + DistributionConfig.GEMFIRE_PREFIX + ""
+ + HTTP_SERVICE_BIND_ADDRESS + "=" + "localhost");
+
+
+ for (String commandLineElement : commandLineElements) {
+ expectedCommandLineElements.remove(commandLineElement.toLowerCase());
+ }
+
+ assertTrue(String.format("Expected ([]); but was (%1$s)", expectedCommandLineElements),
+ expectedCommandLineElements.isEmpty());
+ }
+
+ /**
+ * Verify commandline parameters passed for starting locator
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testLocatorCommandLineWithRestAPI() throws Exception {
+ LocatorLauncher locatorLauncher =
+ new LocatorLauncher.Builder().setCommand(LocatorLauncher.Command.START)
+ .setMemberName("testLocatorCommandLineWithRestAPI").setBindAddress("localhost")
+ .setPort(11111).build();
+
+ Properties gemfireProperties = new Properties();
+ gemfireProperties.setProperty(HTTP_SERVICE_PORT, "8089");
+ gemfireProperties.setProperty(HTTP_SERVICE_BIND_ADDRESS, "localhost");
+
+
+ String[] commandLineElements = launcherCommands.createStartLocatorCommandLine(locatorLauncher,
+ null, null, gemfireProperties, null, false, new String[0], null, null);
+
+ assertNotNull(commandLineElements);
+ assertTrue(commandLineElements.length > 0);
+
+ Set<String> expectedCommandLineElements = new HashSet<>(6);
+
+ expectedCommandLineElements.add(locatorLauncher.getCommand().getName());
+ expectedCommandLineElements.add(locatorLauncher.getMemberName().toLowerCase());
+ expectedCommandLineElements.add(String.format("--port=%1$d", locatorLauncher.getPort()));
+ expectedCommandLineElements
+ .add("-d" + DistributionConfig.GEMFIRE_PREFIX + "" + HTTP_SERVICE_PORT + "=" + "8089");
+ expectedCommandLineElements.add("-d" + DistributionConfig.GEMFIRE_PREFIX + ""
+ + HTTP_SERVICE_BIND_ADDRESS + "=" + "localhost");
+
+
+ for (String commandLineElement : commandLineElements) {
+ expectedCommandLineElements.remove(commandLineElement.toLowerCase());
+ }
+
+ assertTrue(String.format("Expected ([]); but was (%1$s)", expectedCommandLineElements),
+ expectedCommandLineElements.isEmpty());
+ }
+
+
+ @Test
+ public void testReadPidWithNonExistingFile() {
+ assertEquals(LauncherLifecycleCommands.INVALID_PID,
+ getLauncherLifecycleCommands().readPid(new File("/path/to/non_existing/pid.file")));
+ }
+
+ private LauncherLifecycleCommands getLauncherLifecycleCommands() {
+ return launcherCommands;
+ }
+
+ private String toClasspath(final String... jarFilePathnames) {
+ String classpath = StringUtils.EMPTY_STRING;
+
+ if (jarFilePathnames != null) {
+ for (final String jarFilePathname : jarFilePathnames) {
+ classpath += (classpath.isEmpty() ? StringUtils.EMPTY_STRING : File.pathSeparator);
+ classpath += jarFilePathname;
+ }
+ }
+
+ return classpath;
+ }
+
+ private String toPath(Object... pathElements) {
+ String path = "";
+
+ for (Object pathElement : pathElements) {
+ path += (path.isEmpty() ? StringUtils.EMPTY_STRING : File.pathSeparator);
+ path += pathElement;
+ }
+
+ return path;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/geode/blob/568b49b4/geode-core/src/main/java/org/apache/geode/distributed/AbstractLauncher.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/AbstractLauncher.java b/geode-core/src/main/java/org/apache/geode/distributed/AbstractLauncher.java
index 64e20f3..feba893 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/AbstractLauncher.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/AbstractLauncher.java
@@ -72,31 +72,21 @@ public abstract class AbstractLauncher<T extends Comparable<T>> implements Runna
protected static final long READ_PID_FILE_TIMEOUT_MILLIS = 2 * 1000;
- // @see
- // http://publib.boulder.ibm.com/infocenter/javasdk/v6r0/index.jsp?topic=%2Fcom.ibm.java.doc.user.lnx.60%2Fuser%2Fattachapi.html
- // @see
- // http://docs.oracle.com/cd/E13150_01/jrockit_jvm/jrockit/geninfo/diagnos/aboutjrockit.html#wp1083571
- private static final List<String> ATTACH_API_PACKAGES = Arrays.asList("com.sun.tools.attach",
- "com/sun/tools/attach", "com.ibm.tools.attach", "com/ibm/tools/attach");
-
public static final String DEFAULT_WORKING_DIRECTORY = SystemUtils.CURRENT_DIRECTORY;
+
public static final String SIGNAL_HANDLER_REGISTRATION_SYSTEM_PROPERTY =
DistributionConfig.GEMFIRE_PREFIX + "launcher.registerSignalHandlers";
protected static final String OPTION_PREFIX = "-";
- private static final String IBM_ATTACH_API_CLASS_NAME =
- "com.ibm.tools.attach.AgentNotSupportedException";
- private static final String SUN_ATTACH_API_CLASS_NAME =
- "com.sun.tools.attach.AttachNotSupportedException";
private static final String SUN_SIGNAL_API_CLASS_NAME = "sun.misc.Signal";
private volatile boolean debug;
protected final transient AtomicBoolean running = new AtomicBoolean(false);
- protected Logger logger = Logger.getLogger(getClass().getName()); // TODO:KIRK: does this need
- // log4j2?
+ // TODO: use log4j logger instead of JUL
+ protected Logger logger = Logger.getLogger(getClass().getName());
public AbstractLauncher() {
try {
@@ -197,52 +187,6 @@ public abstract class AbstractLauncher<T extends Comparable<T>> implements Runna
}
/**
- * This method attempts to make a best effort determination for whether the Attach API classes are
- * on the classpath.
- *
- * @param t the Throwable being evaluated for missing Attach API classes.
- * @return a boolean indicating whether the Exception or Error condition is a result of the Attach
- * API missing from the classpath.
- */
- protected boolean isAttachAPINotFound(final Throwable t) {
- boolean missing = false;
-
- // NOTE prerequisite, Throwable must be a ClassNotFoundException or NoClassDefFoundError
- if (t instanceof ClassNotFoundException || t instanceof NoClassDefFoundError) {
- // NOTE the use of the 'testing' class member variable, yuck!
- if (!isAttachAPIOnClasspath()) {
- // NOTE ok, the Attach API is not available, however we still do not know whether an user
- // application class
- // caused the ClassNotFoundException or NoClassDefFoundError.
- final StringWriter stackTraceWriter = new StringWriter();
-
- // NOTE the full stack trace includes the Throwable message, which typically indicates the
- // Exception/Error
- // thrown and the reason (as in which class was not found).
- t.printStackTrace(new PrintWriter(stackTraceWriter));
-
- final String stackTrace = stackTraceWriter.toString();
-
- for (String attachApiPackage : ATTACH_API_PACKAGES) {
- missing |= stackTrace.contains(attachApiPackage);
- }
- }
- }
-
- return missing;
- }
-
- /**
- * Determines if the Attach API is on the classpath.
- *
- * @return a boolean value indicating if the Attach API is on the classpath.
- */
- boolean isAttachAPIOnClasspath() {
- return (ClassUtils.isClassAvailable(SUN_ATTACH_API_CLASS_NAME)
- || ClassUtils.isClassAvailable(IBM_ATTACH_API_CLASS_NAME));
- }
-
- /**
* Determines whether the Locator launcher is in debug mode.
*
* @return a boolean to indicate whether the Locator launcher is in debug mode.
http://git-wip-us.apache.org/repos/asf/geode/blob/568b49b4/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
index e677ba3..d42d75e 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
@@ -74,7 +74,6 @@ import org.apache.geode.internal.process.signal.SignalEvent;
import org.apache.geode.internal.process.signal.SignalListener;
import org.apache.geode.internal.util.IOUtils;
import org.apache.geode.internal.util.StopWatch;
-import org.apache.geode.lang.AttachAPINotFoundException;
import org.apache.geode.management.DistributedSystemMXBean;
import org.apache.geode.management.MemberMXBean;
import org.apache.geode.management.cli.CliMetaData;
@@ -169,11 +168,6 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
protected static final int MINIMUM_HEAP_FREE_RATIO = 10;
protected static final int NUM_ATTEMPTS_FOR_SHARED_CONFIGURATION_STATUS = 3;
- protected static final AtomicReference<Boolean> ATTACH_API_AVAILABLE =
- new AtomicReference<>(null);
-
- protected static final String ATTACH_API_CLASS_NAME =
- "com.sun.tools.attach.AttachNotSupportedException";
protected static final String GEODE_HOME = System.getenv("GEODE_HOME");
protected static final String JAVA_HOME = System.getProperty("java.home");
protected static final String LOCALHOST = "localhost";
@@ -185,19 +179,6 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
protected static final String CORE_DEPENDENCIES_JAR_PATHNAME =
IOUtils.appendToPath(GEODE_HOME, "lib", "geode-dependencies.jar");
- protected static boolean isAttachApiAvailable() {
- if (ATTACH_API_AVAILABLE.get() == null) {
- try {
- ClassUtils.forName(ATTACH_API_CLASS_NAME, new AttachAPINotFoundException());
- ATTACH_API_AVAILABLE.set(Boolean.TRUE);
- } catch (AttachAPINotFoundException ignore) {
- ATTACH_API_AVAILABLE.set(Boolean.FALSE);
- }
- }
-
- return ATTACH_API_AVAILABLE.get();
- }
-
private final ThreePhraseGenerator nameGenerator;
public LauncherLifecycleCommands() {
@@ -424,9 +405,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
TimeUnit.MILLISECONDS.timedWait(this, 500);
}
- locatorState = (ProcessUtils.isAttachApiAvailable()
- ? locatorStatus(locatorPidFile, oldPid, memberName)
- : locatorStatus(workingDirectory, memberName));
+ locatorState = locatorStatus(workingDirectory, memberName);
String currentLocatorStatusMessage = locatorState.getStatusMessage();
@@ -1222,29 +1201,6 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
return new File(new File(JAVA_HOME, "bin"), "java").getPath();
}
- @Deprecated
- protected String getToolsJarPath() throws AttachAPINotFoundException {
- String toolsJarPathname = null;
-
- if (!SystemUtils.isMacOSX()) {
- toolsJarPathname = IOUtils.appendToPath(JAVA_HOME, "lib", "tools.jar");
-
- if (!IOUtils.isExistingPathname(toolsJarPathname)) {
- // perhaps the java.home System property refers to the JRE ($JAVA_HOME/jre)...
- String JDK_HOME = new File(JAVA_HOME).getParentFile().getPath();
- toolsJarPathname = IOUtils.appendToPath(JDK_HOME, "lib", "tools.jar");
- }
-
- try {
- IOUtils.verifyPathnameExists(toolsJarPathname);
- } catch (IOException e) {
- throw new AttachAPINotFoundException(getAttachAPINotFoundMessage());
- }
- }
-
- return toolsJarPathname;
- }
-
// TODO refactor the following method into a common base class or utility class
protected String getLocalHost() {
try {
@@ -1254,11 +1210,6 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
}
}
- protected String getAttachAPINotFoundMessage() {
- return CliStrings.format(CliStrings.ATTACH_API_IN_0_NOT_FOUND_ERROR_MESSAGE,
- ((SystemUtils.isMacOSX() && SystemUtils.isAppleJVM()) ? "classes.jar" : "tools.jar"));
- }
-
protected String getLocatorId(final String host, final Integer port) {
final String locatorHost = (host != null ? host : getLocalHost());
final String locatorPort =
@@ -1347,8 +1298,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
}
protected boolean isVmWithProcessIdRunning(final Integer pid) {
- // note: this will use JNA if available or Attach if available or return false if neither is
- // available
+ // note: this will use JNA if available or return false
return ProcessUtils.isProcessAlive(pid);
}
@@ -1717,9 +1667,7 @@ public class LauncherLifecycleCommands extends AbstractCommandsSupport {
TimeUnit.MILLISECONDS.timedWait(this, 500);
}
- serverState = (ProcessUtils.isAttachApiAvailable()
- ? serverStatus(serverPidFile, oldPid, memberName)
- : serverStatus(workingDirectory, memberName));
+ serverState = serverStatus(workingDirectory, memberName);
String currentServerStatusMessage = serverState.getStatusMessage();
http://git-wip-us.apache.org/repos/asf/geode/blob/568b49b4/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
index 7696aa8..51d39d6 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
@@ -2721,7 +2721,8 @@ public class CliStrings {
public static final String STATUS_LOCATOR__MEMBER__HELP =
"Member name or ID of the Locator in the Geode cluster.";
public static final String STATUS_LOCATOR__PID = "pid";
- public static final String STATUS_LOCATOR__PID__HELP = "Process ID (PID) of the running Locator.";
+ public static final String STATUS_LOCATOR__PID__HELP =
+ "Process ID (PID) of the running Locator. Deprecated: Since Geode1.2. Requires the JDK tools.jar which is not included on the classpath by default. Use --dir instead.";
public static final String STATUS_LOCATOR__PORT = "port";
public static final String STATUS_LOCATOR__PORT__HELP =
"Port on which the Locator is listening. The default is 10334.";
@@ -2745,7 +2746,7 @@ public class CliStrings {
"No Geode Cache Server with member name or ID {0} could be found.";
public static final String STATUS_SERVER__PID = "pid";
public static final String STATUS_SERVER__PID__HELP =
- "Process ID (PID) of the running Geode Cache Server.";
+ "Process ID (PID) of the running Geode Cache Server. Deprecated: Since Geode1.2. Requires the JDK tools.jar which is not included on the classpath by default. Use --dir instead.";
/* stop gateway-reciver */
public static final String STOP_GATEWAYRECEIVER = "stop gateway-receiver";
@@ -2782,7 +2783,7 @@ public class CliStrings {
"Member name or ID of the Locator in the Geode cluster.";
public static final String STOP_LOCATOR__PID = "pid";
public static final String STOP_LOCATOR__PID__HELP =
- "The process id (PID) of the running Locator.";
+ "The process id (PID) of the running Locator. Deprecated: Since Geode1.2. Requires the JDK tools.jar which is not included on the classpath by default. Use --dir instead.";
public static final String STOP_LOCATOR__GENERAL_ERROR_MESSAGE =
"An error occurred while attempting to stop a Locator: %1$s";
public static final String STOP_LOCATOR__LOCATOR_IS_CACHE_SERVER_ERROR_MESSAGE =
@@ -2813,7 +2814,7 @@ public class CliStrings {
"No Cache Server with member name or ID {0} could be found.";
public static final String STOP_SERVER__PID = "pid";
public static final String STOP_SERVER__PID__HELP =
- "Process ID (PID) of the running Geode Cache Server.";
+ "Process ID (PID) of the running Geode Cache Server. Deprecated: Since Geode1.2. Requires the JDK tools.jar which is not included on the classpath by default. Use --dir instead.";
public static final String STOP_SERVER__SHUTDOWN_MEMBER_MESSAGE =
"Cache Server {0} has been requested to stop.";
public static final String STOP_SERVER__STOPPING_SERVER_MESSAGE =
http://git-wip-us.apache.org/repos/asf/geode/blob/568b49b4/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherTest.java b/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherTest.java
index f487df9..feba601 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherTest.java
@@ -14,6 +14,9 @@
*/
package org.apache.geode.distributed;
+import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.junit.Assert.*;
+
import org.apache.geode.internal.lang.StringUtils;
import org.apache.geode.test.junit.categories.UnitTest;
import org.junit.Test;
@@ -24,9 +27,6 @@ import java.net.URL;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
-import static org.junit.Assert.*;
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-
/**
* The AbstractLauncherTest class is a test suite of unit tests testing the contract and
* functionality of the AbstractLauncher class.
@@ -46,28 +46,6 @@ public class AbstractLauncherTest {
}
@Test
- public void testIsAttachAPINotFound() {
- final AbstractLauncher<?> launcher = createAbstractLauncher("012", "TestMember");
-
- assertTrue(launcher.isAttachAPINotFound(new NoClassDefFoundError(
- "Exception in thread \"main\" java.lang.NoClassDefFoundError: com/sun/tools/attach/AttachNotSupportedException")));
- assertTrue(launcher.isAttachAPINotFound(new ClassNotFoundException(
- "Caused by: java.lang.ClassNotFoundException: com.sun.tools.attach.AttachNotSupportedException")));
- assertTrue(launcher.isAttachAPINotFound(new NoClassDefFoundError(
- "Exception in thread \"main\" java.lang.NoClassDefFoundError: com/ibm/tools/attach/AgentNotSupportedException")));
- assertTrue(launcher.isAttachAPINotFound(new ClassNotFoundException(
- "Caused by: java.lang.ClassNotFoundException: com.ibm.tools.attach.AgentNotSupportedException")));
- assertFalse(launcher.isAttachAPINotFound(new IllegalArgumentException(
- "Caused by: java.lang.ClassNotFoundException: com.sun.tools.attach.AttachNotSupportedException")));
- assertFalse(launcher.isAttachAPINotFound(new IllegalStateException(
- "Caused by: java.lang.ClassNotFoundException: com.ibm.tools.attach.AgentNotSupportedException")));
- assertFalse(launcher.isAttachAPINotFound(new NoClassDefFoundError(
- "Exception in thread \"main\" java.lang.NoClassDefFoundError: com/companyx/app/service/MyServiceClass")));
- assertFalse(launcher.isAttachAPINotFound(new ClassNotFoundException(
- "Caused by: java.lang.ClassNotFoundException: com.companyx.app.attach.NutsNotAttachedException")));
- }
-
- @Test
public void testIsSet() {
final Properties properties = new Properties();
@@ -282,11 +260,6 @@ public class AbstractLauncherTest {
}
@Override
- boolean isAttachAPIOnClasspath() {
- return false;
- }
-
- @Override
public String getLogFileName() {
throw new UnsupportedOperationException("Not Implemented!");
}
http://git-wip-us.apache.org/repos/asf/geode/blob/568b49b4/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/HelpCommandsIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/HelpCommandsIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/HelpCommandsIntegrationTest.java
index 1483aad..b91a1f3 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/HelpCommandsIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/HelpCommandsIntegrationTest.java
@@ -73,8 +73,7 @@ public class HelpCommandsIntegrationTest {
}
/**
- * TODO:GEODE-1466: update golden file to geode.properties TODO:GEODE-1566: update golden file to
- * GeodeRedisServer
+ * TODO:GEODE-1466: update golden file to geode.properties
*/
@Test
public void testOfflineHelp() throws Exception {
http://git-wip-us.apache.org/repos/asf/geode/blob/568b49b4/geode-core/src/test/resources/org/apache/geode/management/internal/cli/commands/golden-help-offline.properties
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/management/internal/cli/commands/golden-help-offline.properties b/geode-core/src/test/resources/org/apache/geode/management/internal/cli/commands/golden-help-offline.properties
index 8e21a3a..17b7515 100644
--- a/geode-core/src/test/resources/org/apache/geode/management/internal/cli/commands/golden-help-offline.properties
+++ b/geode-core/src/test/resources/org/apache/geode/management/internal/cli/commands/golden-help-offline.properties
@@ -2874,7 +2874,8 @@ PARAMETERS\n\
\ \ \ \ \ \ \ \ Port on which the Locator is listening. The default is 10334.\n\
\ \ \ \ \ \ \ \ Required: false\n\
\ \ \ \ pid\n\
-\ \ \ \ \ \ \ \ Process ID (PID) of the running Locator.\n\
+\ \ \ \ \ \ \ \ Process ID (PID) of the running Locator. Deprecated: Since Geode1.2. Requires the JDK\n\
+\ \ \ \ \ \ \ \ tools.jar which is not included on the classpath by default. Use --dir instead.\n\
\ \ \ \ \ \ \ \ Required: false\n\
\ \ \ \ dir\n\
\ \ \ \ \ \ \ \ Working directory in which the Locator is running. The default is the current directory.\n\
@@ -2894,7 +2895,8 @@ PARAMETERS\n\
\ \ \ \ \ \ \ \ Member name or ID of the Cache Server in the Geode cluster.\n\
\ \ \ \ \ \ \ \ Required: false\n\
\ \ \ \ pid\n\
-\ \ \ \ \ \ \ \ Process ID (PID) of the running Geode Cache Server.\n\
+\ \ \ \ \ \ \ \ Process ID (PID) of the running Geode Cache Server. Deprecated: Since Geode1.2. Requires\n\
+\ \ \ \ \ \ \ \ the JDK tools.jar which is not included on the classpath by default. Use --dir instead.\n\
\ \ \ \ \ \ \ \ Required: false\n\
\ \ \ \ dir\n\
\ \ \ \ \ \ \ \ Working directory in which the Cache Server is running. The default is the current\n\
@@ -2952,7 +2954,8 @@ PARAMETERS\n\
\ \ \ \ \ \ \ \ Member name or ID of the Locator in the Geode cluster.\n\
\ \ \ \ \ \ \ \ Required: false\n\
\ \ \ \ pid\n\
-\ \ \ \ \ \ \ \ The process id (PID) of the running Locator.\n\
+\ \ \ \ \ \ \ \ The process id (PID) of the running Locator. Deprecated: Since Geode1.2. Requires the JDK\n\
+\ \ \ \ \ \ \ \ tools.jar which is not included on the classpath by default. Use --dir instead.\n\
\ \ \ \ \ \ \ \ Required: false\n\
\ \ \ \ dir\n\
\ \ \ \ \ \ \ \ Working directory in which the Locator is running. The default is the current directory.\n\
@@ -2981,7 +2984,8 @@ PARAMETERS\n\
\ \ \ \ \ \ \ \ Member name or ID of the Cache Server in the Geode cluster.\n\
\ \ \ \ \ \ \ \ Required: false\n\
\ \ \ \ pid\n\
-\ \ \ \ \ \ \ \ Process ID (PID) of the running Geode Cache Server.\n\
+\ \ \ \ \ \ \ \ Process ID (PID) of the running Geode Cache Server. Deprecated: Since Geode1.2. Requires\n\
+\ \ \ \ \ \ \ \ the JDK tools.jar which is not included on the classpath by default. Use --dir instead.\n\
\ \ \ \ \ \ \ \ Required: false\n\
\ \ \ \ dir\n\
\ \ \ \ \ \ \ \ Working directory in which the Cache Server is running. The default is the current\n\