diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-10-08 12:29:44 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-10-08 12:30:07 +0200 |
commit | 4de2100bd331a130b6b790c51dc6226f0c65127a (patch) | |
tree | 93263c64571f73baf8332458e29aa1a351afe0d8 | |
parent | 31a65f34968937d01a7e6c64a117409f150b5c0f (diff) | |
download | sonarqube-4de2100bd331a130b6b790c51dc6226f0c65127a.tar.gz sonarqube-4de2100bd331a130b6b790c51dc6226f0c65127a.zip |
SONAR-5709 Add properties sonar.search.javaAdditionalOpts and sonar.web.javaAdditionalOpts
6 files changed, 28 insertions, 5 deletions
diff --git a/debug-server.sh b/debug-server.sh index 5dadb3becab..1d1549d9c4d 100755 --- a/debug-server.sh +++ b/debug-server.sh @@ -7,4 +7,4 @@ if ! ls sonarqube-*/bin/sonar-application*.jar &> /dev/null; then fi cd sonarqube-* -java -jar ./lib/sonar-application*.jar -Dsonar.web.javaOpts=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
\ No newline at end of file +java -jar ./lib/sonar-application*.jar -Dsonar.web.javaAdditionalOpts=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaCommand.java b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaCommand.java index 7750b6deb35..76abf52deba 100644 --- a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaCommand.java +++ b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaCommand.java @@ -19,6 +19,8 @@ */ package org.sonar.process.monitor; +import org.apache.commons.lang.StringUtils; + import javax.annotation.Nullable; import java.io.File; @@ -84,12 +86,16 @@ public class JavaCommand { } public JavaCommand addJavaOption(String s) { - javaOptions.add(s); + if (StringUtils.isNotBlank(s)) { + javaOptions.add(s); + } return this; } public JavaCommand addJavaOptions(String s) { - Collections.addAll(javaOptions, s.split(" ")); + for (String opt : s.split(" ")) { + addJavaOption(opt); + } return this; } diff --git a/server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/JavaCommandTest.java b/server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/JavaCommandTest.java index fbfbad11b54..689f061ff06 100644 --- a/server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/JavaCommandTest.java +++ b/server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/JavaCommandTest.java @@ -65,8 +65,13 @@ public class JavaCommandTest { } @Test - public void split_java_options() throws Exception { + public void add_java_options() throws Exception { JavaCommand command = new JavaCommand("foo"); + assertThat(command.getJavaOptions()).isEmpty(); + + command.addJavaOptions(""); + assertThat(command.getJavaOptions()).isEmpty(); + command.addJavaOptions("-Xmx512m -Xms256m -Dfoo"); assertThat(command.getJavaOptions()).containsOnly("-Xmx512m", "-Xms256m", "-Dfoo"); } diff --git a/sonar-application/src/main/assembly/conf/sonar.properties b/sonar-application/src/main/assembly/conf/sonar.properties index f14700b3592..ff26347346f 100644 --- a/sonar-application/src/main/assembly/conf/sonar.properties +++ b/sonar-application/src/main/assembly/conf/sonar.properties @@ -69,6 +69,9 @@ sonar.jdbc.timeBetweenEvictionRunsMillis=30000 #sonar.web.javaOpts=-Xmx768m -XX:MaxPermSize=160m -XX:+HeapDumpOnOutOfMemoryError \ # -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djruby.management.enabled=false +# Same as previous property, but allows to not repeat all settings like -Djava.awt.headless=true +#sonar.web.javaAdditionalOpts= + # Binding IP address. For servers with more than one IP address, this property specifies which # address will be used for listening on the specified ports. # By default, ports will be used on all IP addresses associated with the server. @@ -173,6 +176,9 @@ sonar.jdbc.timeBetweenEvictionRunsMillis=30000 # -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError \ # -Djava.awt.headless=true +# Same as previous property, but allows to not repeat all settings like -Djava.awt.headless=true +#sonar.search.javaAdditionalOpts= + # Elasticsearch port. Default is 9001. Use 0 to get a free port. # This port must be private and must not be exposed to the Internet. #sonar.search.port=9001 diff --git a/sonar-application/src/main/java/org/sonar/application/App.java b/sonar-application/src/main/java/org/sonar/application/App.java index 502cf561394..ff8016fabc8 100644 --- a/sonar-application/src/main/java/org/sonar/application/App.java +++ b/sonar-application/src/main/java/org/sonar/application/App.java @@ -70,7 +70,8 @@ public class App implements Stoppable { JavaCommand elasticsearch = new JavaCommand("search"); elasticsearch .setWorkDir(homeDir) - .addJavaOptions(props.value(DefaultSettings.SEARCH_JAVA_OPTS)) + .addJavaOptions(props.nonNullValue(DefaultSettings.SEARCH_JAVA_OPTS)) + .addJavaOptions(props.nonNullValue(DefaultSettings.SEARCH_JAVA_ADDITIONAL_OPTS)) .setTempDir(tempDir.getAbsoluteFile()) .setClassName("org.sonar.search.SearchServer") .setArguments(props.rawProperties()) @@ -83,6 +84,7 @@ public class App implements Stoppable { JavaCommand webServer = new JavaCommand("web") .setWorkDir(homeDir) .addJavaOptions(props.nonNullValue(DefaultSettings.WEB_JAVA_OPTS)) + .addJavaOptions(props.nonNullValue(DefaultSettings.WEB_JAVA_ADDITIONAL_OPTS)) .setTempDir(tempDir.getAbsoluteFile()) // required for logback tomcat valve .setEnvVariable("sonar.path.logs", props.nonNullValue("sonar.path.logs")) diff --git a/sonar-application/src/main/java/org/sonar/application/DefaultSettings.java b/sonar-application/src/main/java/org/sonar/application/DefaultSettings.java index 701249f5f63..4a936789499 100644 --- a/sonar-application/src/main/java/org/sonar/application/DefaultSettings.java +++ b/sonar-application/src/main/java/org/sonar/application/DefaultSettings.java @@ -36,7 +36,9 @@ class DefaultSettings { static final String CLUSTER_NODE_NAME = "sonar.node.name"; static final String SEARCH_PORT = "sonar.search.port"; static final String SEARCH_JAVA_OPTS = "sonar.search.javaOpts"; + static final String SEARCH_JAVA_ADDITIONAL_OPTS = "sonar.search.javaAdditionalOpts"; static final String WEB_JAVA_OPTS = "sonar.web.javaOpts"; + static final String WEB_JAVA_ADDITIONAL_OPTS = "sonar.web.javaAdditionalOpts"; static final String JDBC_URL = "sonar.jdbc.url"; static final String JDBC_LOGIN = "sonar.jdbc.username"; static final String JDBC_PASSWORD = "sonar.jdbc.password"; @@ -70,9 +72,11 @@ class DefaultSettings { defaults.put(SEARCH_JAVA_OPTS, "-Xmx256m -Xms256m -Xss256k -Djava.net.preferIPv4Stack=true " + "-XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly " + "-XX:+HeapDumpOnOutOfMemoryError -Djava.awt.headless=true"); + defaults.put(SEARCH_JAVA_ADDITIONAL_OPTS, ""); defaults.put(CLUSTER_NODE_NAME, "sonar-" + System.currentTimeMillis()); defaults.put(WEB_JAVA_OPTS, "-Xmx768m -XX:MaxPermSize=160m -XX:+HeapDumpOnOutOfMemoryError -Djava.net.preferIPv4Stack=true " + "-Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djruby.management.enabled=false"); + defaults.put(WEB_JAVA_ADDITIONAL_OPTS, ""); defaults.put(JDBC_URL, "jdbc:h2:tcp://localhost:9092/sonar"); defaults.put(JDBC_LOGIN, "sonar"); defaults.put(JDBC_PASSWORD, "sonar"); |