From 425551d6785dfffa5690459837d0ebedc4ede0e2 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Tue, 27 Jun 2017 21:44:18 +0200 Subject: [PATCH] SONAR-9489 increase the default nb of shards of rules index --- .../org/sonar/server/rule/index/RuleIndexDefinition.java | 5 ++++- .../org/sonar/server/rule/index/RuleIndexDefinitionTest.java | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndexDefinition.java b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndexDefinition.java index 17fe3380b49..b50ef8398b2 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndexDefinition.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndexDefinition.java @@ -102,7 +102,10 @@ public class RuleIndexDefinition implements IndexDefinition { NewIndex index = context.create(INDEX_TYPE_RULE.getIndex()); index.refreshHandledByIndexer(); - index.configureShards(settings, 1); + // Default nb of shards should be greater than 1 in order to + // easily detect routing misconfiguration. + // See https://jira.sonarsource.com/browse/SONAR-9489 + index.configureShards(settings, 2); // Active rule type NewIndex.NewIndexType activeRuleMapping = index.createType(INDEX_TYPE_ACTIVE_RULE.getType()); diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexDefinitionTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexDefinitionTest.java index 51b7c1cc216..10630b27d48 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexDefinitionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexDefinitionTest.java @@ -57,7 +57,7 @@ public class RuleIndexDefinitionTest { assertThat(ruleIndex.getTypes().keySet()).containsOnly("activeRule", "ruleExtension", "rule"); // no cluster by default - assertThat(ruleIndex.getSettings().get("index.number_of_shards")).isEqualTo("1"); + assertThat(ruleIndex.getSettings().get("index.number_of_shards")).isEqualTo("2"); assertThat(ruleIndex.getSettings().get("index.number_of_replicas")).isEqualTo("0"); } -- 2.39.5