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");
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);
// 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");
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");
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);