aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-application/src/main/java
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2014-10-08 22:09:55 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2014-10-08 22:36:37 +0200
commit3794337ce0d72a52a8d73299cc74a46962a2c2b7 (patch)
treefb07b8f301a389d4c8ca08d578c8caa52dff58d9 /sonar-application/src/main/java
parent563d55544b89fd5356c08e880c463da418eef096 (diff)
downloadsonarqube-3794337ce0d72a52a8d73299cc74a46962a2c2b7.tar.gz
sonarqube-3794337ce0d72a52a8d73299cc74a46962a2c2b7.zip
Central definition of properties shared by ES, web and monitor processes
Diffstat (limited to 'sonar-application/src/main/java')
-rw-r--r--sonar-application/src/main/java/org/sonar/application/App.java23
-rw-r--r--sonar-application/src/main/java/org/sonar/application/DefaultSettings.java35
-rw-r--r--sonar-application/src/main/java/org/sonar/application/JdbcSettings.java7
-rw-r--r--sonar-application/src/main/java/org/sonar/application/PropsBuilder.java11
4 files changed, 33 insertions, 43 deletions
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 9c027abebdf..f0a859435ef 100644
--- a/sonar-application/src/main/java/org/sonar/application/App.java
+++ b/sonar-application/src/main/java/org/sonar/application/App.java
@@ -23,6 +23,7 @@ import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import org.sonar.process.MinimumViableSystem;
import org.sonar.process.ProcessCommands;
+import org.sonar.process.ProcessConstants;
import org.sonar.process.ProcessLogging;
import org.sonar.process.Props;
import org.sonar.process.StopWatcher;
@@ -52,9 +53,9 @@ public class App implements Stoppable {
}
public void start(Props props) {
- if (props.valueAsBoolean("sonar.enableStopCommand", false)) {
+ if (props.valueAsBoolean(ProcessConstants.ENABLE_STOP_COMMAND, false)) {
// stop application when file <temp>/app.stop is created
- File tempDir = props.nonNullValueAsFile("sonar.path.temp");
+ File tempDir = props.nonNullValueAsFile(ProcessConstants.PATH_TEMP);
ProcessCommands commands = new ProcessCommands(tempDir, "app");
stopWatcher = new StopWatcher(commands, this);
stopWatcher.start();
@@ -65,14 +66,14 @@ public class App implements Stoppable {
List<JavaCommand> createCommands(Props props) {
List<JavaCommand> commands = new ArrayList<JavaCommand>();
- File homeDir = props.nonNullValueAsFile("sonar.path.home");
- File tempDir = props.nonNullValueAsFile("sonar.path.temp");
+ File homeDir = props.nonNullValueAsFile(ProcessConstants.PATH_HOME);
+ File tempDir = props.nonNullValueAsFile(ProcessConstants.PATH_TEMP);
JavaCommand elasticsearch = new JavaCommand("search");
elasticsearch
.setWorkDir(homeDir)
.addJavaOptions("-Djava.awt.headless=true")
- .addJavaOptions(props.nonNullValue(DefaultSettings.SEARCH_JAVA_OPTS))
- .addJavaOptions(props.nonNullValue(DefaultSettings.SEARCH_JAVA_ADDITIONAL_OPTS))
+ .addJavaOptions(props.nonNullValue(ProcessConstants.SEARCH_JAVA_OPTS))
+ .addJavaOptions(props.nonNullValue(ProcessConstants.SEARCH_JAVA_ADDITIONAL_OPTS))
.setTempDir(tempDir.getAbsoluteFile())
.setClassName("org.sonar.search.SearchServer")
.setArguments(props.rawProperties())
@@ -81,20 +82,20 @@ public class App implements Stoppable {
commands.add(elasticsearch);
// do not yet start SQ in cluster mode. See SONAR-5483 & SONAR-5391
- if (StringUtils.isEmpty(props.value(DefaultSettings.CLUSTER_MASTER))) {
+ if (StringUtils.isEmpty(props.value(ProcessConstants.CLUSTER_MASTER_HOSTS))) {
JavaCommand webServer = new JavaCommand("web")
.setWorkDir(homeDir)
.addJavaOptions("-Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djruby.management.enabled=false")
- .addJavaOptions(props.nonNullValue(DefaultSettings.WEB_JAVA_OPTS))
- .addJavaOptions(props.nonNullValue(DefaultSettings.WEB_JAVA_ADDITIONAL_OPTS))
+ .addJavaOptions(props.nonNullValue(ProcessConstants.WEB_JAVA_OPTS))
+ .addJavaOptions(props.nonNullValue(ProcessConstants.WEB_JAVA_ADDITIONAL_OPTS))
.setTempDir(tempDir.getAbsoluteFile())
// required for logback tomcat valve
- .setEnvVariable("sonar.path.logs", props.nonNullValue("sonar.path.logs"))
+ .setEnvVariable(ProcessConstants.PATH_LOGS, props.nonNullValue(ProcessConstants.PATH_LOGS))
.setClassName("org.sonar.server.app.WebServer")
.setArguments(props.rawProperties())
.addClasspath("./lib/common/*")
.addClasspath("./lib/server/*");
- String driverPath = props.value(JdbcSettings.PROPERTY_DRIVER_PATH);
+ String driverPath = props.value(ProcessConstants.JDBC_DRIVER_PATH);
if (driverPath != null) {
webServer.addClasspath(driverPath);
}
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 4a936789499..3a710e779c5 100644
--- a/sonar-application/src/main/java/org/sonar/application/DefaultSettings.java
+++ b/sonar-application/src/main/java/org/sonar/application/DefaultSettings.java
@@ -20,6 +20,7 @@
package org.sonar.application;
import org.sonar.process.NetworkUtils;
+import org.sonar.process.ProcessConstants;
import org.sonar.process.Props;
import java.util.HashMap;
@@ -31,21 +32,9 @@ class DefaultSettings {
// only static stuff
}
- static final String CLUSTER_MASTER = "sonar.cluster.master";
- static final String CLUSTER_NAME = "sonar.cluster.name";
- 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";
-
static void init(Props props) {
// forced property
- props.set("sonar.search.type", "TRANSPORT");
+ props.set(ProcessConstants.SEARCH_TYPE, "TRANSPORT");
// init string properties
for (Map.Entry<String, String> entry : defaults().entrySet()) {
@@ -68,24 +57,24 @@ class DefaultSettings {
private static Map<String, String> defaults() {
Map<String, String> defaults = new HashMap<String, String>();
- defaults.put(CLUSTER_NAME, "sonarqube");
- defaults.put(SEARCH_JAVA_OPTS, "-Xmx256m -Xms256m -Xss256k -Djava.net.preferIPv4Stack=true " +
+ defaults.put(ProcessConstants.CLUSTER_NAME, "sonarqube");
+ defaults.put(ProcessConstants.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 " +
+ defaults.put(ProcessConstants.SEARCH_JAVA_ADDITIONAL_OPTS, "");
+ defaults.put(ProcessConstants.CLUSTER_NODE_NAME, "sonar-" + System.currentTimeMillis());
+ defaults.put(ProcessConstants.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");
+ defaults.put(ProcessConstants.WEB_JAVA_ADDITIONAL_OPTS, "");
+ defaults.put(ProcessConstants.JDBC_URL, "jdbc:h2:tcp://localhost:9092/sonar");
+ defaults.put(ProcessConstants.JDBC_LOGIN, "sonar");
+ defaults.put(ProcessConstants.JDBC_PASSWORD, "sonar");
return defaults;
}
private static Map<String, Integer> defaultPorts() {
Map<String, Integer> defaults = new HashMap<String, Integer>();
- defaults.put(SEARCH_PORT, 9001);
+ defaults.put(ProcessConstants.SEARCH_PORT, 9001);
return defaults;
}
}
diff --git a/sonar-application/src/main/java/org/sonar/application/JdbcSettings.java b/sonar-application/src/main/java/org/sonar/application/JdbcSettings.java
index 20e32cacd02..294eed9a108 100644
--- a/sonar-application/src/main/java/org/sonar/application/JdbcSettings.java
+++ b/sonar-application/src/main/java/org/sonar/application/JdbcSettings.java
@@ -22,6 +22,7 @@ package org.sonar.application;
import org.apache.commons.io.FileUtils;
import org.slf4j.LoggerFactory;
import org.sonar.process.MessageException;
+import org.sonar.process.ProcessConstants;
import org.sonar.process.Props;
import javax.annotation.CheckForNull;
@@ -36,8 +37,6 @@ import java.util.regex.Pattern;
public class JdbcSettings {
- static final String PROPERTY_DRIVER_PATH = "sonar.jdbc.driverPath";
-
static enum Provider {
h2(null), jtds("lib/jdbc/jtds"), mysql("lib/jdbc/mysql"), oracle("extensions/jdbc-driver/oracle"),
postgresql("lib/jdbc/postgresql");
@@ -50,12 +49,12 @@ public class JdbcSettings {
}
public void checkAndComplete(File homeDir, Props props) {
- String url = props.nonNullValue(DefaultSettings.JDBC_URL);
+ String url = props.nonNullValue(ProcessConstants.JDBC_URL);
Provider provider = driverProvider(url);
checkUrlParameters(provider, url);
String driverPath = driverPath(homeDir, provider);
if (driverPath != null) {
- props.set(PROPERTY_DRIVER_PATH, driverPath);
+ props.set(ProcessConstants.JDBC_DRIVER_PATH, driverPath);
}
}
diff --git a/sonar-application/src/main/java/org/sonar/application/PropsBuilder.java b/sonar-application/src/main/java/org/sonar/application/PropsBuilder.java
index f736658db7b..1873448fb96 100644
--- a/sonar-application/src/main/java/org/sonar/application/PropsBuilder.java
+++ b/sonar-application/src/main/java/org/sonar/application/PropsBuilder.java
@@ -22,6 +22,7 @@ package org.sonar.application;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.sonar.process.ConfigurationUtils;
+import org.sonar.process.ProcessConstants;
import org.sonar.process.Props;
import java.io.File;
@@ -53,7 +54,7 @@ class PropsBuilder {
Props build() throws IOException {
Properties p = loadPropertiesFile(homeDir);
p.putAll(rawProperties);
- p.setProperty("sonar.path.home", homeDir.getAbsolutePath());
+ p.setProperty(ProcessConstants.PATH_HOME, homeDir.getAbsolutePath());
p = ConfigurationUtils.interpolateVariables(p, System.getenv());
// the difference between Properties and Props is that the latter
@@ -63,9 +64,9 @@ class PropsBuilder {
DefaultSettings.init(props);
// init file system
- initExistingDir(props, "sonar.path.data", "data");
- initExistingDir(props, "sonar.path.web", "web");
- initExistingDir(props, "sonar.path.logs", "logs");
+ initExistingDir(props, ProcessConstants.PATH_DATA, "data");
+ initExistingDir(props, ProcessConstants.PATH_WEB, "web");
+ initExistingDir(props, ProcessConstants.PATH_LOGS, "logs");
initTempDir(props);
// check JDBC properties and set path to driver
@@ -94,7 +95,7 @@ class PropsBuilder {
}
private void initTempDir(Props props) throws IOException {
- File dir = configureDir(props, "sonar.path.temp", "temp");
+ File dir = configureDir(props, ProcessConstants.PATH_TEMP, "temp");
FileUtils.deleteQuietly(dir);
FileUtils.forceMkdir(dir);
}