]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8798 remove setting "index.number_of_replicas"
authorDaniel Schwarz <daniel.schwarz@sonarsource.com>
Mon, 7 Aug 2017 13:32:41 +0000 (15:32 +0200)
committerDaniel Schwarz <bartfastiel@users.noreply.github.com>
Wed, 9 Aug 2017 13:09:54 +0000 (15:09 +0200)
server/sonar-search/src/main/java/org/sonar/search/EsSettings.java
server/sonar-search/src/test/java/org/sonar/search/EsSettingsTest.java
server/sonar-server/src/main/java/org/sonar/server/es/DefaultIndexSettings.java
server/sonar-server/src/test/java/org/sonar/server/es/DefaultIndexSettingsTest.java

index 77ed96a090aacc9afb2aed55eef59a264dd40d5e..4df00c79311a537f6d7c946b5a1c4351bb8f96ec 100644 (file)
@@ -148,12 +148,10 @@ public class EsSettings implements EsSettingsMBean {
 
   private void configureCluster(Map<String, String> builder) {
     // Default value in a standalone mode, not overridable
-    int replicationFactor = 0;
     int minimumMasterNodes = 1;
     String initialStateTimeOut = "30s";
 
     if (clusterEnabled) {
-      replicationFactor = props.valueAsInt(ProcessProperties.SEARCH_REPLICAS, 1);
       minimumMasterNodes = props.valueAsInt(ProcessProperties.SEARCH_MINIMUM_MASTER_NODES, 2);
       initialStateTimeOut = props.value(ProcessProperties.SEARCH_INITIAL_STATE_TIMEOUT, "120s");
 
@@ -164,7 +162,6 @@ public class EsSettings implements EsSettingsMBean {
 
     builder.put("discovery.zen.minimum_master_nodes", String.valueOf(minimumMasterNodes));
     builder.put("discovery.initial_state_timeout", initialStateTimeOut);
-    builder.put("index.number_of_replicas", String.valueOf(replicationFactor));
     builder.put("cluster.name", getClusterName());
     builder.put("cluster.routing.allocation.awareness.attributes", "rack_id");
     builder.put("node.attr.rack_id", nodeName);
index 583dfdcb9b430219eab83e44bb607fe9079e330a..3282bac78de9e1f18dcf9d56c7ae3ccd41457bbb 100644 (file)
@@ -66,7 +66,6 @@ public class EsSettingsTest {
     // http is disabled for security reasons
     assertThat(generated.get("http.enabled")).isEqualTo("false");
 
-    assertThat(generated.get("index.number_of_replicas")).isEqualTo("0");
     assertThat(generated.get("discovery.zen.ping.unicast.hosts")).isNull();
     assertThat(generated.get("discovery.zen.minimum_master_nodes")).isEqualTo("1");
     assertThat(generated.get("discovery.initial_state_timeout")).isEqualTo("30s");
@@ -95,7 +94,6 @@ public class EsSettingsTest {
     props.set(ProcessProperties.CLUSTER_SEARCH_HOSTS, "1.2.3.4:9000,1.2.3.5:8080");
     Map<String, String> settings = new EsSettings(props).build();
 
-    assertThat(settings.get("index.number_of_replicas")).isEqualTo("1");
     assertThat(settings.get("discovery.zen.ping.unicast.hosts")).isEqualTo("1.2.3.4:9000,1.2.3.5:8080");
     assertThat(settings.get("discovery.zen.minimum_master_nodes")).isEqualTo("2");
     assertThat(settings.get("discovery.initial_state_timeout")).isEqualTo("120s");
@@ -147,36 +145,6 @@ public class EsSettingsTest {
     assertThat(settings.get("discovery.zen.minimum_master_nodes")).isEqualTo("1");
   }
 
-
-  @Test
-  public void in_standalone_searchReplicas_is_not_overridable() throws Exception {
-    Props props = minProps(false);
-    props.set(ProcessProperties.SEARCH_REPLICAS, "5");
-    Map<String, String> settings = new EsSettings(props).build();
-
-    assertThat(settings.get("index.number_of_replicas")).isEqualTo("0");
-  }
-
-  @Test
-  public void cluster_is_enabled_with_defined_replicas() throws Exception {
-    Props props = minProps(true);
-    props.set(ProcessProperties.SEARCH_REPLICAS, "5");
-    Map<String, String> settings = new EsSettings(props).build();
-
-    assertThat(settings.get("index.number_of_replicas")).isEqualTo("5");
-  }
-
-  @Test
-  public void incorrect_values_of_replicas() throws Exception {
-    Props props = minProps(true);
-
-    props.set(ProcessProperties.SEARCH_REPLICAS, "ꝱꝲꝳପ");
-
-    expectedException.expect(IllegalStateException.class);
-    expectedException.expectMessage("Value of property sonar.search.replicas is not an integer:");
-    Map<String, String> settings = new EsSettings(props).build();
-  }
-
   @Test
   public void enable_marvel() throws Exception {
     Props props = minProps(false);
index 71d272340258e40ea1daf17763ec77f38fe0e002..799d6fde0db89a11952ef890a7b85df3323067d4 100644 (file)
@@ -79,7 +79,6 @@ public class DefaultIndexSettings {
   static Settings.Builder defaults() {
     Settings.Builder builder = Settings.builder()
       .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
-      .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
       .put("index.refresh_interval", "30s")
       .put("index.mapper.dynamic", false);
 
index 5532d3d89b4fc2a9227a980fbc0aafe31b3ee419..1811106596cfde4e1ff700f7136dac2021404e4f 100644 (file)
@@ -35,7 +35,6 @@ public class DefaultIndexSettingsTest {
 
     // test some values
     assertThat(map.get("index.number_of_shards")).isEqualTo("1");
-    assertThat(map.get("index.number_of_replicas")).isEqualTo("0");
     assertThat(map.get("index.analysis.analyzer." + SORTABLE_ANALYZER.getName() + ".tokenizer")).isEqualTo("keyword");
   }