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 2018/01/12 00:04:40 UTC
[geode] branch develop updated: GEODE-4101: Add --redirect-output
flag to GFSH (#1203)
This is an automated email from the ASF dual-hosted git repository.
khowe pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 5c1d8ef GEODE-4101: Add --redirect-output flag to GFSH (#1203)
5c1d8ef is described below
commit 5c1d8ef106d468dcc584d1ff0393dbcb6c5a4c81
Author: Juan José Ramos <ju...@users.noreply.github.com>
AuthorDate: Thu Jan 11 21:04:37 2018 -0300
GEODE-4101: Add --redirect-output flag to GFSH (#1203)
* GEODE-4101: Add --redirect-output flag to GFSH.
To avoid major code changes the start commands check the new flag and
set as `true` a new system property, `DISABLE_REDIRECTION_CONFIGURATION`,
which disables the other two (now deprecated) properties. In the next
major release, the properties and the related logic should be deleted.
The integration between log4j2 and geode-pulse was also incomplete.
When ran in embedded mode, some messages were totally swallowed and the
actual logging was split between the member's log and pulse.log file.
- Added flag `--redirect-ouput` to `StartServerCommand`.
- Added flag `--redirect-ouput` to `StartLocatorCommand`.
- Added tests to verify the behavior of the commands/builders.
- Added `OSProcess.DISABLE_REDIRECTION_CONFIGURATION` internal property.
- Property `OSProcess.ENABLE_OUTPUT_REDIRECTION` marked as deprecated.
- Property `OSProcess.DISABLE_OUTPUT_REDIRECTION` marked as deprecated.
- Added `log4j-jcl` as a dependency of `geode-pulse`. By adding this
dependency no logging is lost and nothing is split: everything goes
to the pulse.log file (or whatever is configured in `log4j2.xml`).
* GEODE-4101: Add --redirect-output flag to GFSH.
- Changes requested by reviewers.
- Added `commons-logging.jar` as an exclusion from `geode-web-api.war`
to avoid unformatted output on the member's log when the
`dev-rest-api` is enabled.
---
.../cli/commands/StartLocatorCommandTest.java | 111 +++++++++++++++++++++
.../cli/commands/StartServerCommandTest.java | 99 ++++++++++++++++++
.../java/org/apache/geode/internal/OSProcess.java | 45 ++++++++-
.../internal/cli/commands/StartLocatorCommand.java | 13 ++-
.../internal/cli/commands/StartServerCommand.java | 21 ++--
.../management/internal/cli/i18n/CliStrings.java | 6 ++
.../distributed/LocatorLauncherBuilderTest.java | 15 ++-
.../distributed/ServerLauncherBuilderTest.java | 15 ++-
.../internal/cli/GfshParserAutoCompletionTest.java | 16 +--
geode-pulse/build.gradle | 2 +
geode-web-api/build.gradle | 1 +
11 files changed, 316 insertions(+), 28 deletions(-)
diff --git a/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/StartLocatorCommandTest.java b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/StartLocatorCommandTest.java
index 5a7c11c..4d15368 100644
--- a/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/StartLocatorCommandTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/StartLocatorCommandTest.java
@@ -20,9 +20,13 @@ import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
import java.io.File;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
@@ -33,6 +37,7 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import org.apache.geode.distributed.ConfigurationProperties;
import org.apache.geode.distributed.LocatorLauncher;
import org.apache.geode.distributed.internal.DistributionConfig;
import org.apache.geode.internal.lang.SystemUtils;
@@ -144,4 +149,110 @@ public class StartLocatorCommandTest {
commandLine.add("-XXexitOnOutOfMemory");
}
}
+
+ @Test
+ public void testCreateStartLocatorCommandLine() throws Exception {
+ LocatorLauncher locatorLauncher = new LocatorLauncher.Builder().setMemberName("defaultLocator")
+ .setCommand(LocatorLauncher.Command.START).build();
+
+ String[] commandLineElements = locatorCommands.createStartLocatorCommandLine(locatorLauncher,
+ null, null, new Properties(), null, false, null, null, null);
+
+ Set<String> expectedCommandLineElements = new HashSet<>();
+ expectedCommandLineElements.add(StartMemberUtils.getJavaPath());
+ expectedCommandLineElements.add("-server");
+ expectedCommandLineElements.add("-classpath");
+ expectedCommandLineElements.add(StartMemberUtils.getGemFireJarPath().concat(File.pathSeparator)
+ .concat(StartMemberUtils.CORE_DEPENDENCIES_JAR_PATHNAME));
+ expectedCommandLineElements.add("-Dgemfire.launcher.registerSignalHandlers=true");
+ expectedCommandLineElements.add("-Djava.awt.headless=true");
+ expectedCommandLineElements.add("-Dsun.rmi.dgc.server.gcInterval=9223372036854775806");
+ expectedCommandLineElements.add("org.apache.geode.distributed.LocatorLauncher");
+ expectedCommandLineElements.add("start");
+ expectedCommandLineElements.add("defaultLocator");
+ expectedCommandLineElements.add("--port=10334");
+
+ assertNotNull(commandLineElements);
+ assertTrue(commandLineElements.length > 0);
+ assertEquals(commandLineElements.length, expectedCommandLineElements.size());
+
+ for (String commandLineElement : commandLineElements) {
+ expectedCommandLineElements.remove(commandLineElement);
+ }
+
+ assertTrue(String.format("Expected ([]); but was (%1$s)", expectedCommandLineElements),
+ expectedCommandLineElements.isEmpty());
+ }
+
+ @Test
+ public void testCreateStartLocatorCommandLineWithAllOptions() throws Exception {
+ LocatorLauncher locatorLauncher =
+ new LocatorLauncher.Builder().setCommand(LocatorLauncher.Command.START)
+ .setDebug(Boolean.TRUE).setDeletePidFileOnStop(Boolean.TRUE).setForce(Boolean.TRUE)
+ .setHostnameForClients("localhost").setMemberName("customLocator").setPort(10101)
+ .setRedirectOutput(Boolean.TRUE).build();
+
+ File gemfirePropertiesFile = spy(mock(File.class));
+ when(gemfirePropertiesFile.getAbsolutePath()).thenReturn("/config/customGemfire.properties");
+
+ File gemfireSecurityPropertiesFile = spy(mock(File.class));
+ when(gemfireSecurityPropertiesFile.getAbsolutePath())
+ .thenReturn("/config/customGemfireSecurity.properties");
+
+ Properties gemfireProperties = new Properties();
+ gemfireProperties.setProperty(ConfigurationProperties.STATISTIC_SAMPLE_RATE, "1500");
+ gemfireProperties.setProperty(ConfigurationProperties.DISABLE_AUTO_RECONNECT, "true");
+
+ String heapSize = "1024m";
+ String customClasspath = "/temp/domain-1.0.0.jar";
+ String[] jvmArguments = new String[] {"-verbose:gc", "-Xloggc:member-gc.log",
+ "-XX:+PrintGCDateStamps", "-XX:+PrintGCDetails"};
+
+ String[] commandLineElements = locatorCommands.createStartLocatorCommandLine(locatorLauncher,
+ gemfirePropertiesFile, gemfireSecurityPropertiesFile, gemfireProperties, customClasspath,
+ Boolean.FALSE, jvmArguments, heapSize, heapSize);
+
+ Set<String> expectedCommandLineElements = new HashSet<>();
+ expectedCommandLineElements.add(StartMemberUtils.getJavaPath());
+ expectedCommandLineElements.add("-server");
+ expectedCommandLineElements.add("-classpath");
+ expectedCommandLineElements
+ .add(StartMemberUtils.getGemFireJarPath().concat(File.pathSeparator).concat(customClasspath)
+ .concat(File.pathSeparator).concat(StartMemberUtils.CORE_DEPENDENCIES_JAR_PATHNAME));
+ expectedCommandLineElements
+ .add("-DgemfirePropertyFile=".concat(gemfirePropertiesFile.getAbsolutePath()));
+ expectedCommandLineElements.add(
+ "-DgemfireSecurityPropertyFile=".concat(gemfireSecurityPropertiesFile.getAbsolutePath()));
+ expectedCommandLineElements.add("-Dgemfire.statistic-sample-rate=1500");
+ expectedCommandLineElements.add("-Dgemfire.disable-auto-reconnect=true");
+ expectedCommandLineElements.addAll(Arrays.asList(jvmArguments));
+ expectedCommandLineElements.add("-Xms".concat(heapSize));
+ expectedCommandLineElements.add("-Xmx".concat(heapSize));
+ expectedCommandLineElements.add("-XX:+UseConcMarkSweepGC");
+ expectedCommandLineElements.add("-XX:CMSInitiatingOccupancyFraction="
+ .concat(String.valueOf(StartMemberUtils.CMS_INITIAL_OCCUPANCY_FRACTION)));
+ expectedCommandLineElements.add("-Dgemfire.launcher.registerSignalHandlers=true");
+ expectedCommandLineElements.add("-Djava.awt.headless=true");
+ expectedCommandLineElements.add("-Dsun.rmi.dgc.server.gcInterval=9223372036854775806");
+ expectedCommandLineElements.add("-Dgemfire.OSProcess.DISABLE_REDIRECTION_CONFIGURATION=true");
+ expectedCommandLineElements.add("org.apache.geode.distributed.LocatorLauncher");
+ expectedCommandLineElements.add("start");
+ expectedCommandLineElements.add("customLocator");
+ expectedCommandLineElements.add("--debug");
+ expectedCommandLineElements.add("--force");
+ expectedCommandLineElements.add("--hostname-for-clients=localhost");
+ expectedCommandLineElements.add("--port=10101");
+ expectedCommandLineElements.add("--redirect-output");
+
+ assertNotNull(commandLineElements);
+ assertTrue(commandLineElements.length > 0);
+ assertEquals(commandLineElements.length, expectedCommandLineElements.size());
+
+ for (String commandLineElement : commandLineElements) {
+ expectedCommandLineElements.remove(commandLineElement);
+ }
+
+ assertTrue(String.format("Expected ([]); but was (%1$s)", expectedCommandLineElements),
+ expectedCommandLineElements.isEmpty());
+ }
}
diff --git a/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/StartServerCommandTest.java b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/StartServerCommandTest.java
index e704248..5008ed3 100644
--- a/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/StartServerCommandTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/management/internal/cli/commands/StartServerCommandTest.java
@@ -21,8 +21,12 @@ import static org.apache.geode.distributed.ConfigurationProperties.START_DEV_RES
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
import java.io.File;
+import java.util.Arrays;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
@@ -32,8 +36,10 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import org.apache.geode.distributed.ConfigurationProperties;
import org.apache.geode.distributed.ServerLauncher;
import org.apache.geode.distributed.internal.DistributionConfig;
+import org.apache.geode.pdx.PdxSerializer;
import org.apache.geode.test.junit.categories.UnitTest;
@Category(UnitTest.class)
@@ -141,4 +147,97 @@ public class StartServerCommandTest {
assertTrue(String.format("Expected ([]); but was (%1$s)", expectedCommandLineElements),
expectedCommandLineElements.isEmpty());
}
+
+ @Test
+ public void testCreateStartServerCommandLineWithAllOptions() throws Exception {
+ ServerLauncher serverLauncher = new ServerLauncher.Builder().setAssignBuckets(Boolean.TRUE)
+ .setCommand(ServerLauncher.Command.START).setCriticalHeapPercentage(95.5f)
+ .setCriticalOffHeapPercentage(95.5f).setDebug(Boolean.TRUE)
+ .setDisableDefaultServer(Boolean.TRUE).setDeletePidFileOnStop(Boolean.TRUE)
+ .setEvictionHeapPercentage(85.0f).setEvictionOffHeapPercentage(85.0f).setForce(Boolean.TRUE)
+ .setHostNameForClients("localhost").setMaxConnections(800).setMaxMessageCount(500)
+ .setMaxThreads(100).setMemberName("fullServer").setMessageTimeToLive(93)
+ .setPdxDiskStore("pdxDiskStore").setPdxIgnoreUnreadFields(Boolean.TRUE)
+ .setPdxPersistent(Boolean.TRUE).setPdxReadSerialized(Boolean.TRUE)
+ .setPdxSerializer(mock(PdxSerializer.class)).setRebalance(Boolean.TRUE)
+ .setRedirectOutput(Boolean.TRUE).setRebalance(true).setServerPort(41214)
+ .setSocketBufferSize(1024 * 1024).setSpringXmlLocation("/config/spring-server.xml").build();
+
+ File gemfirePropertiesFile = spy(mock(File.class));
+ when(gemfirePropertiesFile.getAbsolutePath()).thenReturn("/config/customGemfire.properties");
+
+ File gemfireSecurityPropertiesFile = spy(mock(File.class));
+ when(gemfireSecurityPropertiesFile.getAbsolutePath())
+ .thenReturn("/config/customGemfireSecurity.properties");
+
+ Properties gemfireProperties = new Properties();
+ gemfireProperties.setProperty(ConfigurationProperties.STATISTIC_SAMPLE_RATE, "1500");
+ gemfireProperties.setProperty(ConfigurationProperties.DISABLE_AUTO_RECONNECT, "true");
+
+ String heapSize = "1024m";
+ String customClasspath = "/temp/domain-1.0.0.jar";
+ String[] jvmArguments = new String[] {"-verbose:gc", "-Xloggc:member-gc.log",
+ "-XX:+PrintGCDateStamps", "-XX:+PrintGCDetails"};
+
+ String[] commandLineElements = serverCommands.createStartServerCommandLine(serverLauncher,
+ gemfirePropertiesFile, gemfireSecurityPropertiesFile, gemfireProperties, customClasspath,
+ Boolean.FALSE, jvmArguments, Boolean.FALSE, heapSize, heapSize);
+
+ Set<String> expectedCommandLineElements = new HashSet<>();
+ expectedCommandLineElements.add(StartMemberUtils.getJavaPath());
+ expectedCommandLineElements.add("-server");
+ expectedCommandLineElements.add("-classpath");
+ expectedCommandLineElements
+ .add(StartMemberUtils.getGemFireJarPath().concat(File.pathSeparator).concat(customClasspath)
+ .concat(File.pathSeparator).concat(StartMemberUtils.CORE_DEPENDENCIES_JAR_PATHNAME));
+ expectedCommandLineElements
+ .add("-DgemfirePropertyFile=".concat(gemfirePropertiesFile.getAbsolutePath()));
+ expectedCommandLineElements.add(
+ "-DgemfireSecurityPropertyFile=".concat(gemfireSecurityPropertiesFile.getAbsolutePath()));
+ expectedCommandLineElements.add("-Dgemfire.statistic-sample-rate=1500");
+ expectedCommandLineElements.add("-Dgemfire.disable-auto-reconnect=true");
+ expectedCommandLineElements.addAll(Arrays.asList(jvmArguments));
+ expectedCommandLineElements.add("-XX:OnOutOfMemoryError=kill -KILL %p");
+ expectedCommandLineElements.add("-Xms".concat(heapSize));
+ expectedCommandLineElements.add("-Xmx".concat(heapSize));
+ expectedCommandLineElements.add("-XX:+UseConcMarkSweepGC");
+ expectedCommandLineElements.add("-XX:CMSInitiatingOccupancyFraction="
+ .concat(String.valueOf(StartMemberUtils.CMS_INITIAL_OCCUPANCY_FRACTION)));
+ expectedCommandLineElements.add("-Dgemfire.launcher.registerSignalHandlers=true");
+ expectedCommandLineElements.add("-Djava.awt.headless=true");
+ expectedCommandLineElements.add("-Dsun.rmi.dgc.server.gcInterval=9223372036854775806");
+ expectedCommandLineElements.add("-Dgemfire.OSProcess.DISABLE_REDIRECTION_CONFIGURATION=true");
+ expectedCommandLineElements.add("org.apache.geode.distributed.ServerLauncher");
+ expectedCommandLineElements.add("start");
+ expectedCommandLineElements.add("fullServer");
+ expectedCommandLineElements.add("--assign-buckets");
+ expectedCommandLineElements.add("--debug");
+ expectedCommandLineElements.add("--disable-default-server");
+ expectedCommandLineElements.add("--force");
+ expectedCommandLineElements.add("--rebalance");
+ expectedCommandLineElements.add("--redirect-output");
+ expectedCommandLineElements.add("--server-port=41214");
+ expectedCommandLineElements.add("--spring-xml-location=/config/spring-server.xml");
+ expectedCommandLineElements.add("--critical-heap-percentage=95.5");
+ expectedCommandLineElements.add("--eviction-heap-percentage=85.0");
+ expectedCommandLineElements.add("--critical-off-heap-percentage=95.5");
+ expectedCommandLineElements.add("--eviction-off-heap-percentage=85.0");
+ expectedCommandLineElements.add("--max-connections=800");
+ expectedCommandLineElements.add("--max-message-count=500");
+ expectedCommandLineElements.add("--max-threads=100");
+ expectedCommandLineElements.add("--message-time-to-live=93");
+ expectedCommandLineElements.add("--socket-buffer-size=1048576");
+ expectedCommandLineElements.add("--hostname-for-clients=localhost");
+
+ assertNotNull(commandLineElements);
+ assertTrue(commandLineElements.length > 0);
+ assertEquals(commandLineElements.length, expectedCommandLineElements.size());
+
+ for (String commandLineElement : commandLineElements) {
+ expectedCommandLineElements.remove(commandLineElement);
+ }
+
+ assertTrue(String.format("Expected ([]); but was (%1$s)", expectedCommandLineElements),
+ expectedCommandLineElements.isEmpty());
+ }
}
diff --git a/geode-core/src/main/java/org/apache/geode/internal/OSProcess.java b/geode-core/src/main/java/org/apache/geode/internal/OSProcess.java
index d16f859..a715d6f 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/OSProcess.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/OSProcess.java
@@ -32,21 +32,57 @@ import org.apache.geode.internal.logging.LoggingThreadGroup;
* Used to interact with operating system processes. Use <code>exec</code> to create a new process
* by executing a command. Use <code>kill</code> to kill a process.
*
- *
*/
+// TODO: In the next major release, we should remove the variables and logic related to the system
+// properties used to determine whether output redirection is allowed or not
+// (DISABLE_OUTPUT_REDIRECTION_PROPERTY, ENABLE_OUTPUT_REDIRECTION_PROPERTY,
+// DISABLE_REDIRECTION_CONFIGURATION_PROPERTY, ENABLE_OUTPUT_REDIRECTION, DISABLE_OUTPUT_REDIRECTION
+// and DISABLE_REDIRECTION_CONFIGURATION). GFSH should always use the new redirect-output flag.
public class OSProcess {
private static final Logger logger = LogService.getLogger();
+ /**
+ * @deprecated use GFSH redirect-output flag instead.
+ */
+ @Deprecated
public static final String DISABLE_OUTPUT_REDIRECTION_PROPERTY =
DistributionConfig.GEMFIRE_PREFIX + "OSProcess.DISABLE_OUTPUT_REDIRECTION";
+
+ /**
+ * @deprecated use GFSH redirect-output flag instead.
+ */
+ @Deprecated
public static final String ENABLE_OUTPUT_REDIRECTION_PROPERTY =
DistributionConfig.GEMFIRE_PREFIX + "OSProcess.ENABLE_OUTPUT_REDIRECTION";
- private static final boolean DISABLE_OUTPUT_REDIRECTION =
- Boolean.getBoolean(DISABLE_OUTPUT_REDIRECTION_PROPERTY);
+ /**
+ * @deprecated use GFSH redirect-output flag instead.
+ */
+ @Deprecated
+ public static final String DISABLE_REDIRECTION_CONFIGURATION_PROPERTY =
+ DistributionConfig.GEMFIRE_PREFIX + "OSProcess.DISABLE_REDIRECTION_CONFIGURATION";
+
+ /**
+ * @deprecated use GFSH redirect-output flag instead.
+ */
+ @Deprecated
private static final boolean ENABLE_OUTPUT_REDIRECTION =
Boolean.getBoolean(ENABLE_OUTPUT_REDIRECTION_PROPERTY);
+ /**
+ * @deprecated use GFSH redirect-output flag instead.
+ */
+ @Deprecated
+ private static final boolean DISABLE_OUTPUT_REDIRECTION =
+ Boolean.getBoolean(DISABLE_OUTPUT_REDIRECTION_PROPERTY);
+
+ /**
+ * @deprecated use GFSH redirect-output flag instead.
+ */
+ @Deprecated
+ private static final boolean DISABLE_REDIRECTION_CONFIGURATION =
+ Boolean.getBoolean(DISABLE_REDIRECTION_CONFIGURATION_PROPERTY);
+
static final boolean pureMode = PureJavaMode.isPure();
static {
@@ -716,7 +752,8 @@ public class OSProcess {
}
final PrintStream newPrintStream =
new PrintStream(new BufferedOutputStream(newFileStream, 128), true);
- if (ENABLE_OUTPUT_REDIRECTION && !DISABLE_OUTPUT_REDIRECTION && setOut) {
+ if (((DISABLE_REDIRECTION_CONFIGURATION)
+ || (ENABLE_OUTPUT_REDIRECTION && !DISABLE_OUTPUT_REDIRECTION)) && setOut) {
System.setOut(newPrintStream);
if (System.err instanceof TeePrintStream) {
((TeePrintStream) System.err).getTeeOutputStream()
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StartLocatorCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StartLocatorCommand.java
index 1e6f5da..4d54323 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StartLocatorCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StartLocatorCommand.java
@@ -117,7 +117,10 @@ public class StartLocatorCommand implements GfshCommand {
@CliOption(key = CliStrings.START_LOCATOR__HTTP_SERVICE_PORT,
help = CliStrings.START_LOCATOR__HTTP_SERVICE_PORT__HELP) final Integer httpServicePort,
@CliOption(key = CliStrings.START_LOCATOR__HTTP_SERVICE_BIND_ADDRESS,
- help = CliStrings.START_LOCATOR__HTTP_SERVICE_BIND_ADDRESS__HELP) final String httpServiceBindAddress)
+ help = CliStrings.START_LOCATOR__HTTP_SERVICE_BIND_ADDRESS__HELP) final String httpServiceBindAddress,
+ @CliOption(key = CliStrings.START_LOCATOR__REDIRECT_OUTPUT, unspecifiedDefaultValue = "false",
+ specifiedDefaultValue = "true",
+ help = CliStrings.START_LOCATOR__REDIRECT_OUTPUT__HELP) final Boolean redirectOutput)
throws Exception {
if (StringUtils.isBlank(memberName)) {
// when the user doesn't give us a name, we make one up!
@@ -167,9 +170,6 @@ public class StartLocatorCommand implements GfshCommand {
StartMemberUtils.setPropertyIfNotNull(gemfireProperties,
ConfigurationProperties.JMX_MANAGER_HOSTNAME_FOR_CLIENTS, jmxManagerHostnameForClients);
- // read the OSProcess enable redirect system property here
- // TODO: replace with new GFSH argument
- final boolean redirectOutput = Boolean.getBoolean(OSProcess.ENABLE_OUTPUT_REDIRECTION_PROPERTY);
LocatorLauncher.Builder locatorLauncherBuilder =
new LocatorLauncher.Builder().setBindAddress(bindAddress).setForce(force).setPort(port)
.setRedirectOutput(redirectOutput).setWorkingDirectory(workingDirectory);
@@ -429,6 +429,10 @@ public class StartLocatorCommand implements GfshCommand {
commandLine.add("-Djava.awt.headless=true");
commandLine.add(
"-Dsun.rmi.dgc.server.gcInterval".concat("=").concat(Long.toString(Long.MAX_VALUE - 1)));
+ if (launcher.isRedirectingOutput()) {
+ commandLine
+ .add("-D".concat(OSProcess.DISABLE_REDIRECTION_CONFIGURATION_PROPERTY).concat("=true"));
+ }
commandLine.add(LocatorLauncher.class.getName());
commandLine.add(LocatorLauncher.Command.START.getName());
@@ -459,6 +463,7 @@ public class StartLocatorCommand implements GfshCommand {
if (launcher.isRedirectingOutput()) {
commandLine.add("--redirect-output");
}
+
return commandLine.toArray(new String[commandLine.size()]);
}
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StartServerCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StartServerCommand.java
index 3522701..c02de1a 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StartServerCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StartServerCommand.java
@@ -173,11 +173,13 @@ public class StartServerCommand implements GfshCommand {
@CliOption(key = CliStrings.START_SERVER__USERNAME, unspecifiedDefaultValue = "",
help = CliStrings.START_SERVER__USERNAME__HELP) final String userName,
@CliOption(key = CliStrings.START_SERVER__PASSWORD, unspecifiedDefaultValue = "",
- help = CliStrings.START_SERVER__PASSWORD__HELP) String passwordToUse)
- throws Exception
- // NOTICE: keep the parameters in alphabetical order based on their CliStrings.START_SERVER_* text
- {
-
+ help = CliStrings.START_SERVER__PASSWORD__HELP) String passwordToUse,
+ @CliOption(key = CliStrings.START_SERVER__REDIRECT_OUTPUT, unspecifiedDefaultValue = "false",
+ specifiedDefaultValue = "true",
+ help = CliStrings.START_SERVER__REDIRECT_OUTPUT__HELP) final Boolean redirectOutput)
+ throws Exception {
+ // NOTICE: keep the parameters in alphabetical order based on their CliStrings.START_SERVER_*
+ // text
if (StringUtils.isBlank(memberName)) {
// when the user doesn't give us a name, we make one up!
memberName = StartMemberUtils.getNameGenerator().generate('-');
@@ -273,10 +275,6 @@ public class StartServerCommand implements GfshCommand {
gemfireProperties.setProperty(ResourceConstants.PASSWORD, passwordToUse);
}
- // read the OSProcess enable redirect system property here -- TODO: replace with new GFSH
- // argument
- final boolean redirectOutput = Boolean.getBoolean(OSProcess.ENABLE_OUTPUT_REDIRECTION_PROPERTY);
-
ServerLauncher.Builder serverLauncherBuilder = new ServerLauncher.Builder()
.setAssignBuckets(assignBuckets).setDisableDefaultServer(disableDefaultServer)
.setForce(force).setRebalance(rebalance).setRedirectOutput(redirectOutput)
@@ -426,7 +424,10 @@ public class StartServerCommand implements GfshCommand {
commandLine.add("-Djava.awt.headless=true");
commandLine.add(
"-Dsun.rmi.dgc.server.gcInterval".concat("=").concat(Long.toString(Long.MAX_VALUE - 1)));
-
+ if (launcher.isRedirectingOutput()) {
+ commandLine
+ .add("-D".concat(OSProcess.DISABLE_REDIRECTION_CONFIGURATION_PROPERTY).concat("=true"));
+ }
commandLine.add(ServerLauncher.class.getName());
commandLine.add(ServerLauncher.Command.START.getName());
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 fbf7a9e..306f32e 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
@@ -2409,6 +2409,9 @@ public class CliStrings {
public static final String START_LOCATOR__HTTP_SERVICE_BIND_ADDRESS = "http-service-bind-address";
public static final String START_LOCATOR__HTTP_SERVICE_BIND_ADDRESS__HELP =
"The IP address on which the HTTP Service will be bound. By default, the Server is bound to all local addresses.";
+ public static final String START_LOCATOR__REDIRECT_OUTPUT = "redirect-output";
+ public static final String START_LOCATOR__REDIRECT_OUTPUT__HELP =
+ "Causes the member to redirect standard out and standard error to its own log file";
/* 'start manager' command */
public static final String START_MANAGER = "start manager";
@@ -3157,6 +3160,9 @@ public class CliStrings {
"Password to securely connect to the cluster.";
public static final String START_SERVER__MSG__PASSWORD_MUST_BE_SPECIFIED =
"password must be specified.";
+ public static final String START_SERVER__REDIRECT_OUTPUT = "redirect-output";
+ public static final String START_SERVER__REDIRECT_OUTPUT__HELP =
+ "Causes the member to redirect standard out and standard error to its own log file.";
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherBuilderTest.java b/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherBuilderTest.java
index cc01e6c..a91230a 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherBuilderTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherBuilderTest.java
@@ -88,6 +88,11 @@ public class LocatorLauncherBuilderTest {
}
@Test
+ public void getRedirectOutputReturnsNullByDefault() throws Exception {
+ assertThat(new LocatorLauncher.Builder().getRedirectOutput()).isNull();
+ }
+
+ @Test
public void getPortReturnsDefaultLocatorPortByDefault() throws Exception {
assertThat(new Builder().getPort()).isEqualTo(Integer.valueOf(DEFAULT_LOCATOR_PORT));
}
@@ -343,6 +348,13 @@ public class LocatorLauncherBuilderTest {
}
@Test
+ public void setRedirectOutputReturnsBuilderInstance() throws Exception {
+ LocatorLauncher.Builder builder = new LocatorLauncher.Builder();
+
+ assertThat(builder.setRedirectOutput(Boolean.TRUE)).isSameAs(builder);
+ }
+
+ @Test
public void parseArgumentsWithForceSetsForceToTrue() throws Exception {
Builder builder = new Builder();
@@ -473,7 +485,7 @@ public class LocatorLauncherBuilderTest {
LocatorLauncher launcher = builder.setCommand(Command.START).setDebug(true)
.setHostnameForClients("beanstock.vmware.com").setMemberName("Beanstock").setPort(8192)
- .build();
+ .setRedirectOutput(Boolean.TRUE).build();
assertThat(launcher.getCommand()).isEqualTo(builder.getCommand());
assertThat(launcher.isDebugging()).isTrue();
@@ -481,6 +493,7 @@ public class LocatorLauncherBuilderTest {
assertThat(launcher.getMemberName()).isEqualTo(builder.getMemberName());
assertThat(launcher.getPort()).isEqualTo(builder.getPort());
assertThat(launcher.getWorkingDirectory()).isEqualTo(builder.getWorkingDirectory());
+ assertThat(launcher.isRedirectingOutput()).isTrue();
assertThat(launcher.isHelping()).isFalse();
assertThat(launcher.isRunning()).isFalse();
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherBuilderTest.java b/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherBuilderTest.java
index 0f04a69..c9ea56b 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherBuilderTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherBuilderTest.java
@@ -115,6 +115,11 @@ public class ServerLauncherBuilderTest {
}
@Test
+ public void getRedirectOutputReturnsNullByDefault() throws Exception {
+ assertThat(new Builder().getRedirectOutput()).isNull();
+ }
+
+ @Test
public void getServerBindAddressReturnsNullByDefault() throws Exception {
assertThat(new Builder().getServerBindAddress()).isNull();
}
@@ -207,6 +212,13 @@ public class ServerLauncherBuilderTest {
}
@Test
+ public void setRedirectOutputReturnsBuilderInstance() throws Exception {
+ Builder builder = new Builder();
+
+ assertThat(builder.setRedirectOutput(Boolean.TRUE)).isSameAs(builder);
+ }
+
+ @Test
public void setServerPortReturnsBuilderInstance() throws Exception {
Builder builder = new Builder();
@@ -813,7 +825,7 @@ public class ServerLauncherBuilderTest {
.setServerBindAddress(InetAddress.getLocalHost().getHostAddress()).setServerPort(11235)
.setCriticalHeapPercentage(90.0f).setEvictionHeapPercentage(75.0f).setMaxConnections(100)
.setMaxMessageCount(512).setMaxThreads(8).setMessageTimeToLive(120000)
- .setSocketBufferSize(32768).build();
+ .setSocketBufferSize(32768).setRedirectOutput(Boolean.TRUE).build();
assertThat(launcher.getCommand()).isEqualTo(Command.STOP);
assertThat(launcher.getMemberName()).isEqualTo("serverOne");
@@ -832,6 +844,7 @@ public class ServerLauncherBuilderTest {
assertThat(launcher.isForcing()).isTrue();
assertThat(launcher.isHelping()).isFalse();
assertThat(launcher.isRebalancing()).isTrue();
+ assertThat(launcher.isRedirectingOutput()).isTrue();
assertThat(launcher.isRunning()).isFalse();
}
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserAutoCompletionTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserAutoCompletionTest.java
index 58f971a..86da02b 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserAutoCompletionTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserAutoCompletionTest.java
@@ -124,7 +124,7 @@ public class GfshParserAutoCompletionTest {
buffer = "start server --name=name1 --";
candidate = parser.complete(buffer);
assertThat(candidate.getCursor()).isEqualTo(buffer.length() - 2);
- assertThat(candidate.size()).isEqualTo(52);
+ assertThat(candidate.size()).isEqualTo(53);
assertTrue(candidate.getCandidates().contains(new Completion("--properties-file")));
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "J");
}
@@ -134,7 +134,7 @@ public class GfshParserAutoCompletionTest {
buffer = "start server --name=name1 ";
candidate = parser.complete(buffer);
assertThat(candidate.getCursor()).isEqualTo(buffer.length() - 1);
- assertThat(candidate.size()).isEqualTo(52);
+ assertThat(candidate.size()).isEqualTo(53);
assertTrue(candidate.getCandidates().contains(new Completion(" --properties-file")));
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "--J");
}
@@ -144,7 +144,7 @@ public class GfshParserAutoCompletionTest {
buffer = "start server --name=name1";
candidate = parser.complete(buffer);
assertThat(candidate.getCursor()).isEqualTo(buffer.length());
- assertThat(candidate.size()).isEqualTo(52);
+ assertThat(candidate.size()).isEqualTo(53);
assertTrue(candidate.getCandidates().contains(new Completion(" --properties-file")));
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + " --J");
}
@@ -169,7 +169,7 @@ public class GfshParserAutoCompletionTest {
public void testCompleteWithDash() throws Exception {
buffer = "start server --name=name1 --J=-Dfoo.bar --";
candidate = parser.complete(buffer);
- assertThat(candidate.size()).isEqualTo(51);
+ assertThat(candidate.size()).isEqualTo(52);
}
@Test
@@ -187,7 +187,7 @@ public class GfshParserAutoCompletionTest {
buffer = "start server --name=name1 --J=-Dtest=test1 --J=-Dfoo=bar";
candidate = parser.complete(buffer);
assertThat(candidate.getCursor()).isEqualTo(buffer.length());
- assertThat(candidate.size()).isEqualTo(51);
+ assertThat(candidate.size()).isEqualTo(52);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + " --assign-buckets");
}
@@ -196,7 +196,7 @@ public class GfshParserAutoCompletionTest {
buffer = "start server --J=-Dtest=test1 --J=-Dfoo=bar --name=name1";
candidate = parser.complete(buffer);
assertThat(candidate.getCursor()).isEqualTo(buffer.length());
- assertThat(candidate.size()).isEqualTo(51);
+ assertThat(candidate.size()).isEqualTo(52);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + " --assign-buckets");
}
@@ -205,7 +205,7 @@ public class GfshParserAutoCompletionTest {
buffer = "start server --name=name1 --locators=localhost --J=-Dfoo=bar";
candidate = parser.complete(buffer);
assertThat(candidate.getCursor()).isEqualTo(buffer.length());
- assertThat(candidate.size()).isEqualTo(50);
+ assertThat(candidate.size()).isEqualTo(51);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + " --assign-buckets");
}
@@ -214,7 +214,7 @@ public class GfshParserAutoCompletionTest {
buffer = "start server --name=name1 --locators=localhost --J=-Dfoo=bar --";
candidate = parser.complete(buffer);
assertThat(candidate.getCursor()).isEqualTo(buffer.length() - 2);
- assertThat(candidate.size()).isEqualTo(50);
+ assertThat(candidate.size()).isEqualTo(51);
assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "assign-buckets");
}
diff --git a/geode-pulse/build.gradle b/geode-pulse/build.gradle
index 1d0b6ae..8fd45e9 100755
--- a/geode-pulse/build.gradle
+++ b/geode-pulse/build.gradle
@@ -30,6 +30,8 @@ sourceSets {
dependencies {
compile 'org.springframework:spring-beans:' + project.'springframework.version'
+ // Needed to fully use log4j instead of commons-logging.
+ compile 'org.apache.logging.log4j:log4j-jcl:' + project.'log4j.version'
compile 'org.apache.logging.log4j:log4j-api:' + project.'log4j.version'
compile 'org.apache.logging.log4j:log4j-core:' + project.'log4j.version'
diff --git a/geode-web-api/build.gradle b/geode-web-api/build.gradle
index b55a9d9..9a6d592 100755
--- a/geode-web-api/build.gradle
+++ b/geode-web-api/build.gradle
@@ -64,6 +64,7 @@ dependencies {
}
war {
+ rootSpec.exclude("**/*commons-logging-*.jar")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
// this shouldn't be necessary but if it's not specified we're missing some of the jars
// from the runtime classpath
--
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <co...@geode.apache.org>'].