[
https://issues.apache.org/jira/browse/GEODE-4275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16332518#comment-16332518
]
ASF GitHub Bot commented on GEODE-4275:
---------------------------------------
jinmeiliao closed pull request #1270: GEODE-4275: Improved
StartMemberUtils.addMaxHeap
URL: https://github.com/apache/geode/pull/1270
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StartMemberUtils.java
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StartMemberUtils.java
index 3b0dbc7335..c2defa5ac1 100644
---
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StartMemberUtils.java
+++
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/StartMemberUtils.java
@@ -126,8 +126,16 @@ static void addInitialHeap(final List<String> commandLine,
final String initialH
static void addMaxHeap(final List<String> commandLine, final String maxHeap)
{
if (StringUtils.isNotBlank(maxHeap)) {
commandLine.add("-Xmx" + maxHeap);
- commandLine.add("-XX:+UseConcMarkSweepGC");
- commandLine.add("-XX:CMSInitiatingOccupancyFraction=" +
CMS_INITIAL_OCCUPANCY_FRACTION);
+
+ String collectorKey = "-XX:+UseConcMarkSweepGC";
+ if (!commandLine.contains(collectorKey)) {
+ commandLine.add(collectorKey);
+ }
+
+ String occupancyFractionKey = "-XX:CMSInitiatingOccupancyFraction=";
+ if (commandLine.stream().noneMatch(s ->
s.contains(occupancyFractionKey))) {
+ commandLine.add(occupancyFractionKey + CMS_INITIAL_OCCUPANCY_FRACTION);
+ }
}
}
diff --git
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/StartMemberUtilsTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/StartMemberUtilsTest.java
index 1fea6941e8..e0b327d29e 100644
---
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/StartMemberUtilsTest.java
+++
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/StartMemberUtilsTest.java
@@ -24,6 +24,10 @@
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
import org.apache.commons.io.FileUtils;
import org.junit.Rule;
@@ -101,6 +105,32 @@ public void testGeodeOnClasspathIsFirst() {
assertThat(gemfireClasspath).startsWith(customGeodeCore);
}
+ @Test
+ public void testAddMaxHeap() {
+ List<String> baseCommandLine = new ArrayList<>();
+
+ // Empty Max Heap Option
+ StartMemberUtils.addMaxHeap(baseCommandLine, null);
+ assertThat(baseCommandLine.size()).isEqualTo(0);
+
+ StartMemberUtils.addMaxHeap(baseCommandLine, "");
+ assertThat(baseCommandLine.size()).isEqualTo(0);
+
+ // Only Max Heap Option Set
+ StartMemberUtils.addMaxHeap(baseCommandLine, "32g");
+ assertThat(baseCommandLine.size()).isEqualTo(3);
+ assertThat(baseCommandLine).containsExactly("-Xmx32g",
"-XX:+UseConcMarkSweepGC",
+ "-XX:CMSInitiatingOccupancyFraction=" +
StartMemberUtils.CMS_INITIAL_OCCUPANCY_FRACTION);
+
+ // All Options Set
+ List<String> customCommandLine = new ArrayList<>(
+ Arrays.asList("-XX:+UseConcMarkSweepGC",
"-XX:CMSInitiatingOccupancyFraction=30"));
+ StartMemberUtils.addMaxHeap(customCommandLine, "16g");
+ assertThat(customCommandLine.size()).isEqualTo(3);
+ assertThat(customCommandLine).containsExactly("-XX:+UseConcMarkSweepGC",
+ "-XX:CMSInitiatingOccupancyFraction=30", "-Xmx16g");
+ }
+
private void writePid(final File pidFile, final int pid) throws IOException {
final FileWriter fileWriter = new FileWriter(pidFile, false);
fileWriter.write(String.valueOf(pid));
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Duplicate CMSInitiatingOccupancyFraction Startup Parameter
> ----------------------------------------------------------
>
> Key: GEODE-4275
> URL: https://issues.apache.org/jira/browse/GEODE-4275
> Project: Geode
> Issue Type: Bug
> Components: gfsh
> Reporter: Juan José Ramos Cassella
> Assignee: Juan José Ramos Cassella
> Priority: Major
> Labels: pull-request-available
>
> If you start a server/locator by specifying both {{max-heap}} and
> {{-XX:CMSInitiatingOccupancyFraction}}, logs show that a default
> {{CMSInitiatingOccupancyFraction`}} is also added in addition to the user
> specified value.
> As an example, the command {{start server --name=server1 --max-heap=1g
> --J=-XX:CMSInitiatingOccupancyFraction=50 --server-port=0}} produces the
> following output:
> {noformat}
> Command Line Parameters:
> -Dgemfire.start-dev-rest-api=false
> -Dgemfire.use-cluster-configuration=true
> -XX:CMSInitiatingOccupancyFraction=50
> -XX:OnOutOfMemoryError=kill -KILL %p
> -Xmx1g
> -XX:+UseConcMarkSweepGC
> -XX:CMSInitiatingOccupancyFraction=60
> -Dgemfire.launcher.registerSignalHandlers=true
> -Djava.awt.headless=true
> -Dsun.rmi.dgc.server.gcInterval=9223372036854775806
> {noformat}
> There are 2 entries for {{XX:CMSInitiatingOccupancyFraction}}.
> The problem resides within the {{addMaxHeap}} method of the
> {{StartMemberUtils}} class:
> {code:title=StartMemberUtils.java|borderStyle=solid}
> static void addMaxHeap(final List<String> commandLine, final String
> maxHeap) {
> if (StringUtils.isNotBlank(maxHeap)) {
> commandLine.add("-Xmx" + maxHeap);
> commandLine.add("-XX:+UseConcMarkSweepGC");
> commandLine.add("-XX:CMSInitiatingOccupancyFraction=" +
> CMS_INITIAL_OCCUPANCY_FRACTION);
> }
> }
> {code}
> The method is called by both the {{StartLocatorCommand}} and
> {{StartServerCommand}} after the jvmArgs have been already added to the
> parsed {{commandLine}}. The solution would be to simply check the collection
> before adding the {{-XX:CMSInitiatingOccupancyFraction}} option.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)