aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Hartmann <hartmann.eric@gmail.Com>2017-03-17 17:54:14 +0100
committerGitHub <noreply@github.com>2017-03-17 17:54:14 +0100
commitb35205ac59d363548b245b3ec8ed742a68fbf22a (patch)
tree9c2e878e37396071a0b7013e5c028c8ec1bd456b
parent8759b3933d8bc4a147b7242e1838a39b82bcc719 (diff)
downloadsonarqube-b35205ac59d363548b245b3ec8ed742a68fbf22a.tar.gz
sonarqube-b35205ac59d363548b245b3ec8ed742a68fbf22a.zip
SONAR-8938 Remove sonar.search.clusterName in favor of sonar.cluster.name (#1795)
-rw-r--r--server/sonar-process-monitor/src/main/java/org/sonar/application/cluster/ClusterProperties.java9
-rw-r--r--server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/ClusterPropertiesTest.java16
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java4
-rw-r--r--server/sonar-search/src/main/java/org/sonar/search/EsSettings.java3
-rw-r--r--server/sonar-search/src/test/java/org/sonar/search/EsSettingsTest.java2
-rw-r--r--server/sonar-search/src/test/java/org/sonar/search/SearchServerTest.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/es/EsClientProvider.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/es/EsClientProviderTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/es/EsServerHolder.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/tester/ServerTester.java2
10 files changed, 13 insertions, 35 deletions
diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/application/cluster/ClusterProperties.java b/server/sonar-process-monitor/src/main/java/org/sonar/application/cluster/ClusterProperties.java
index 661919efbd9..e8287c24d74 100644
--- a/server/sonar-process-monitor/src/main/java/org/sonar/application/cluster/ClusterProperties.java
+++ b/server/sonar-process-monitor/src/main/java/org/sonar/application/cluster/ClusterProperties.java
@@ -52,7 +52,7 @@ public final class ClusterProperties {
networkInterfaces = extractNetworkInterfaces(
appSettings.getProps().value(ProcessProperties.CLUSTER_NETWORK_INTERFACES, "")
);
- name = appSettings.getProps().value(ProcessProperties.CLUSTER_NAME);
+ name = appSettings.getProps().nonNullValue(ProcessProperties.CLUSTER_NAME);
hosts = extractHosts(
appSettings.getProps().value(ProcessProperties.CLUSTER_HOSTS, "")
);
@@ -82,13 +82,6 @@ public final class ClusterProperties {
if (!enabled) {
return;
}
- // Name is required in cluster mode
- checkArgument(
- StringUtils.isNotEmpty(name),
- "Cluster have been enabled but a %s has not been defined.",
- ProcessProperties.CLUSTER_NAME
- );
-
// Test validity of port
checkArgument(
port > 0 && port < 65_536,
diff --git a/server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/ClusterPropertiesTest.java b/server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/ClusterPropertiesTest.java
index 46013fa9811..05e471c7ffd 100644
--- a/server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/ClusterPropertiesTest.java
+++ b/server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/ClusterPropertiesTest.java
@@ -41,7 +41,6 @@ public class ClusterPropertiesTest {
@Test
public void test_default_values() throws Exception {
-
ClusterProperties props = new ClusterProperties(appSettings);
assertThat(props.getNetworkInterfaces())
@@ -53,7 +52,7 @@ public class ClusterPropertiesTest {
assertThat(props.getHosts())
.isEqualTo(Collections.emptyList());
assertThat(props.getName())
- .isEqualTo("");
+ .isEqualTo("sonarqube");
}
@Test
@@ -88,19 +87,6 @@ public class ClusterPropertiesTest {
}
@Test
- public void test_missing_name() {
- appSettings.getProps().set(ProcessProperties.CLUSTER_ENABLED, "true");
- appSettings.getProps().set(ProcessProperties.CLUSTER_NAME, "");
-
- ClusterProperties clusterProperties = new ClusterProperties(appSettings);
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage(
- String.format("Cluster have been enabled but a %s has not been defined.",
- ProcessProperties.CLUSTER_NAME));
- clusterProperties.validate();
- }
-
- @Test
public void validate_does_not_fail_if_cluster_enabled_and_name_specified() {
appSettings.getProps().set(ProcessProperties.CLUSTER_ENABLED, "true");
appSettings.getProps().set(ProcessProperties.CLUSTER_NAME, "sonarqube");
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 e956b0079f5..c27ae3a33f3 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
@@ -56,7 +56,6 @@ public class ProcessProperties {
public static final String PATH_TEMP = "sonar.path.temp";
public static final String PATH_WEB = "sonar.path.web";
- public static final String SEARCH_CLUSTER_NAME = "sonar.search.clusterName";
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";
@@ -111,7 +110,6 @@ public class ProcessProperties {
public static Properties defaults() {
Properties defaults = new Properties();
- defaults.put(SEARCH_CLUSTER_NAME, "sonarqube");
defaults.put(SEARCH_HOST, "127.0.0.1");
defaults.put(SEARCH_JAVA_OPTS, "-Xmx1G -Xms256m -Xss256k -Djna.nosys=true " +
"-XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly " +
@@ -138,7 +136,7 @@ public class ProcessProperties {
defaults.put(CLUSTER_CE_DISABLED, "false");
defaults.put(CLUSTER_WEB_DISABLED, "false");
defaults.put(CLUSTER_SEARCH_DISABLED, "false");
- defaults.put(CLUSTER_NAME, "");
+ defaults.put(CLUSTER_NAME, "sonarqube");
defaults.put(CLUSTER_NETWORK_INTERFACES, "");
defaults.put(CLUSTER_HOSTS, "");
defaults.put(CLUSTER_PORT, "9003");
diff --git a/server/sonar-search/src/main/java/org/sonar/search/EsSettings.java b/server/sonar-search/src/main/java/org/sonar/search/EsSettings.java
index 36369295ac7..9abb06eb258 100644
--- a/server/sonar-search/src/main/java/org/sonar/search/EsSettings.java
+++ b/server/sonar-search/src/main/java/org/sonar/search/EsSettings.java
@@ -49,9 +49,8 @@ public class EsSettings implements EsSettingsMBean {
EsSettings(Props props) {
this.props = props;
- // name of ES cluster must always be set, even if clustering of SQ is disabled
- this.clusterName = props.nonNullValue(ProcessProperties.SEARCH_CLUSTER_NAME);
+ this.clusterName = props.nonNullValue(ProcessProperties.CLUSTER_NAME);
this.clusterEnabled = props.valueAsBoolean(ProcessProperties.CLUSTER_ENABLED);
if (this.clusterEnabled) {
this.nodeName = props.value(CLUSTER_SEARCH_NODE_NAME, "sonarqube-" + UUID.randomUUID().toString());
diff --git a/server/sonar-search/src/test/java/org/sonar/search/EsSettingsTest.java b/server/sonar-search/src/test/java/org/sonar/search/EsSettingsTest.java
index e088c1190b1..595b2a670e7 100644
--- a/server/sonar-search/src/test/java/org/sonar/search/EsSettingsTest.java
+++ b/server/sonar-search/src/test/java/org/sonar/search/EsSettingsTest.java
@@ -43,7 +43,7 @@ public class EsSettingsTest {
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.SEARCH_CLUSTER_NAME, "sonarqube");
+ props.set(ProcessProperties.CLUSTER_NAME, "sonarqube");
EsSettings esSettings = new EsSettings(props);
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 ddfcd68fbc5..00c3c0fd02a 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
@@ -73,10 +73,10 @@ public class SearchServerTest {
public void start_stop_server() throws Exception {
Props props = new Props(new Properties());
// the following properties have always default values (see ProcessProperties)
- InetAddress host = InetAddress.getLocalHost();
+ InetAddress host = InetAddress.getLoopbackAddress();
props.set(ProcessProperties.SEARCH_HOST, host.getHostAddress());
props.set(ProcessProperties.SEARCH_PORT, String.valueOf(port));
- props.set(ProcessProperties.SEARCH_CLUSTER_NAME, A_CLUSTER_NAME);
+ props.set(ProcessProperties.CLUSTER_NAME, A_CLUSTER_NAME);
props.set(EsSettings.CLUSTER_SEARCH_NODE_NAME, A_NODE_NAME);
props.set(ProcessProperties.PATH_HOME, temp.newFolder().getAbsolutePath());
props.set(ProcessEntryPoint.PROPERTY_SHARED_PATH, temp.newFolder().getAbsolutePath());
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/EsClientProvider.java b/server/sonar-server/src/main/java/org/sonar/server/es/EsClientProvider.java
index 8cc403f8ac3..abe03d6304a 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/es/EsClientProvider.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/es/EsClientProvider.java
@@ -35,6 +35,8 @@ import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.process.ProcessProperties;
+import static org.apache.commons.lang.StringUtils.isBlank;
+
@ComputeEngineSide
@ServerSide
public class EsClientProvider extends ProviderAdapter {
@@ -49,7 +51,7 @@ public class EsClientProvider extends ProviderAdapter {
org.elasticsearch.common.settings.Settings.Builder esSettings = org.elasticsearch.common.settings.Settings.builder();
// mandatory property defined by bootstrap process
- esSettings.put("cluster.name", settings.getString(ProcessProperties.SEARCH_CLUSTER_NAME));
+ esSettings.put("cluster.name", settings.getString(ProcessProperties.CLUSTER_NAME));
boolean clusterEnabled = settings.getBoolean(ProcessProperties.CLUSTER_ENABLED);
if (clusterEnabled && settings.getBoolean(ProcessProperties.CLUSTER_SEARCH_DISABLED)) {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/EsClientProviderTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/EsClientProviderTest.java
index 757d1b1e17b..59e675713e0 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/es/EsClientProviderTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/es/EsClientProviderTest.java
@@ -51,7 +51,7 @@ public class EsClientProviderTest {
@Before
public void setUp() throws Exception {
// mandatory property
- settings.setProperty(ProcessProperties.SEARCH_CLUSTER_NAME, "the_cluster_name");
+ settings.setProperty(ProcessProperties.CLUSTER_NAME, "the_cluster_name");
localhost = InetAddress.getLocalHost().getHostAddress();
}
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 6aacb55cd51..70efdab4e5e 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
@@ -102,7 +102,7 @@ public class EsServerHolder {
int port = NetworkUtils.freePort();
Properties properties = new Properties();
- properties.setProperty(ProcessProperties.SEARCH_CLUSTER_NAME, clusterName);
+ properties.setProperty(ProcessProperties.CLUSTER_NAME, clusterName);
properties.setProperty(ProcessProperties.SEARCH_PORT, String.valueOf(port));
properties.setProperty(ProcessProperties.SEARCH_HOST, hostName);
properties.setProperty(ProcessProperties.PATH_HOME, homeDir.getAbsolutePath());
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 d7862d6ce0d..2de34b5be21 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
@@ -103,7 +103,7 @@ public class ServerTester extends ExternalResource {
Properties properties = new Properties();
properties.putAll(initialProps);
esServerHolder = EsServerHolder.get();
- properties.setProperty(ProcessProperties.SEARCH_CLUSTER_NAME, esServerHolder.getClusterName());
+ properties.setProperty(ProcessProperties.CLUSTER_NAME, esServerHolder.getClusterName());
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());