diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-03-30 23:00:55 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-03-30 23:02:01 +0200 |
commit | b1e329a5182f8d611fdefe98ea7c3b5a54d2d7a3 (patch) | |
tree | 4b2cff21b1b9bb0b42ad3b5a7a255cd3c5fae984 /server | |
parent | fd36d975984c356164d7ca95f7a32ca7f339d2c7 (diff) | |
download | sonarqube-b1e329a5182f8d611fdefe98ea7c3b5a54d2d7a3.tar.gz sonarqube-b1e329a5182f8d611fdefe98ea7c3b5a54d2d7a3.zip |
SONAR-6293 refactor loading of default values of sonar.properties
Diffstat (limited to 'server')
40 files changed, 398 insertions, 317 deletions
diff --git a/server/sonar-process/src/main/java/org/sonar/process/LogbackHelper.java b/server/sonar-process/src/main/java/org/sonar/process/LogbackHelper.java index cb9bb6a8080..5ed5459c0c8 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/LogbackHelper.java +++ b/server/sonar-process/src/main/java/org/sonar/process/LogbackHelper.java @@ -94,7 +94,7 @@ public class LogbackHelper { public RollingPolicy createRollingPolicy(Context ctx, Props props, String filenamePrefix) { String rollingPolicy = props.value(ROLLING_POLICY_PROPERTY, "time:yyyy-MM-dd"); int maxFiles = props.valueAsInt(MAX_FILES_PROPERTY, 7); - File logsDir = props.nonNullValueAsFile(ProcessConstants.PATH_LOGS); + File logsDir = props.nonNullValueAsFile(ProcessProperties.PATH_LOGS); if (rollingPolicy.startsWith("time:")) { return new TimeRollingPolicy(ctx, filenamePrefix, logsDir, maxFiles, StringUtils.substringAfter(rollingPolicy, "time:")); diff --git a/server/sonar-process/src/main/java/org/sonar/process/ProcessConstants.java b/server/sonar-process/src/main/java/org/sonar/process/ProcessConstants.java deleted file mode 100644 index 4a078369d38..00000000000 --- a/server/sonar-process/src/main/java/org/sonar/process/ProcessConstants.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.process; - -/** - * Constants shared by search, web server and monitor processes. - * It represents more or less all the properties commented in conf/sonar.properties - */ -public interface ProcessConstants { - - String CLUSTER_ACTIVATE = "sonar.cluster.activate"; - String CLUSTER_MASTER = "sonar.cluster.master"; - String CLUSTER_MASTER_HOST = "sonar.cluster.masterHost"; - String CLUSTER_NAME = "sonar.cluster.name"; - String CLUSTER_NODE_NAME = "sonar.node.name"; - - String JDBC_URL = "sonar.jdbc.url"; - String JDBC_LOGIN = "sonar.jdbc.username"; - String JDBC_PASSWORD = "sonar.jdbc.password"; - String JDBC_DRIVER_PATH = "sonar.jdbc.driverPath"; - String JDBC_MAX_ACTIVE = "sonar.jdbc.maxActive"; - String JDBC_MAX_IDLE = "sonar.jdbc.maxIdle"; - String JDBC_MIN_IDLE = "sonar.jdbc.minIdle"; - String JDBC_MAX_WAIT = "sonar.jdbc.maxWait"; - String JDBC_MIN_EVICTABLE_IDLE_TIME_MILLIS = "sonar.jdbc.minEvictableIdleTimeMillis"; - String JDBC_TIME_BETWEEN_EVICTION_RUNS_MILLIS = "sonar.jdbc.timeBetweenEvictionRunsMillis"; - - String PATH_DATA = "sonar.path.data"; - String PATH_HOME = "sonar.path.home"; - String PATH_LOGS = "sonar.path.logs"; - String PATH_TEMP = "sonar.path.temp"; - String PATH_WEB = "sonar.path.web"; - - String SEARCH_HOST = "sonar.search.host"; - String SEARCH_PORT = "sonar.search.port"; - String SEARCH_JAVA_OPTS = "sonar.search.javaOpts"; - String SEARCH_JAVA_ADDITIONAL_OPTS = "sonar.search.javaAdditionalOpts"; - String SEARCH_TYPE = "sonar.search.type"; - - String WEB_JAVA_OPTS = "sonar.web.javaOpts"; - String WEB_JAVA_ADDITIONAL_OPTS = "sonar.web.javaAdditionalOpts"; - - /** - * Used by Orchestrator to ask for shutdown of monitor process - */ - String ENABLE_STOP_COMMAND = "sonar.enableStopCommand"; - - // Constants declared by the ES plugin ListUpdate (see sonar-search) - // that are used by sonar-server - String ES_PLUGIN_LISTUPDATE_SCRIPT_NAME = "listUpdate"; - String ES_PLUGIN_LISTUPDATE_ID_FIELD = "idField"; - String ES_PLUGIN_LISTUPDATE_ID_VALUE = "idValue"; - String ES_PLUGIN_LISTUPDATE_FIELD = "field"; - String ES_PLUGIN_LISTUPDATE_VALUE = "value"; -} 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 new file mode 100644 index 00000000000..9532d3bace2 --- /dev/null +++ b/server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java @@ -0,0 +1,134 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.process; + +import java.util.HashMap; +import java.util.Map; + +/** + * Constants shared by search, web server and app processes. + * They are almost all the properties defined in conf/sonar.properties. + */ +public class ProcessProperties { + + public static final String CLUSTER_ACTIVATE = "sonar.cluster.activate"; + public static final String CLUSTER_MASTER = "sonar.cluster.master"; + public static final String CLUSTER_MASTER_HOST = "sonar.cluster.masterHost"; + public static final String CLUSTER_NAME = "sonar.cluster.name"; + public static final String CLUSTER_NODE_NAME = "sonar.node.name"; + + public static final String JDBC_URL = "sonar.jdbc.url"; + public static final String JDBC_LOGIN = "sonar.jdbc.username"; + public static final String JDBC_PASSWORD = "sonar.jdbc.password"; + 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 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 WEB_JAVA_OPTS = "sonar.web.javaOpts"; + public static final String WEB_JAVA_ADDITIONAL_OPTS = "sonar.web.javaAdditionalOpts"; + + /** + * Used by Orchestrator to ask for shutdown of monitor process + */ + public static final String ENABLE_STOP_COMMAND = "sonar.enableStopCommand"; + + // Constants declared by the ES plugin ListUpdate (see sonar-search) + // that are used by sonar-server + public static final String ES_PLUGIN_LISTUPDATE_SCRIPT_NAME = "listUpdate"; + public static final String ES_PLUGIN_LISTUPDATE_ID_FIELD = "idField"; + public static final String ES_PLUGIN_LISTUPDATE_ID_VALUE = "idValue"; + public static final String ES_PLUGIN_LISTUPDATE_FIELD = "field"; + public static final String ES_PLUGIN_LISTUPDATE_VALUE = "value"; + + public static final String WEB_ENFORCED_JVM_ARGS = "-Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djruby.management.enabled=false " + + // jruby is slow with java 8: https://jira.codehaus.org/browse/SONAR-6115 + "-Djruby.compile.invokedynamic=false"; + + private ProcessProperties() { + // only static stuff + } + + public static void completeDefaults(Props props) { + // init string properties + for (Map.Entry<String, String> entry : defaults().entrySet()) { + props.setDefault(entry.getKey(), entry.getValue()); + } + + // init ports + for (Map.Entry<String, Integer> entry : defaultPorts().entrySet()) { + String key = entry.getKey(); + int port = props.valueAsInt(key, -1); + if (port == -1) { + // default port + props.set(key, String.valueOf((int) entry.getValue())); + } else if (port == 0) { + // pick one available port + props.set(key, String.valueOf(NetworkUtils.freePort())); + } + } + } + + public static Map<String, String> defaults() { + Map<String, String> defaults = new HashMap<>(); + defaults.put(ProcessProperties.CLUSTER_NAME, "sonarqube"); + defaults.put(ProcessProperties.CLUSTER_NODE_NAME, "sonar-" + System.currentTimeMillis()); + + defaults.put(ProcessProperties.SEARCH_HOST, "127.0.0.1"); + defaults.put(ProcessProperties.SEARCH_JAVA_OPTS, "-Xmx1G -Xms256m -Xss256k -Djava.net.preferIPv4Stack=true " + + "-XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly " + + "-XX:+HeapDumpOnOutOfMemoryError"); + defaults.put(ProcessProperties.SEARCH_JAVA_ADDITIONAL_OPTS, ""); + + defaults.put(ProcessProperties.WEB_JAVA_OPTS, "-Xmx768m -XX:MaxPermSize=160m -XX:+HeapDumpOnOutOfMemoryError -Djava.net.preferIPv4Stack=true"); + defaults.put(ProcessProperties.WEB_JAVA_ADDITIONAL_OPTS, ""); + defaults.put(ProcessProperties.JDBC_URL, "jdbc:h2:tcp://localhost:9092/sonar"); + defaults.put(ProcessProperties.JDBC_LOGIN, "sonar"); + defaults.put(ProcessProperties.JDBC_PASSWORD, "sonar"); + defaults.put(ProcessProperties.JDBC_MAX_ACTIVE, "50"); + defaults.put(ProcessProperties.JDBC_MAX_IDLE, "5"); + defaults.put(ProcessProperties.JDBC_MIN_IDLE, "2"); + defaults.put(ProcessProperties.JDBC_MAX_WAIT, "5000"); + defaults.put(ProcessProperties.JDBC_MIN_EVICTABLE_IDLE_TIME_MILLIS, "600000"); + defaults.put(ProcessProperties.JDBC_TIME_BETWEEN_EVICTION_RUNS_MILLIS, "30000"); + return defaults; + } + + private static Map<String, Integer> defaultPorts() { + Map<String, Integer> defaults = new HashMap<>(); + defaults.put(ProcessProperties.SEARCH_PORT, 9001); + return defaults; + } +} diff --git a/server/sonar-process/src/test/java/org/sonar/process/LogbackHelperTest.java b/server/sonar-process/src/test/java/org/sonar/process/LogbackHelperTest.java index 667a5632ebe..753d06e67c4 100644 --- a/server/sonar-process/src/test/java/org/sonar/process/LogbackHelperTest.java +++ b/server/sonar-process/src/test/java/org/sonar/process/LogbackHelperTest.java @@ -54,7 +54,7 @@ public class LogbackHelperTest { @Before public void setUp() throws Exception { File dir = temp.newFolder(); - props.set(ProcessConstants.PATH_LOGS, dir.getAbsolutePath()); + props.set(ProcessProperties.PATH_LOGS, dir.getAbsolutePath()); } @AfterClass diff --git a/server/sonar-process/src/test/java/org/sonar/process/ProcessPropertiesTest.java b/server/sonar-process/src/test/java/org/sonar/process/ProcessPropertiesTest.java new file mode 100644 index 00000000000..2a8cdddd3d7 --- /dev/null +++ b/server/sonar-process/src/test/java/org/sonar/process/ProcessPropertiesTest.java @@ -0,0 +1,65 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.process; + +import org.junit.Test; +import org.sonar.test.TestUtils; + +import java.util.Properties; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ProcessPropertiesTest { + + @Test + public void init_defaults() throws Exception { + Props props = new Props(new Properties()); + ProcessProperties.completeDefaults(props); + + assertThat(props.value("sonar.search.javaOpts")).contains("-Xmx"); + assertThat(props.value("sonar.jdbc.username")).isEqualTo("sonar"); + assertThat(props.valueAsInt("sonar.jdbc.maxActive")).isEqualTo(50); + } + + @Test + public void do_not_override_existing_properties() throws Exception { + Properties p = new Properties(); + p.setProperty("sonar.jdbc.username", "angela"); + Props props = new Props(p); + ProcessProperties.completeDefaults(props); + + assertThat(props.value("sonar.jdbc.username")).isEqualTo("angela"); + } + + @Test + public void use_random_port_if_zero() throws Exception { + Properties p = new Properties(); + p.setProperty("sonar.search.port", "0"); + Props props = new Props(p); + + ProcessProperties.completeDefaults(props); + assertThat(props.valueAsInt("sonar.search.port")).isGreaterThan(0); + } + + @Test + public void private_constructor() throws Exception { + assertThat(TestUtils.hasOnlyPrivateConstructors(ProcessProperties.class)).isTrue(); + } +} diff --git a/server/sonar-search/src/main/java/org/sonar/search/SearchServer.java b/server/sonar-search/src/main/java/org/sonar/search/SearchServer.java index fdc575277d2..13dde539c10 100644 --- a/server/sonar-search/src/main/java/org/sonar/search/SearchServer.java +++ b/server/sonar-search/src/main/java/org/sonar/search/SearchServer.java @@ -22,7 +22,6 @@ package org.sonar.search; import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.node.internal.InternalNode; -import org.slf4j.LoggerFactory; import org.sonar.process.MinimumViableSystem; import org.sonar.process.Monitored; import org.sonar.process.ProcessEntryPoint; @@ -40,8 +39,6 @@ public class SearchServer implements Monitored { @Override public void start() { - LoggerFactory.getLogger(SearchServer.class).info("Starting Elasticsearch[{}] on port {}", settings.clusterName(), settings.tcpPort()); - node = new InternalNode(settings.build(), false); node.start(); } diff --git a/server/sonar-search/src/main/java/org/sonar/search/SearchSettings.java b/server/sonar-search/src/main/java/org/sonar/search/SearchSettings.java index 6ae77559f27..bab755bc722 100644 --- a/server/sonar-search/src/main/java/org/sonar/search/SearchSettings.java +++ b/server/sonar-search/src/main/java/org/sonar/search/SearchSettings.java @@ -26,7 +26,7 @@ import org.elasticsearch.common.settings.Settings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.process.MessageException; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.process.Props; import org.sonar.search.script.ListUpdate; @@ -40,45 +40,22 @@ class SearchSettings { private static final Logger LOGGER = LoggerFactory.getLogger(SearchSettings.class); - public static final String PROP_HTTP_PORT = "sonar.search.httpPort"; public static final String PROP_MARVEL_HOSTS = "sonar.search.marvelHosts"; private final Props props; - private final Set<String> masterHosts = new LinkedHashSet<String>(); - private final String clusterName; - private final String hostName; - private final int tcpPort; + private final Set<String> masterHosts = new LinkedHashSet<>(); SearchSettings(Props props) { this.props = props; - masterHosts.addAll(Arrays.asList(StringUtils.split(props.value(ProcessConstants.CLUSTER_MASTER_HOST, ""), ","))); - clusterName = props.value(ProcessConstants.CLUSTER_NAME); - hostName = props.value(ProcessConstants.SEARCH_HOST); - Integer port = props.valueAsInt(ProcessConstants.SEARCH_PORT); - if (port == null) { - throw new MessageException("Property is not set: " + ProcessConstants.SEARCH_PORT); - } - tcpPort = port.intValue(); + masterHosts.addAll(Arrays.asList(StringUtils.split(props.value(ProcessProperties.CLUSTER_MASTER_HOST, ""), ","))); } boolean inCluster() { - return props.valueAsBoolean(ProcessConstants.CLUSTER_ACTIVATE, false); + return props.valueAsBoolean(ProcessProperties.CLUSTER_ACTIVATE, false); } boolean isMaster() { - return props.valueAsBoolean(ProcessConstants.CLUSTER_MASTER, false); - } - - String clusterName() { - return clusterName; - } - - int tcpPort() { - return tcpPort; - } - - String hostName() { - return hostName; + return props.valueAsBoolean(ProcessProperties.CLUSTER_MASTER, false); } Settings build() { @@ -93,11 +70,11 @@ class SearchSettings { } private void configureFileSystem(ImmutableSettings.Builder builder) { - File homeDir = props.nonNullValueAsFile(ProcessConstants.PATH_HOME); + File homeDir = props.nonNullValueAsFile(ProcessProperties.PATH_HOME); File dataDir, workDir, logDir; // data dir - String dataPath = props.value(ProcessConstants.PATH_DATA); + String dataPath = props.value(ProcessProperties.PATH_DATA); if (StringUtils.isNotEmpty(dataPath)) { dataDir = new File(dataPath, "es"); } else { @@ -106,7 +83,7 @@ class SearchSettings { builder.put("path.data", dataDir.getAbsolutePath()); // working dir - String workPath = props.value(ProcessConstants.PATH_TEMP); + String workPath = props.value(ProcessProperties.PATH_TEMP); if (StringUtils.isNotEmpty(workPath)) { workDir = new File(workPath); } else { @@ -116,7 +93,7 @@ class SearchSettings { builder.put("path.plugins", workDir.getAbsolutePath()); // log dir - String logPath = props.value(ProcessConstants.PATH_LOGS); + String logPath = props.value(ProcessProperties.PATH_LOGS); if (StringUtils.isNotEmpty(logPath)) { logDir = new File(logPath); } else { @@ -128,22 +105,25 @@ class SearchSettings { private void configurePlugins(ImmutableSettings.Builder builder) { builder .put("script.default_lang", "native") - .put(String.format("script.native.%s.type", ProcessConstants.ES_PLUGIN_LISTUPDATE_SCRIPT_NAME), + .put(String.format("script.native.%s.type", ProcessProperties.ES_PLUGIN_LISTUPDATE_SCRIPT_NAME), ListUpdate.UpdateListScriptFactory.class.getName()); } private void configureNetwork(ImmutableSettings.Builder builder) { + String host = props.value(ProcessProperties.SEARCH_HOST); + Integer port = props.valueAsInt(ProcessProperties.SEARCH_PORT); + LOGGER.info("Elasticsearch listening on {}:{}", host, port); + // disable multicast builder.put("discovery.zen.ping.multicast.enabled", "false"); - builder.put("transport.tcp.port", tcpPort); - if (hostName != null) { - builder.put("transport.host", hostName); - } + builder.put("transport.tcp.port", port); + builder.put("transport.host", host); + // Elasticsearch sets the default value of TCP reuse address to true only on non-MSWindows machines, but why ? builder.put("network.tcp.reuse_address", true); - Integer httpPort = props.valueAsInt(PROP_HTTP_PORT); - if (httpPort == null) { + Integer httpPort = props.valueAsInt(ProcessProperties.SEARCH_HTTP_PORT); + if (httpPort == null || httpPort < 0) { // standard configuration builder.put("http.enabled", false); } else { @@ -152,11 +132,7 @@ class SearchSettings { // see https://github.com/lmenezes/elasticsearch-kopf/issues/195 builder.put("http.cors.enabled", true); builder.put("http.enabled", true); - if (hostName != null) { - builder.put("http.host", hostName); - } else { - builder.put("http.host", "127.0.0.1"); - } + builder.put("http.host", host); builder.put("http.port", httpPort); } } @@ -181,18 +157,18 @@ class SearchSettings { builder.put("discovery.zen.minimum_master_nodes", 1); } else { throw new MessageException(String.format("Not an Elasticsearch master nor slave. Please check properties %s and %s", - ProcessConstants.CLUSTER_MASTER, ProcessConstants.CLUSTER_MASTER_HOST)); + ProcessProperties.CLUSTER_MASTER, ProcessProperties.CLUSTER_MASTER_HOST)); } } builder.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, replicationFactor); - builder.put("cluster.name", clusterName); + builder.put("cluster.name", props.value(ProcessProperties.CLUSTER_NAME)); builder.put("cluster.routing.allocation.awareness.attributes", "rack_id"); - builder.put("node.rack_id", props.value(ProcessConstants.CLUSTER_NODE_NAME, "unknown")); - builder.put("node.name", props.value(ProcessConstants.CLUSTER_NODE_NAME)); + builder.put("node.rack_id", props.value(ProcessProperties.CLUSTER_NODE_NAME, "unknown")); + builder.put("node.name", props.value(ProcessProperties.CLUSTER_NODE_NAME)); } private void configureMarvel(ImmutableSettings.Builder builder) { - Set<String> marvels = new TreeSet<String>(); + Set<String> marvels = new TreeSet<>(); marvels.addAll(Arrays.asList(StringUtils.split(props.value(PROP_MARVEL_HOSTS, ""), ","))); // If we're collecting indexing data send them to the Marvel host(s) diff --git a/server/sonar-search/src/main/java/org/sonar/search/script/ListUpdate.java b/server/sonar-search/src/main/java/org/sonar/search/script/ListUpdate.java index 721ba6b2328..587825f60f5 100644 --- a/server/sonar-search/src/main/java/org/sonar/search/script/ListUpdate.java +++ b/server/sonar-search/src/main/java/org/sonar/search/script/ListUpdate.java @@ -24,7 +24,7 @@ import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.script.AbstractExecutableScript; import org.elasticsearch.script.ExecutableScript; import org.elasticsearch.script.NativeScriptFactory; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import java.util.ArrayList; import java.util.Collection; @@ -36,25 +36,25 @@ public class ListUpdate extends AbstractExecutableScript { public static class UpdateListScriptFactory implements NativeScriptFactory { @Override public ExecutableScript newScript(@Nullable Map<String, Object> params) { - String idField = XContentMapValues.nodeStringValue(params.get(ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_FIELD), null); - String idValue = XContentMapValues.nodeStringValue(params.get(ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_VALUE), null); - String field = XContentMapValues.nodeStringValue(params.get(ProcessConstants.ES_PLUGIN_LISTUPDATE_FIELD), null); + String idField = XContentMapValues.nodeStringValue(params.get(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_FIELD), null); + String idValue = XContentMapValues.nodeStringValue(params.get(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_VALUE), null); + String field = XContentMapValues.nodeStringValue(params.get(ProcessProperties.ES_PLUGIN_LISTUPDATE_FIELD), null); Map value = null; if (idField == null) { - throw new IllegalStateException(String.format("Missing '%s' parameter", ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_FIELD)); + throw new IllegalStateException(String.format("Missing '%s' parameter", ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_FIELD)); } if (idValue == null) { - throw new IllegalStateException(String.format("Missing '%s' parameter", ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_VALUE)); + throw new IllegalStateException(String.format("Missing '%s' parameter", ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_VALUE)); } if (field == null) { - throw new IllegalStateException(String.format("Missing '%s' parameter", ProcessConstants.ES_PLUGIN_LISTUPDATE_FIELD)); + throw new IllegalStateException(String.format("Missing '%s' parameter", ProcessProperties.ES_PLUGIN_LISTUPDATE_FIELD)); } //NULL case is deletion of nested item - if (params.containsKey(ProcessConstants.ES_PLUGIN_LISTUPDATE_VALUE)) { - Object obj = params.get(ProcessConstants.ES_PLUGIN_LISTUPDATE_VALUE); + if (params.containsKey(ProcessProperties.ES_PLUGIN_LISTUPDATE_VALUE)) { + Object obj = params.get(ProcessProperties.ES_PLUGIN_LISTUPDATE_VALUE); if (obj != null) { - value = XContentMapValues.nodeMapValue(params.get(ProcessConstants.ES_PLUGIN_LISTUPDATE_VALUE), "Update item"); + value = XContentMapValues.nodeMapValue(params.get(ProcessProperties.ES_PLUGIN_LISTUPDATE_VALUE), "Update item"); } } diff --git a/server/sonar-search/src/test/java/org/sonar/search/SearchServerTest.java b/server/sonar-search/src/test/java/org/sonar/search/SearchServerTest.java index 3b012798916..bd8f49b511a 100644 --- a/server/sonar-search/src/test/java/org/sonar/search/SearchServerTest.java +++ b/server/sonar-search/src/test/java/org/sonar/search/SearchServerTest.java @@ -34,9 +34,10 @@ import org.junit.rules.TemporaryFolder; import org.junit.rules.TestRule; import org.junit.rules.Timeout; import org.sonar.process.NetworkUtils; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.process.Props; +import java.net.InetAddress; import java.util.Properties; import static org.assertj.core.api.Assertions.assertThat; @@ -70,16 +71,22 @@ public class SearchServerTest { @Test public void start_stop_server() throws Exception { Props props = new Props(new Properties()); - props.set(ProcessConstants.SEARCH_PORT, String.valueOf(port)); - props.set(ProcessConstants.CLUSTER_NAME, CLUSTER_NAME); - props.set(ProcessConstants.CLUSTER_NODE_NAME, "test"); - props.set(ProcessConstants.PATH_HOME, temp.newFolder().getAbsolutePath()); + // the following properties have always default values (see ProcessProperties) + String host = InetAddress.getLocalHost().getHostAddress(); + props.set(ProcessProperties.SEARCH_HOST, host); + props.set(ProcessProperties.SEARCH_PORT, String.valueOf(port)); + props.set(ProcessProperties.CLUSTER_NAME, CLUSTER_NAME); + props.set(ProcessProperties.CLUSTER_NODE_NAME, "test"); + props.set(ProcessProperties.PATH_HOME, temp.newFolder().getAbsolutePath()); searchServer = new SearchServer(props); searchServer.start(); assertThat(searchServer.isReady()).isTrue(); - client = getSearchClient(); + Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", CLUSTER_NAME).build(); + client = new TransportClient(settings) + .addTransportAddress(new InetSocketTransportAddress(host, port)); + assertThat(client.admin().cluster().prepareClusterStats().get().getStatus()).isEqualTo(ClusterHealthStatus.GREEN); searchServer.stop(); searchServer.awaitStop(); @@ -91,13 +98,4 @@ public class SearchServerTest { // ok } } - - private Client getSearchClient() { - Settings settings = ImmutableSettings.settingsBuilder() - .put("cluster.name", CLUSTER_NAME).build(); - Client client = new TransportClient(settings) - .addTransportAddress(new InetSocketTransportAddress("localhost", port)); - assertThat(client.admin().cluster().prepareClusterStats().get().getStatus()).isEqualTo(ClusterHealthStatus.GREEN); - return client; - } } diff --git a/server/sonar-search/src/test/java/org/sonar/search/SearchSettingsTest.java b/server/sonar-search/src/test/java/org/sonar/search/SearchSettingsTest.java index 59213c08f41..295eb86b94a 100644 --- a/server/sonar-search/src/test/java/org/sonar/search/SearchSettingsTest.java +++ b/server/sonar-search/src/test/java/org/sonar/search/SearchSettingsTest.java @@ -24,7 +24,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonar.process.MessageException; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.process.Props; import java.io.File; @@ -40,30 +40,17 @@ public class SearchSettingsTest { public TemporaryFolder temp = new TemporaryFolder(); @Test - public void fail_if_tcp_port_is_not_set() throws Exception { - try { - new SearchSettings(new Props(new Properties())); - fail(); - } catch (MessageException e) { - assertThat(e).hasMessage("Property is not set: sonar.search.port"); - } - } - - @Test public void test_default_settings() throws Exception { File homeDir = temp.newFolder(); Props props = new Props(new Properties()); - props.set(ProcessConstants.SEARCH_PORT, "1234"); - props.set(ProcessConstants.SEARCH_HOST, "127.0.0.1"); - props.set(ProcessConstants.PATH_HOME, homeDir.getAbsolutePath()); - props.set(ProcessConstants.CLUSTER_NAME, "tests"); - props.set(ProcessConstants.CLUSTER_NODE_NAME, "test"); + props.set(ProcessProperties.SEARCH_PORT, "1234"); + props.set(ProcessProperties.SEARCH_HOST, "127.0.0.1"); + props.set(ProcessProperties.PATH_HOME, homeDir.getAbsolutePath()); + props.set(ProcessProperties.CLUSTER_NAME, "tests"); + props.set(ProcessProperties.CLUSTER_NODE_NAME, "test"); SearchSettings searchSettings = new SearchSettings(props); assertThat(searchSettings.inCluster()).isFalse(); - assertThat(searchSettings.clusterName()).isEqualTo("tests"); - assertThat(searchSettings.tcpPort()).isEqualTo(1234); - assertThat(searchSettings.hostName()).isEqualTo("127.0.0.1"); Settings generated = searchSettings.build(); assertThat(generated.get("transport.tcp.port")).isEqualTo("1234"); @@ -89,24 +76,21 @@ public class SearchSettingsTest { SearchSettings searchSettings = new SearchSettings(props); assertThat(searchSettings.inCluster()).isFalse(); - assertThat(searchSettings.clusterName()).isEqualTo("tests"); - assertThat(searchSettings.tcpPort()).isEqualTo(1234); - assertThat(searchSettings.hostName()).isEqualTo(null); Settings generated = searchSettings.build(); - assertThat(generated.get("transport.tcp.port")).isEqualTo("1234"); - assertThat(generated.get("transport.host")).isEqualTo(null); - assertThat(generated.get("cluster.name")).isEqualTo("tests"); - assertThat(generated.get("node.name")).isEqualTo("test"); + assertThat(generated.get("transport.tcp.port")).isEqualTo("9001"); + assertThat(generated.get("transport.host")).isEqualTo("127.0.0.1"); + assertThat(generated.get("cluster.name")).isEqualTo("sonarqube"); + assertThat(generated.get("node.name")).startsWith("sonar-"); } @Test public void override_dirs() throws Exception { File dataDir = temp.newFolder(), logDir = temp.newFolder(), tempDir = temp.newFolder(); Props props = minProps(); - props.set(ProcessConstants.PATH_DATA, dataDir.getAbsolutePath()); - props.set(ProcessConstants.PATH_LOGS, logDir.getAbsolutePath()); - props.set(ProcessConstants.PATH_TEMP, tempDir.getAbsolutePath()); + props.set(ProcessProperties.PATH_DATA, dataDir.getAbsolutePath()); + props.set(ProcessProperties.PATH_LOGS, logDir.getAbsolutePath()); + props.set(ProcessProperties.PATH_TEMP, tempDir.getAbsolutePath()); Settings settings = new SearchSettings(props).build(); @@ -118,8 +102,8 @@ public class SearchSettingsTest { @Test public void test_cluster_master() throws Exception { Props props = minProps(); - props.set(ProcessConstants.CLUSTER_ACTIVATE, "true"); - props.set(ProcessConstants.CLUSTER_MASTER, "true"); + props.set(ProcessProperties.CLUSTER_ACTIVATE, "true"); + props.set(ProcessProperties.CLUSTER_MASTER, "true"); Settings settings = new SearchSettings(props).build(); assertThat(settings.get("index.number_of_replicas")).isEqualTo("1"); @@ -130,8 +114,8 @@ public class SearchSettingsTest { @Test public void test_cluster_slave() throws Exception { Props props = minProps(); - props.set(ProcessConstants.CLUSTER_ACTIVATE, "true"); - props.set(ProcessConstants.CLUSTER_MASTER_HOST, "127.0.0.2,127.0.0.3"); + props.set(ProcessProperties.CLUSTER_ACTIVATE, "true"); + props.set(ProcessProperties.CLUSTER_MASTER_HOST, "127.0.0.2,127.0.0.3"); Settings settings = new SearchSettings(props).build(); assertThat(settings.get("discovery.zen.ping.unicast.hosts")).isEqualTo("127.0.0.2,127.0.0.3"); @@ -141,11 +125,12 @@ public class SearchSettingsTest { @Test public void bad_cluster_configuration() throws Exception { Props props = minProps(); - props.set(ProcessConstants.CLUSTER_ACTIVATE, "true"); + props.set(ProcessProperties.CLUSTER_ACTIVATE, "true"); try { new SearchSettings(props).build(); fail(); - } catch (MessageException e) { + } catch (MessageException ignored) { + // expected } } @@ -161,7 +146,7 @@ public class SearchSettingsTest { @Test public void enable_http_connector() throws Exception { Props props = minProps(); - props.set(SearchSettings.PROP_HTTP_PORT, "9010"); + props.set(ProcessProperties.SEARCH_HTTP_PORT, "9010"); Settings settings = new SearchSettings(props).build(); assertThat(settings.get("http.port")).isEqualTo("9010"); @@ -172,8 +157,8 @@ public class SearchSettingsTest { @Test public void enable_http_connector_different_host() throws Exception { Props props = minProps(); - props.set(SearchSettings.PROP_HTTP_PORT, "9010"); - props.set(ProcessConstants.SEARCH_HOST, "127.0.0.2"); + props.set(ProcessProperties.SEARCH_HTTP_PORT, "9010"); + props.set(ProcessProperties.SEARCH_HOST, "127.0.0.2"); Settings settings = new SearchSettings(props).build(); assertThat(settings.get("http.port")).isEqualTo("9010"); @@ -184,10 +169,8 @@ public class SearchSettingsTest { private Props minProps() throws IOException { File homeDir = temp.newFolder(); Props props = new Props(new Properties()); - props.set(ProcessConstants.SEARCH_PORT, "1234"); - props.set(ProcessConstants.PATH_HOME, homeDir.getAbsolutePath()); - props.set(ProcessConstants.CLUSTER_NAME, "tests"); - props.set(ProcessConstants.CLUSTER_NODE_NAME, "test"); + ProcessProperties.completeDefaults(props); + props.set(ProcessProperties.PATH_HOME, homeDir.getAbsolutePath()); return props; } } diff --git a/server/sonar-search/src/test/java/org/sonar/search/script/UpdateListScriptTest.java b/server/sonar-search/src/test/java/org/sonar/search/script/UpdateListScriptTest.java index d0b6a19da8b..0c1f603831c 100644 --- a/server/sonar-search/src/test/java/org/sonar/search/script/UpdateListScriptTest.java +++ b/server/sonar-search/src/test/java/org/sonar/search/script/UpdateListScriptTest.java @@ -23,7 +23,7 @@ import com.google.common.collect.ImmutableMap; import org.elasticsearch.script.ExecutableScript; import org.junit.Before; import org.junit.Test; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import java.util.Collection; import java.util.HashMap; @@ -54,7 +54,7 @@ public class UpdateListScriptTest { } // Missing ID_VALUE - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_FIELD, "test"); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_FIELD, "test"); try { factory.newScript(params); fail(); @@ -63,7 +63,7 @@ public class UpdateListScriptTest { } // Missing FIELD - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_VALUE, "test"); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_VALUE, "test"); try { factory.newScript(params); fail(); @@ -72,12 +72,12 @@ public class UpdateListScriptTest { } // Has all required attributes and Null Value - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_FIELD, "test"); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_FIELD, "test"); ExecutableScript script = factory.newScript(params); assertThat(script).isNotNull(); // Has all required attributes and VALUE of wrong type - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_VALUE, new Integer(52)); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_VALUE, new Integer(52)); try { factory.newScript(params); fail(); @@ -86,12 +86,12 @@ public class UpdateListScriptTest { } // Has all required attributes and Proper VALUE - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_VALUE, ImmutableMap.of("key", "value")); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_VALUE, ImmutableMap.of("key", "value")); script = factory.newScript(params); assertThat(script).isNotNull(); // Missing ID_FIELD - params.remove(ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_FIELD); + params.remove(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_FIELD); try { factory.newScript(params); fail(); @@ -110,10 +110,10 @@ public class UpdateListScriptTest { // 0 Create list when field does not exists Map<String, Object> params = new HashMap<String, Object>(); - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_FIELD, listField); - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_FIELD, "key"); - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_VALUE, "1"); - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_VALUE, mapOf("key", "1", "value", "A")); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_FIELD, listField); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_FIELD, "key"); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_VALUE, "1"); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_VALUE, mapOf("key", "1", "value", "A")); ExecutableScript script = factory.newScript(params); script.setNextVar("ctx", ImmutableMap.of("_source", source)); @@ -125,10 +125,10 @@ public class UpdateListScriptTest { // Add item to existing list params = new HashMap<String, Object>(); - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_FIELD, listField); - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_FIELD, "key"); - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_VALUE, "2"); - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_VALUE, mapOf("key", "2", "value", "B")); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_FIELD, listField); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_FIELD, "key"); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_VALUE, "2"); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_VALUE, mapOf("key", "2", "value", "B")); script = factory.newScript(params); script.setNextVar("ctx", ImmutableMap.of("_source", source)); script.run(); @@ -137,10 +137,10 @@ public class UpdateListScriptTest { // updated first item in list params = new HashMap<String, Object>(); - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_FIELD, listField); - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_FIELD, "key"); - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_VALUE, "1"); - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_VALUE, mapOf("key", "1", "value", "a")); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_FIELD, listField); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_FIELD, "key"); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_VALUE, "1"); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_VALUE, mapOf("key", "1", "value", "a")); script = factory.newScript(params); script.setNextVar("ctx", ImmutableMap.of("_source", source)); script.run(); @@ -149,10 +149,10 @@ public class UpdateListScriptTest { // updated second item in list params = new HashMap<String, Object>(); - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_FIELD, listField); - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_FIELD, "key"); - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_VALUE, "2"); - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_VALUE, mapOf("key", "2", "value", "b")); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_FIELD, listField); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_FIELD, "key"); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_VALUE, "2"); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_VALUE, mapOf("key", "2", "value", "b")); script = factory.newScript(params); script.setNextVar("ctx", ImmutableMap.of("_source", source)); script.run(); @@ -161,10 +161,10 @@ public class UpdateListScriptTest { // delete first item params = new HashMap<String, Object>(); - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_FIELD, listField); - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_FIELD, "key"); - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_VALUE, "1"); - params.put(ProcessConstants.ES_PLUGIN_LISTUPDATE_VALUE, null); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_FIELD, listField); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_FIELD, "key"); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_VALUE, "1"); + params.put(ProcessProperties.ES_PLUGIN_LISTUPDATE_VALUE, null); script = factory.newScript(params); script.setNextVar("ctx", ImmutableMap.of("_source", source)); script.run(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/activity/index/ActivityIndexDefinition.java b/server/sonar-server/src/main/java/org/sonar/server/activity/index/ActivityIndexDefinition.java index bac57c04233..38a8fff0a4e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/activity/index/ActivityIndexDefinition.java +++ b/server/sonar-server/src/main/java/org/sonar/server/activity/index/ActivityIndexDefinition.java @@ -22,7 +22,7 @@ package org.sonar.server.activity.index; import com.google.common.collect.ImmutableMap; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.sonar.api.config.Settings; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.server.es.IndexDefinition; import org.sonar.server.es.NewIndex; @@ -54,7 +54,7 @@ public class ActivityIndexDefinition implements IndexDefinition { index.getSettings().put("analysis.analyzer.default.type", "keyword"); // shards - boolean clusterMode = settings.getBoolean(ProcessConstants.CLUSTER_ACTIVATE); + boolean clusterMode = settings.getBoolean(ProcessProperties.CLUSTER_ACTIVATE); if (clusterMode) { index.getSettings().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 4); index.getSettings().put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1); diff --git a/server/sonar-server/src/main/java/org/sonar/server/app/EmbeddedTomcat.java b/server/sonar-server/src/main/java/org/sonar/server/app/EmbeddedTomcat.java index 1a308b1bfb1..9cff7388191 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/app/EmbeddedTomcat.java +++ b/server/sonar-server/src/main/java/org/sonar/server/app/EmbeddedTomcat.java @@ -25,7 +25,7 @@ import org.apache.catalina.core.StandardContext; import org.apache.catalina.startup.Tomcat; import org.apache.commons.io.FileUtils; import org.sonar.api.utils.log.Loggers; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.process.Props; import java.io.File; @@ -86,7 +86,7 @@ class EmbeddedTomcat { } private File tomcatBasedir() { - return new File(props.value(ProcessConstants.PATH_TEMP), "tc"); + return new File(props.value(ProcessProperties.PATH_TEMP), "tc"); } void terminate() { diff --git a/server/sonar-server/src/main/java/org/sonar/server/app/Webapp.java b/server/sonar-server/src/main/java/org/sonar/server/app/Webapp.java index f2be0473d45..67c4a0b78b3 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/app/Webapp.java +++ b/server/sonar-server/src/main/java/org/sonar/server/app/Webapp.java @@ -24,7 +24,7 @@ import org.apache.catalina.core.StandardContext; import org.apache.catalina.startup.Tomcat; import org.apache.commons.lang.StringUtils; import org.sonar.api.utils.log.Loggers; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.process.Props; import java.io.File; @@ -100,7 +100,7 @@ class Webapp { static String webappPath(Props props) { String webDir = props.value("sonar.web.dev.sources"); if (StringUtils.isEmpty(webDir)) { - webDir = new File(props.value(ProcessConstants.PATH_HOME), "web").getAbsolutePath(); + webDir = new File(props.value(ProcessProperties.PATH_HOME), "web").getAbsolutePath(); } Loggers.get(Webapp.class).info(String.format("Webapp directory: %s", webDir)); return webDir; diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/ReportQueue.java b/server/sonar-server/src/main/java/org/sonar/server/computation/ReportQueue.java index ebddc02357c..51a84f5f356 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/ReportQueue.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/ReportQueue.java @@ -28,7 +28,7 @@ import org.sonar.api.utils.log.Loggers; import org.sonar.core.computation.db.AnalysisReportDto; import org.sonar.core.persistence.DbSession; import org.sonar.core.persistence.MyBatis; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.server.computation.db.AnalysisReportDao; import org.sonar.server.db.DbClient; @@ -179,7 +179,7 @@ public class ReportQueue implements ServerComponent { * Never return null but the directory may not exist. */ private File reportsDir() { - return new File(settings.getString(ProcessConstants.PATH_DATA), "analysis"); + return new File(settings.getString(ProcessProperties.PATH_DATA), "analysis"); } private File reportFileForUuid(String uuid) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/EmbeddedDatabase.java b/server/sonar-server/src/main/java/org/sonar/server/db/EmbeddedDatabase.java index ef0ab6c5ed1..c13017560b4 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/db/EmbeddedDatabase.java +++ b/server/sonar-server/src/main/java/org/sonar/server/db/EmbeddedDatabase.java @@ -29,7 +29,7 @@ import org.sonar.api.database.DatabaseProperties; import org.sonar.api.utils.SonarException; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import java.io.File; import java.sql.DriverManager; @@ -84,7 +84,7 @@ public class EmbeddedDatabase implements Startable { @VisibleForTesting File getDataDirectory(Settings settings) { - return new File(settings.getString(ProcessConstants.PATH_DATA)); + return new File(settings.getString(ProcessProperties.PATH_DATA)); } private String getSetting(String name, String defaultValue) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexDefinition.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexDefinition.java index 68292b43a93..9f6b25f6f96 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexDefinition.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexDefinition.java @@ -22,7 +22,7 @@ package org.sonar.server.issue.index; import com.google.common.collect.ImmutableMap; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.sonar.api.config.Settings; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.server.es.IndexDefinition; import org.sonar.server.es.NewIndex; @@ -97,7 +97,7 @@ public class IssueIndexDefinition implements IndexDefinition { index.getSettings().put("index.refresh_interval", "-1"); // shards - boolean clusterMode = settings.getBoolean(ProcessConstants.CLUSTER_ACTIVATE); + boolean clusterMode = settings.getBoolean(ProcessProperties.CLUSTER_ACTIVATE); if (clusterMode) { index.getSettings().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 4); index.getSettings().put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1); diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java b/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java index e8e65acbee8..eecf1e5386e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java @@ -27,7 +27,7 @@ import org.sonar.api.platform.Server; import org.sonar.api.platform.ServerFileSystem; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import java.io.File; import java.io.FileFilter; @@ -50,7 +50,7 @@ public class DefaultServerFileSystem implements ServerFileSystem, Startable { public DefaultServerFileSystem(Settings settings, Server server) { this.server = server; - this.homeDir = new File(settings.getString(ProcessConstants.PATH_HOME)); + this.homeDir = new File(settings.getString(ProcessProperties.PATH_HOME)); } /** diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java b/server/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java index 991ceb18d1d..dd961e8c560 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java @@ -31,7 +31,7 @@ import org.sonar.api.config.Settings; import org.sonar.api.platform.Server; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import java.io.File; import java.io.IOException; @@ -78,7 +78,7 @@ public final class ServerImpl extends Server implements Startable { // Remove trailing slashes .replaceFirst("(\\/+)$", ""); - sonarHome = new File(settings.getString(ProcessConstants.PATH_HOME)); + sonarHome = new File(settings.getString(ProcessProperties.PATH_HOME)); if (!sonarHome.isDirectory()) { throw new IllegalStateException("SonarQube home directory is not valid"); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SonarQubeMonitor.java b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SonarQubeMonitor.java index a043b8dc5b7..930a32c36b6 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SonarQubeMonitor.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/SonarQubeMonitor.java @@ -24,7 +24,7 @@ import org.sonar.api.CoreProperties; import org.sonar.api.config.Settings; import org.sonar.api.platform.Server; import org.sonar.api.security.SecurityRealm; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.server.user.SecurityRealmFactory; import java.util.LinkedHashMap; @@ -86,10 +86,10 @@ public class SonarQubeMonitor extends BaseMonitorMBean implements SonarQubeMonit attributes.put("Automatic User Creation", getAutomaticUserCreation()); attributes.put("Allow Users to Sign Up", getAllowUsersToSignUp()); attributes.put("Force authentication", getForceAuthentication()); - attributes.put("Home Dir", settings.getString(ProcessConstants.PATH_HOME)); - attributes.put("Data Dir", settings.getString(ProcessConstants.PATH_DATA)); - attributes.put("Logs Dir", settings.getString(ProcessConstants.PATH_LOGS)); - attributes.put("Temp Dir", settings.getString(ProcessConstants.PATH_TEMP)); + attributes.put("Home Dir", settings.getString(ProcessProperties.PATH_HOME)); + attributes.put("Data Dir", settings.getString(ProcessProperties.PATH_DATA)); + attributes.put("Logs Dir", settings.getString(ProcessProperties.PATH_LOGS)); + attributes.put("Temp Dir", settings.getString(ProcessProperties.PATH_TEMP)); return attributes; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleNormalizer.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleNormalizer.java index 4dfe45cc78f..335991d4448 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleNormalizer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleNormalizer.java @@ -29,7 +29,7 @@ import org.sonar.core.qualityprofile.db.ActiveRuleDto; import org.sonar.core.qualityprofile.db.ActiveRuleKey; import org.sonar.core.qualityprofile.db.ActiveRuleParamDto; import org.sonar.core.qualityprofile.db.QualityProfileDto; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.server.db.DbClient; import org.sonar.server.qualityprofile.ActiveRule; import org.sonar.server.search.BaseNormalizer; @@ -165,11 +165,11 @@ public class ActiveRuleNormalizer extends BaseNormalizer<ActiveRuleDto, ActiveRu .replicationType(ReplicationType.ASYNC) .routing(key.ruleKey().toString()) .id(key.toString()) - .script(ProcessConstants.ES_PLUGIN_LISTUPDATE_SCRIPT_NAME) - .addScriptParam(ProcessConstants.ES_PLUGIN_LISTUPDATE_FIELD, ActiveRuleField.PARAMS.field()) - .addScriptParam(ProcessConstants.ES_PLUGIN_LISTUPDATE_VALUE, newParam) - .addScriptParam(ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_FIELD, ActiveRuleParamField.NAME.field()) - .addScriptParam(ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_VALUE, param.getKey()) + .script(ProcessProperties.ES_PLUGIN_LISTUPDATE_SCRIPT_NAME) + .addScriptParam(ProcessProperties.ES_PLUGIN_LISTUPDATE_FIELD, ActiveRuleField.PARAMS.field()) + .addScriptParam(ProcessProperties.ES_PLUGIN_LISTUPDATE_VALUE, newParam) + .addScriptParam(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_FIELD, ActiveRuleParamField.NAME.field()) + .addScriptParam(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_VALUE, param.getKey()) ); } @@ -178,11 +178,11 @@ public class ActiveRuleNormalizer extends BaseNormalizer<ActiveRuleDto, ActiveRu .replicationType(ReplicationType.ASYNC) .routing(key.ruleKey().toString()) .id(key.toString()) - .script(ProcessConstants.ES_PLUGIN_LISTUPDATE_SCRIPT_NAME) - .addScriptParam(ProcessConstants.ES_PLUGIN_LISTUPDATE_FIELD, ActiveRuleField.PARAMS.field()) - .addScriptParam(ProcessConstants.ES_PLUGIN_LISTUPDATE_VALUE, null) - .addScriptParam(ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_FIELD, ActiveRuleParamField.NAME.field()) - .addScriptParam(ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_VALUE, param.getKey()) + .script(ProcessProperties.ES_PLUGIN_LISTUPDATE_SCRIPT_NAME) + .addScriptParam(ProcessProperties.ES_PLUGIN_LISTUPDATE_FIELD, ActiveRuleField.PARAMS.field()) + .addScriptParam(ProcessProperties.ES_PLUGIN_LISTUPDATE_VALUE, null) + .addScriptParam(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_FIELD, ActiveRuleParamField.NAME.field()) + .addScriptParam(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_VALUE, param.getKey()) ); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java index 7ce70f0757c..a9d5d828428 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java @@ -32,7 +32,7 @@ import org.sonar.core.rule.RuleDto; import org.sonar.core.rule.RuleParamDto; import org.sonar.core.technicaldebt.db.CharacteristicDto; import org.sonar.markdown.Markdown; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.server.db.DbClient; import org.sonar.server.search.BaseNormalizer; import org.sonar.server.search.IndexField; @@ -322,22 +322,22 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> { return ImmutableList.of(new UpdateRequest() .id(key.toString()) - .script(ProcessConstants.ES_PLUGIN_LISTUPDATE_SCRIPT_NAME) - .addScriptParam(ProcessConstants.ES_PLUGIN_LISTUPDATE_FIELD, RuleField.PARAMS.field()) - .addScriptParam(ProcessConstants.ES_PLUGIN_LISTUPDATE_VALUE, newParam) - .addScriptParam(ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_FIELD, RuleParamField.NAME.field()) - .addScriptParam(ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_VALUE, param.getName()) + .script(ProcessProperties.ES_PLUGIN_LISTUPDATE_SCRIPT_NAME) + .addScriptParam(ProcessProperties.ES_PLUGIN_LISTUPDATE_FIELD, RuleField.PARAMS.field()) + .addScriptParam(ProcessProperties.ES_PLUGIN_LISTUPDATE_VALUE, newParam) + .addScriptParam(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_FIELD, RuleParamField.NAME.field()) + .addScriptParam(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_VALUE, param.getName()) ); } private List<UpdateRequest> nestedDelete(RuleParamDto param, RuleKey key) { return ImmutableList.of(new UpdateRequest() .id(key.toString()) - .script(ProcessConstants.ES_PLUGIN_LISTUPDATE_SCRIPT_NAME) - .addScriptParam(ProcessConstants.ES_PLUGIN_LISTUPDATE_FIELD, RuleField.PARAMS.field()) - .addScriptParam(ProcessConstants.ES_PLUGIN_LISTUPDATE_VALUE, null) - .addScriptParam(ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_FIELD, RuleParamField.NAME.field()) - .addScriptParam(ProcessConstants.ES_PLUGIN_LISTUPDATE_ID_VALUE, param.getName()) + .script(ProcessProperties.ES_PLUGIN_LISTUPDATE_SCRIPT_NAME) + .addScriptParam(ProcessProperties.ES_PLUGIN_LISTUPDATE_FIELD, RuleField.PARAMS.field()) + .addScriptParam(ProcessProperties.ES_PLUGIN_LISTUPDATE_VALUE, null) + .addScriptParam(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_FIELD, RuleParamField.NAME.field()) + .addScriptParam(ProcessProperties.ES_PLUGIN_LISTUPDATE_ID_VALUE, param.getName()) ); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/SearchClient.java b/server/sonar-server/src/main/java/org/sonar/server/search/SearchClient.java index 8f03a3a8057..2b5973c3941 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/SearchClient.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/SearchClient.java @@ -53,7 +53,7 @@ import org.elasticsearch.common.transport.InetSocketTransportAddress; import org.picocontainer.Startable; import org.sonar.api.config.Settings; import org.sonar.process.LoopbackAddress; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.server.es.request.*; /** @@ -63,14 +63,14 @@ public class SearchClient extends TransportClient implements Startable { public SearchClient(Settings settings) { super(ImmutableSettings.settingsBuilder() - .put("node.name", StringUtils.defaultIfEmpty(settings.getString(ProcessConstants.CLUSTER_NODE_NAME), "sq_local_client")) - .put("network.bind_host", StringUtils.defaultIfEmpty(settings.getString(ProcessConstants.SEARCH_HOST), "localhost")) - .put("node.rack_id", StringUtils.defaultIfEmpty(settings.getString(ProcessConstants.CLUSTER_NODE_NAME), "unknown")) - .put("cluster.name", StringUtils.defaultIfBlank(settings.getString(ProcessConstants.CLUSTER_NAME), "sonarqube")) + .put("node.name", StringUtils.defaultIfEmpty(settings.getString(ProcessProperties.CLUSTER_NODE_NAME), "sq_local_client")) + .put("network.bind_host", StringUtils.defaultIfEmpty(settings.getString(ProcessProperties.SEARCH_HOST), "localhost")) + .put("node.rack_id", StringUtils.defaultIfEmpty(settings.getString(ProcessProperties.CLUSTER_NODE_NAME), "unknown")) + .put("cluster.name", StringUtils.defaultIfBlank(settings.getString(ProcessProperties.CLUSTER_NAME), "sonarqube")) .build()); initLogging(); - this.addTransportAddress(new InetSocketTransportAddress(StringUtils.defaultIfEmpty(settings.getString(ProcessConstants.SEARCH_HOST), LoopbackAddress.get().getHostAddress()), - settings.getInt(ProcessConstants.SEARCH_PORT))); + this.addTransportAddress(new InetSocketTransportAddress(StringUtils.defaultIfEmpty(settings.getString(ProcessProperties.SEARCH_HOST), LoopbackAddress.get().getHostAddress()), + settings.getInt(ProcessProperties.SEARCH_PORT))); } private void initLogging() { diff --git a/server/sonar-server/src/main/java/org/sonar/server/source/index/SourceLineIndexDefinition.java b/server/sonar-server/src/main/java/org/sonar/server/source/index/SourceLineIndexDefinition.java index 5385b80f136..d80f57f6496 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/source/index/SourceLineIndexDefinition.java +++ b/server/sonar-server/src/main/java/org/sonar/server/source/index/SourceLineIndexDefinition.java @@ -22,7 +22,7 @@ package org.sonar.server.source.index; import com.google.common.collect.ImmutableMap; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.sonar.api.config.Settings; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.server.es.IndexDefinition; import org.sonar.server.es.NewIndex; @@ -65,7 +65,7 @@ public class SourceLineIndexDefinition implements IndexDefinition { index.getSettings().put("index.refresh_interval", "-1"); // shards - boolean clusterMode = settings.getBoolean(ProcessConstants.CLUSTER_ACTIVATE); + boolean clusterMode = settings.getBoolean(ProcessProperties.CLUSTER_ACTIVATE); if (clusterMode) { index.getSettings().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 4); index.getSettings().put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1); diff --git a/server/sonar-server/src/main/java/org/sonar/server/startup/JdbcDriverDeployer.java b/server/sonar-server/src/main/java/org/sonar/server/startup/JdbcDriverDeployer.java index 289d94cab7e..8a38ae75e6a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/startup/JdbcDriverDeployer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/startup/JdbcDriverDeployer.java @@ -22,7 +22,7 @@ package org.sonar.server.startup; import org.apache.commons.io.FileUtils; import org.sonar.api.config.Settings; import org.sonar.home.cache.FileHashes; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.server.platform.DefaultServerFileSystem; import javax.annotation.Nullable; @@ -42,7 +42,7 @@ public class JdbcDriverDeployer { public void start() { // see initialization of this property in sonar-application - String driverPath = settings.getString(ProcessConstants.JDBC_DRIVER_PATH); + String driverPath = settings.getString(ProcessProperties.JDBC_DRIVER_PATH); if (driverPath == null) { // Medium tests return; diff --git a/server/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java b/server/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java index 0101265cad3..555ea7fff67 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java +++ b/server/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java @@ -37,7 +37,7 @@ import org.sonar.api.web.Widget; import org.sonar.core.persistence.Database; import org.sonar.core.resource.ResourceIndexerDao; import org.sonar.core.timemachine.Periods; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.server.component.ComponentCleanerService; import org.sonar.server.db.migrations.DatabaseMigrator; import org.sonar.server.measure.MeasureFilterEngine; @@ -338,7 +338,7 @@ public final class JRubyFacade { } public String getServerHome() { - return get(Settings.class).getString(ProcessConstants.PATH_HOME); + return get(Settings.class).getString(ProcessProperties.PATH_HOME); } public ComponentContainer getContainer() { diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/index/UserIndexDefinition.java b/server/sonar-server/src/main/java/org/sonar/server/user/index/UserIndexDefinition.java index 6e610ff74b6..68a191aab1f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/user/index/UserIndexDefinition.java +++ b/server/sonar-server/src/main/java/org/sonar/server/user/index/UserIndexDefinition.java @@ -22,7 +22,7 @@ package org.sonar.server.user.index; import com.google.common.collect.ImmutableMap; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.sonar.api.config.Settings; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.server.es.IndexDefinition; import org.sonar.server.es.NewIndex; @@ -54,7 +54,7 @@ public class UserIndexDefinition implements IndexDefinition { NewIndex index = context.create(INDEX); // shards - boolean clusterMode = settings.getBoolean(ProcessConstants.CLUSTER_ACTIVATE); + boolean clusterMode = settings.getBoolean(ProcessProperties.CLUSTER_ACTIVATE); if (clusterMode) { index.getSettings().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 4); index.getSettings().put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1); diff --git a/server/sonar-server/src/main/java/org/sonar/server/view/index/ViewIndexDefinition.java b/server/sonar-server/src/main/java/org/sonar/server/view/index/ViewIndexDefinition.java index ce84709be78..3fe2be97a98 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/view/index/ViewIndexDefinition.java +++ b/server/sonar-server/src/main/java/org/sonar/server/view/index/ViewIndexDefinition.java @@ -23,7 +23,7 @@ package org.sonar.server.view.index; import com.google.common.collect.ImmutableMap; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.sonar.api.config.Settings; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.server.es.IndexDefinition; import org.sonar.server.es.NewIndex; @@ -50,7 +50,7 @@ public class ViewIndexDefinition implements IndexDefinition { NewIndex index = context.create(INDEX); // shards - boolean clusterMode = settings.getBoolean(ProcessConstants.CLUSTER_ACTIVATE); + boolean clusterMode = settings.getBoolean(ProcessProperties.CLUSTER_ACTIVATE); if (clusterMode) { index.getSettings().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 4); index.getSettings().put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1); diff --git a/server/sonar-server/src/test/java/org/sonar/server/activity/index/ActivityIndexDefinitionTest.java b/server/sonar-server/src/test/java/org/sonar/server/activity/index/ActivityIndexDefinitionTest.java index 80ef2f2fba0..3e5336d9194 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/activity/index/ActivityIndexDefinitionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/activity/index/ActivityIndexDefinitionTest.java @@ -21,7 +21,7 @@ package org.sonar.server.activity.index; import org.junit.Test; import org.sonar.api.config.Settings; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.server.es.IndexDefinition; import org.sonar.server.es.NewIndex; @@ -49,7 +49,7 @@ public class ActivityIndexDefinitionTest { @Test public void enable_cluster() throws Exception { Settings settings = new Settings(); - settings.setProperty(ProcessConstants.CLUSTER_ACTIVATE, true); + settings.setProperty(ProcessProperties.CLUSTER_ACTIVATE, true); ActivityIndexDefinition def = new ActivityIndexDefinition(settings); def.define(context); diff --git a/server/sonar-server/src/test/java/org/sonar/server/app/TomcatAccessLogTest.java b/server/sonar-server/src/test/java/org/sonar/server/app/TomcatAccessLogTest.java index 0e64c81de60..ac5351bf9fd 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/app/TomcatAccessLogTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/app/TomcatAccessLogTest.java @@ -28,7 +28,7 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.mockito.Mockito; import org.sonar.api.utils.log.Logger; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.process.Props; import java.io.File; @@ -55,7 +55,7 @@ public class TomcatAccessLogTest { public void enable_access_logs_by_Default() throws Exception { Tomcat tomcat = mock(Tomcat.class, Mockito.RETURNS_DEEP_STUBS); Props props = new Props(new Properties()); - props.set(ProcessConstants.PATH_LOGS, temp.newFolder().getAbsolutePath()); + props.set(ProcessProperties.PATH_LOGS, temp.newFolder().getAbsolutePath()); sut.configure(tomcat, props); verify(tomcat.getHost().getPipeline()).addValve(any(ProgrammaticLogbackValve.class)); diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ReportQueueTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ReportQueueTest.java index 54d29d63e68..b7ffeb65311 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/ReportQueueTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/ReportQueueTest.java @@ -32,7 +32,7 @@ import org.sonar.api.utils.System2; import org.sonar.core.computation.db.AnalysisReportDto; import org.sonar.core.persistence.DbSession; import org.sonar.core.persistence.DbTester; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.server.component.ComponentTesting; import org.sonar.server.component.db.ComponentDao; import org.sonar.server.computation.db.AnalysisReportDao; @@ -68,7 +68,7 @@ public class ReportQueueTest { @Before public void setUp() throws Exception { dataDir = temp.newFolder(); - settings.setProperty(ProcessConstants.PATH_DATA, dataDir.getAbsolutePath()); + settings.setProperty(ProcessProperties.PATH_DATA, dataDir.getAbsolutePath()); when(system.now()).thenReturn(NOW); DbClient dbClient = new DbClient(db.database(), db.myBatis(), new ComponentDao(), new AnalysisReportDao(system)); diff --git a/server/sonar-server/src/test/java/org/sonar/server/db/EmbeddedDatabaseTest.java b/server/sonar-server/src/test/java/org/sonar/server/db/EmbeddedDatabaseTest.java index 29edb659620..954f480dadd 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/db/EmbeddedDatabaseTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/db/EmbeddedDatabaseTest.java @@ -26,7 +26,7 @@ import org.junit.rules.ExpectedException; import org.sonar.api.config.Settings; import org.sonar.api.database.DatabaseProperties; import org.sonar.process.NetworkUtils; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import java.io.File; import java.io.IOException; @@ -73,6 +73,6 @@ public class EmbeddedDatabaseTest { .setProperty(DatabaseProperties.PROP_USER, "login") .setProperty(DatabaseProperties.PROP_PASSWORD, "pwd") .setProperty(DatabaseProperties.PROP_EMBEDDED_PORT, "" + port) - .setProperty(ProcessConstants.PATH_DATA, "./target/testDB"); + .setProperty(ProcessProperties.PATH_DATA, "./target/testDB"); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/EsServerHolder.java b/server/sonar-server/src/test/java/org/sonar/server/es/EsServerHolder.java index 5146f5b733a..3604426eff2 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/es/EsServerHolder.java +++ b/server/sonar-server/src/test/java/org/sonar/server/es/EsServerHolder.java @@ -25,7 +25,7 @@ import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.transport.InetSocketTransportAddress; import org.sonar.process.LoopbackAddress; import org.sonar.process.NetworkUtils; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.process.Props; import org.sonar.search.SearchServer; import org.sonar.test.TestUtils; @@ -108,11 +108,11 @@ public class EsServerHolder { int port = NetworkUtils.freePort(); Properties properties = new Properties(); - properties.setProperty(ProcessConstants.CLUSTER_NAME, clusterName); - properties.setProperty(ProcessConstants.CLUSTER_NODE_NAME, nodeName); - properties.setProperty(ProcessConstants.SEARCH_PORT, String.valueOf(port)); - properties.setProperty(ProcessConstants.SEARCH_HOST, hostName); - properties.setProperty(ProcessConstants.PATH_HOME, homeDir.getAbsolutePath()); + properties.setProperty(ProcessProperties.CLUSTER_NAME, clusterName); + properties.setProperty(ProcessProperties.CLUSTER_NODE_NAME, nodeName); + properties.setProperty(ProcessProperties.SEARCH_PORT, String.valueOf(port)); + properties.setProperty(ProcessProperties.SEARCH_HOST, hostName); + properties.setProperty(ProcessProperties.PATH_HOME, homeDir.getAbsolutePath()); SearchServer server = new SearchServer(new Props(properties)); server.start(); HOLDER = new EsServerHolder(server, clusterName, nodeName, port, hostName, homeDir); diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexDefinitionTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexDefinitionTest.java index 0e5b70d0d0b..65b41afdedf 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexDefinitionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexDefinitionTest.java @@ -21,7 +21,7 @@ package org.sonar.server.issue.index; import org.junit.Test; import org.sonar.api.config.Settings; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.server.es.IndexDefinition; import org.sonar.server.es.NewIndex; @@ -49,7 +49,7 @@ public class IssueIndexDefinitionTest { @Test public void enable_cluster() throws Exception { Settings settings = new Settings(); - settings.setProperty(ProcessConstants.CLUSTER_ACTIVATE, true); + settings.setProperty(ProcessProperties.CLUSTER_ACTIVATE, true); IssueIndexDefinition def = new IssueIndexDefinition(settings); def.define(context); diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/ServerImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/ServerImplTest.java index 1766cb82459..68a3f260c51 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/platform/ServerImplTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/platform/ServerImplTest.java @@ -27,7 +27,7 @@ import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.sonar.api.CoreProperties; import org.sonar.api.config.Settings; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import java.io.File; @@ -48,7 +48,7 @@ public class ServerImplTest { @Before public void setUp() throws Exception { - settings = new Settings().setProperty(ProcessConstants.PATH_HOME, sonarHome.getRoot().getAbsolutePath()); + settings = new Settings().setProperty(ProcessProperties.PATH_HOME, sonarHome.getRoot().getAbsolutePath()); new File(sonarHome.getRoot(), "web/deploy").mkdirs(); server = new ServerImpl(settings, "/org/sonar/server/platform/ServerImplTest/build.properties", "/org/sonar/server/platform/ServerImplTest/version.txt"); diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/BaseIndexTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/BaseIndexTest.java index 53a001331ee..6d772538a17 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/search/BaseIndexTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/search/BaseIndexTest.java @@ -26,7 +26,7 @@ import org.junit.ClassRule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonar.api.config.Settings; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.server.es.EsServerHolder; import java.io.IOException; @@ -47,11 +47,11 @@ public class BaseIndexTest { public void setup() throws IOException { EsServerHolder holder = EsServerHolder.get(); Settings settings = new Settings(); - settings.setProperty(ProcessConstants.CLUSTER_ACTIVATE, false); - settings.setProperty(ProcessConstants.CLUSTER_NAME, holder.getClusterName()); - settings.setProperty(ProcessConstants.CLUSTER_NODE_NAME, holder.getNodeName()); - settings.setProperty(ProcessConstants.SEARCH_PORT, String.valueOf(holder.getPort())); - settings.setProperty(ProcessConstants.SEARCH_HOST, String.valueOf(holder.getHostName())); + settings.setProperty(ProcessProperties.CLUSTER_ACTIVATE, false); + settings.setProperty(ProcessProperties.CLUSTER_NAME, holder.getClusterName()); + settings.setProperty(ProcessProperties.CLUSTER_NODE_NAME, holder.getNodeName()); + settings.setProperty(ProcessProperties.SEARCH_PORT, String.valueOf(holder.getPort())); + settings.setProperty(ProcessProperties.SEARCH_HOST, String.valueOf(holder.getHostName())); searchClient = new SearchClient(settings); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/source/index/SourceLineIndexDefinitionTest.java b/server/sonar-server/src/test/java/org/sonar/server/source/index/SourceLineIndexDefinitionTest.java index 4c5af2a2567..f33c15c5281 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/source/index/SourceLineIndexDefinitionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/source/index/SourceLineIndexDefinitionTest.java @@ -21,7 +21,7 @@ package org.sonar.server.source.index; import org.junit.Test; import org.sonar.api.config.Settings; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.server.es.IndexDefinition; import org.sonar.server.es.NewIndex; @@ -49,7 +49,7 @@ public class SourceLineIndexDefinitionTest { @Test public void enable_cluster() throws Exception { Settings settings = new Settings(); - settings.setProperty(ProcessConstants.CLUSTER_ACTIVATE, true); + settings.setProperty(ProcessProperties.CLUSTER_ACTIVATE, true); IndexDefinition def = new SourceLineIndexDefinition(settings); def.define(context); diff --git a/server/sonar-server/src/test/java/org/sonar/server/tester/ServerTester.java b/server/sonar-server/src/test/java/org/sonar/server/tester/ServerTester.java index aa08b8db729..b6c3d6fd856 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/tester/ServerTester.java +++ b/server/sonar-server/src/test/java/org/sonar/server/tester/ServerTester.java @@ -29,7 +29,7 @@ import org.sonar.api.database.DatabaseProperties; import org.sonar.api.resources.Language; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.server.es.EsServerHolder; import org.sonar.server.platform.BackendCleanup; import org.sonar.server.platform.Platform; @@ -81,12 +81,12 @@ public class ServerTester extends ExternalResource { Properties properties = new Properties(); properties.putAll(initialProps); esServerHolder = EsServerHolder.get(); - properties.setProperty(ProcessConstants.CLUSTER_NAME, esServerHolder.getClusterName()); - properties.setProperty(ProcessConstants.CLUSTER_NODE_NAME, esServerHolder.getNodeName()); - properties.setProperty(ProcessConstants.SEARCH_PORT, String.valueOf(esServerHolder.getPort())); - properties.setProperty(ProcessConstants.SEARCH_HOST, String.valueOf(esServerHolder.getHostName())); - properties.setProperty(ProcessConstants.PATH_HOME, homeDir.getAbsolutePath()); - properties.setProperty(ProcessConstants.PATH_DATA, new File(homeDir, "data").getAbsolutePath()); + properties.setProperty(ProcessProperties.CLUSTER_NAME, esServerHolder.getClusterName()); + properties.setProperty(ProcessProperties.CLUSTER_NODE_NAME, esServerHolder.getNodeName()); + properties.setProperty(ProcessProperties.SEARCH_PORT, String.valueOf(esServerHolder.getPort())); + properties.setProperty(ProcessProperties.SEARCH_HOST, String.valueOf(esServerHolder.getHostName())); + properties.setProperty(ProcessProperties.PATH_HOME, homeDir.getAbsolutePath()); + properties.setProperty(ProcessProperties.PATH_DATA, new File(homeDir, "data").getAbsolutePath()); properties.setProperty(DatabaseProperties.PROP_URL, "jdbc:h2:" + homeDir.getAbsolutePath() + "/h2"); for (Map.Entry<Object, Object> entry : System.getProperties().entrySet()) { String key = entry.getKey().toString(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/index/UserIndexDefinitionTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/index/UserIndexDefinitionTest.java index 932c92f98b5..8de69b73d93 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/user/index/UserIndexDefinitionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/user/index/UserIndexDefinitionTest.java @@ -21,7 +21,7 @@ package org.sonar.server.user.index; import org.junit.Test; import org.sonar.api.config.Settings; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.server.es.IndexDefinition; import org.sonar.server.es.NewIndex; @@ -49,7 +49,7 @@ public class UserIndexDefinitionTest { @Test public void enable_cluster() throws Exception { Settings settings = new Settings(); - settings.setProperty(ProcessConstants.CLUSTER_ACTIVATE, true); + settings.setProperty(ProcessProperties.CLUSTER_ACTIVATE, true); UserIndexDefinition def = new UserIndexDefinition(settings); def.define(context); diff --git a/server/sonar-server/src/test/java/org/sonar/server/view/index/ViewIndexDefinitionTest.java b/server/sonar-server/src/test/java/org/sonar/server/view/index/ViewIndexDefinitionTest.java index df48201c599..9da76180dc8 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/view/index/ViewIndexDefinitionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/view/index/ViewIndexDefinitionTest.java @@ -22,7 +22,7 @@ package org.sonar.server.view.index; import org.junit.Test; import org.sonar.api.config.Settings; -import org.sonar.process.ProcessConstants; +import org.sonar.process.ProcessProperties; import org.sonar.server.es.IndexDefinition; import org.sonar.server.es.NewIndex; @@ -50,7 +50,7 @@ public class ViewIndexDefinitionTest { @Test public void enable_cluster() throws Exception { Settings settings = new Settings(); - settings.setProperty(ProcessConstants.CLUSTER_ACTIVATE, true); + settings.setProperty(ProcessProperties.CLUSTER_ACTIVATE, true); ViewIndexDefinition def = new ViewIndexDefinition(settings); def.define(context); |