aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java')
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java194
1 files changed, 112 insertions, 82 deletions
diff --git a/server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java b/server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java
index 853729068bb..a2c62187550 100644
--- a/server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java
+++ b/server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java
@@ -21,9 +21,13 @@ package org.sonar.process;
import java.net.InetAddress;
import java.net.UnknownHostException;
+import java.util.Arrays;
import java.util.Map;
+import java.util.Objects;
import java.util.Properties;
import java.util.UUID;
+import java.util.stream.Collectors;
+import javax.annotation.Nullable;
/**
* Constants shared by search, web server and app processes.
@@ -31,61 +35,110 @@ import java.util.UUID;
*/
public class ProcessProperties {
- public static final String JDBC_URL = "sonar.jdbc.url";
- public static final String JDBC_DRIVER_PATH = "sonar.jdbc.driverPath";
- public static final String JDBC_MAX_ACTIVE = "sonar.jdbc.maxActive";
- public static final String JDBC_MAX_IDLE = "sonar.jdbc.maxIdle";
- public static final String JDBC_MIN_IDLE = "sonar.jdbc.minIdle";
- public static final String JDBC_MAX_WAIT = "sonar.jdbc.maxWait";
- public static final String JDBC_MIN_EVICTABLE_IDLE_TIME_MILLIS = "sonar.jdbc.minEvictableIdleTimeMillis";
- public static final String JDBC_TIME_BETWEEN_EVICTION_RUNS_MILLIS = "sonar.jdbc.timeBetweenEvictionRunsMillis";
- public static final String JDBC_EMBEDDED_PORT = "sonar.embeddedDatabase.port";
-
- public static final String PATH_DATA = "sonar.path.data";
- public static final String PATH_HOME = "sonar.path.home";
- public static final String PATH_LOGS = "sonar.path.logs";
- public static final String PATH_TEMP = "sonar.path.temp";
- public static final String PATH_WEB = "sonar.path.web";
-
- public static final String SEARCH_HOST = "sonar.search.host";
- public static final String SEARCH_PORT = "sonar.search.port";
- public static final String SEARCH_HTTP_PORT = "sonar.search.httpPort";
- public static final String SEARCH_JAVA_OPTS = "sonar.search.javaOpts";
- public static final String SEARCH_JAVA_ADDITIONAL_OPTS = "sonar.search.javaAdditionalOpts";
- public static final String SEARCH_REPLICAS = "sonar.search.replicas";
- public static final String SEARCH_MINIMUM_MASTER_NODES = "sonar.search.minimumMasterNodes";
- public static final String SEARCH_INITIAL_STATE_TIMEOUT = "sonar.search.initialStateTimeout";
-
- public static final String WEB_JAVA_OPTS = "sonar.web.javaOpts";
- public static final String WEB_JAVA_ADDITIONAL_OPTS = "sonar.web.javaAdditionalOpts";
- public static final String WEB_PORT = "sonar.web.port";
- public static final String AUTH_JWT_SECRET = "sonar.auth.jwtBase64Hs256Secret";
-
- public static final String CE_JAVA_OPTS = "sonar.ce.javaOpts";
- public static final String CE_JAVA_ADDITIONAL_OPTS = "sonar.ce.javaAdditionalOpts";
-
- /**
- * Used by Orchestrator to ask for shutdown of monitor process
- */
- public static final String ENABLE_STOP_COMMAND = "sonar.enableStopCommand";
-
- public static final String HTTP_PROXY_HOST = "http.proxyHost";
- public static final String HTTPS_PROXY_HOST = "https.proxyHost";
- public static final String HTTP_PROXY_PORT = "http.proxyPort";
- public static final String HTTPS_PROXY_PORT = "https.proxyPort";
- public static final String HTTP_PROXY_USER = "http.proxyUser";
- public static final String HTTP_PROXY_PASSWORD = "http.proxyPassword";
-
- public static final String CLUSTER_ENABLED = "sonar.cluster.enabled";
- public static final String CLUSTER_NODE_TYPE = "sonar.cluster.node.type";
- public static final String CLUSTER_SEARCH_HOSTS = "sonar.cluster.search.hosts";
- public static final String CLUSTER_HOSTS = "sonar.cluster.hosts";
- public static final String CLUSTER_NODE_PORT = "sonar.cluster.node.port";
- public static final int CLUSTER_NODE_PORT_DEFAULT_VALUE = 9003;
- public static final String CLUSTER_NODE_HOST = "sonar.cluster.node.host";
- public static final String CLUSTER_NODE_NAME = "sonar.cluster.node.name";
- public static final String CLUSTER_NAME = "sonar.cluster.name";
- public static final String CLUSTER_WEB_STARTUP_LEADER = "sonar.cluster.web.startupLeader";
+ public enum Property {
+ JDBC_URL("sonar.jdbc.url"),
+ JDBC_USERNAME("sonar.jdbc.username", ""),
+ JDBC_PASSWORD("sonar.jdbc.password", ""),
+ JDBC_DRIVER_PATH("sonar.jdbc.driverPath"),
+ JDBC_MAX_ACTIVE("sonar.jdbc.maxActive", "60"),
+ JDBC_MAX_IDLE("sonar.jdbc.maxIdle", "5"),
+ JDBC_MIN_IDLE("sonar.jdbc.minIdle", "2"),
+ JDBC_MAX_WAIT("sonar.jdbc.maxWait", "5000"),
+ JDBC_MIN_EVICTABLE_IDLE_TIME_MILLIS("sonar.jdbc.minEvictableIdleTimeMillis", "600000"),
+ JDBC_TIME_BETWEEN_EVICTION_RUNS_MILLIS("sonar.jdbc.timeBetweenEvictionRunsMillis", "30000"),
+ JDBC_EMBEDDED_PORT("sonar.embeddedDatabase.port"),
+
+ PATH_DATA("sonar.path.data", "data"),
+ PATH_HOME("sonar.path.home"),
+ PATH_LOGS("sonar.path.logs", "logs"),
+ PATH_TEMP("sonar.path.temp", "temp"),
+ PATH_WEB("sonar.path.web", "web"),
+
+ SEARCH_HOST("sonar.search.host", InetAddress.getLoopbackAddress().getHostAddress()),
+ SEARCH_PORT("sonar.search.port", "9001"),
+ SEARCH_HTTP_PORT("sonar.search.httpPort"),
+ SEARCH_JAVA_OPTS("sonar.search.javaOpts", "-Xms512m -Xmx512m -XX:+HeapDumpOnOutOfMemoryError"),
+ SEARCH_JAVA_ADDITIONAL_OPTS("sonar.search.javaAdditionalOpts", ""),
+ SEARCH_REPLICAS("sonar.search.replicas"),
+ SEARCH_MINIMUM_MASTER_NODES("sonar.search.minimumMasterNodes"),
+ SEARCH_INITIAL_STATE_TIMEOUT("sonar.search.initialStateTimeout"),
+
+ WEB_JAVA_OPTS("sonar.web.javaOpts", "-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError"),
+ WEB_JAVA_ADDITIONAL_OPTS("sonar.web.javaAdditionalOpts", ""),
+ WEB_PORT("sonar.web.port"),
+
+ CE_JAVA_OPTS("sonar.ce.javaOpts", "-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError"),
+ CE_JAVA_ADDITIONAL_OPTS("sonar.ce.javaAdditionalOpts", ""),
+
+ HTTP_PROXY_HOST("http.proxyHost"),
+ HTTPS_PROXY_HOST("https.proxyHost"),
+ HTTP_PROXY_PORT("http.proxyPort"),
+ HTTPS_PROXY_PORT("https.proxyPort"),
+ HTTP_PROXY_USER("http.proxyUser"),
+ HTTP_PROXY_PASSWORD("http.proxyPassword"),
+ HTTP_NON_PROXY_HOSTS("http.nonProxyHosts"),
+ HTTP_AUTH_NLM_DOMAN("http.auth.ntlm.domain"),
+ SOCKS_PROXY_HOST("socksProxyHost"),
+ SOCKS_PROXY_PORT("socksProxyPort"),
+
+ CLUSTER_ENABLED("sonar.cluster.enabled", "false"),
+ CLUSTER_NODE_TYPE("sonar.cluster.node.type"),
+ CLUSTER_SEARCH_HOSTS("sonar.cluster.search.hosts"),
+ CLUSTER_HOSTS("sonar.cluster.hosts"),
+ CLUSTER_NODE_PORT("sonar.cluster.node.port", "9003"),
+ CLUSTER_NODE_HOST("sonar.cluster.node.host"),
+ CLUSTER_NODE_NAME("sonar.cluster.node.name", "sonarqube-" + UUID.randomUUID().toString()),
+ CLUSTER_NAME("sonar.cluster.name", "sonarqube"),
+ CLUSTER_WEB_STARTUP_LEADER("sonar.cluster.web.startupLeader"),
+
+ AUTH_JWT_SECRET("sonar.auth.jwtBase64Hs256Secret"),
+ SONAR_WEB_SSO_ENABLE("sonar.web.sso.enable", "false"),
+ SONAR_WEB_SSO_LOGIN_HEADER("sonar.web.sso.loginHeader", "X-Forwarded-Login"),
+ SONAR_WEB_SSO_NAME_HEADER("sonar.web.sso.nameHeader", "X-Forwarded-Name"),
+ SONAR_WEB_SSO_EMAIL_HEADER("sonar.web.sso.emailHeader", "X-Forwarded-Email"),
+ SONAR_WEB_SSO_GROUPS_HEADER("sonar.web.sso.groupsHeader", "X-Forwarded-Groups"),
+ SONAR_WEB_SSO_REFRESH_INTERVAL_IN_MINUTES("sonar.web.sso.refreshIntervalInMinutes", "5"),
+ SONAR_SECURITY_REALM("sonar.security.realm"),
+ SONAR_AUTHENTICATOR_IGNORE_STARTUP_FAILURE("sonar.authenticator.ignoreStartupFailure", "false"),
+
+ SONAR_TELEMETRY_ENABLE("sonar.telemetry.enable", "true"),
+ SONAR_TELEMETRY_URL("sonar.telemetry.url", "https://telemetry.sonarsource.com/sonarqube"),
+ SONAR_TELEMETRY_FREQUENCY_IN_SECONDS("sonar.telemetry.frequencyInSeconds", "21600"),
+
+ SONAR_UPDATECENTER_ACTIVATE("sonar.updatecenter.activate", "true"),
+
+ SONARCLOUD_ENABLED("sonar.sonarcloud.enabled", "false"),
+
+ /**
+ * Used by Orchestrator to ask for shutdown of monitor process
+ */
+ ENABLE_STOP_COMMAND("sonar.enableStopCommand");
+
+ private final String key;
+ private final String defaultValue;
+
+ Property(String key, @Nullable String defaultValue) {
+ this.key = key;
+ this.defaultValue = defaultValue;
+ }
+
+ Property(String key) {
+ this(key, null);
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public String getDefaultValue() {
+ Objects.requireNonNull(defaultValue, "There's no default value on this property");
+ return defaultValue;
+ }
+
+ public boolean hasDefaultValue() {
+ return defaultValue != null;
+ }
+ }
private ProcessProperties() {
// only static stuff
@@ -97,37 +150,14 @@ public class ProcessProperties {
props.setDefault(entry.getKey().toString(), entry.getValue().toString());
}
- fixPortIfZero(props, SEARCH_HOST, SEARCH_PORT);
+ fixPortIfZero(props, Property.SEARCH_HOST.getKey(), Property.SEARCH_PORT.getKey());
}
public static Properties defaults() {
Properties defaults = new Properties();
- defaults.put(SEARCH_HOST, InetAddress.getLoopbackAddress().getHostAddress());
- defaults.put(SEARCH_PORT, "9001");
- defaults.put(SEARCH_JAVA_OPTS, "-Xms512m -Xmx512m -XX:+HeapDumpOnOutOfMemoryError");
- defaults.put(SEARCH_JAVA_ADDITIONAL_OPTS, "");
-
- defaults.put(PATH_DATA, "data");
- defaults.put(PATH_LOGS, "logs");
- defaults.put(PATH_TEMP, "temp");
- defaults.put(PATH_WEB, "web");
-
- defaults.put(WEB_JAVA_OPTS, "-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError");
- defaults.put(WEB_JAVA_ADDITIONAL_OPTS, "");
- defaults.put(CE_JAVA_OPTS, "-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError");
- defaults.put(CE_JAVA_ADDITIONAL_OPTS, "");
- defaults.put(JDBC_MAX_ACTIVE, "60");
- defaults.put(JDBC_MAX_IDLE, "5");
- defaults.put(JDBC_MIN_IDLE, "2");
- defaults.put(JDBC_MAX_WAIT, "5000");
- defaults.put(JDBC_MIN_EVICTABLE_IDLE_TIME_MILLIS, "600000");
- defaults.put(JDBC_TIME_BETWEEN_EVICTION_RUNS_MILLIS, "30000");
-
- defaults.put(CLUSTER_ENABLED, "false");
- defaults.put(CLUSTER_NAME, "sonarqube");
- defaults.put(CLUSTER_NODE_PORT, Integer.toString(CLUSTER_NODE_PORT_DEFAULT_VALUE));
- defaults.put(CLUSTER_NODE_NAME, "sonarqube-" + UUID.randomUUID().toString());
-
+ defaults.putAll(Arrays.stream(Property.values())
+ .filter(Property::hasDefaultValue)
+ .collect(Collectors.toMap(Property::getKey, Property::getDefaultValue)));
return defaults;
}