Fix duplicate phrase in shrink/split error message (#36734)

This commit removes a duplicate "must be a" from the shrink/split error
messages.
This commit is contained in:
Jason Tedor 2018-12-17 17:42:58 -05:00 committed by GitHub
parent 384757deff
commit f0f2b26159
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View File

@ -1531,14 +1531,14 @@ public class IndexMetaData implements Diffable<IndexMetaData>, ToXContentFragmen
if (sourceNumberOfShards < targetNumberOfShards) { // split if (sourceNumberOfShards < targetNumberOfShards) { // split
factor = targetNumberOfShards / sourceNumberOfShards; factor = targetNumberOfShards / sourceNumberOfShards;
if (factor * sourceNumberOfShards != targetNumberOfShards || factor <= 1) { if (factor * sourceNumberOfShards != targetNumberOfShards || factor <= 1) {
throw new IllegalArgumentException("the number of source shards [" + sourceNumberOfShards + "] must be a must be a " + throw new IllegalArgumentException("the number of source shards [" + sourceNumberOfShards + "] must be a " +
"factor of [" "factor of ["
+ targetNumberOfShards + "]"); + targetNumberOfShards + "]");
} }
} else if (sourceNumberOfShards > targetNumberOfShards) { // shrink } else if (sourceNumberOfShards > targetNumberOfShards) { // shrink
factor = sourceNumberOfShards / targetNumberOfShards; factor = sourceNumberOfShards / targetNumberOfShards;
if (factor * targetNumberOfShards != sourceNumberOfShards || factor <= 1) { if (factor * targetNumberOfShards != sourceNumberOfShards || factor <= 1) {
throw new IllegalArgumentException("the number of source shards [" + sourceNumberOfShards + "] must be a must be a " + throw new IllegalArgumentException("the number of source shards [" + sourceNumberOfShards + "] must be a " +
"multiple of [" "multiple of ["
+ targetNumberOfShards + "]"); + targetNumberOfShards + "]");
} }

View File

@ -227,7 +227,7 @@ public class IndexMetaDataTests extends ESTestCase {
assertEquals("the number of target shards (0) must be greater than the shard id: 0", assertEquals("the number of target shards (0) must be greater than the shard id: 0",
expectThrows(IllegalArgumentException.class, () -> IndexMetaData.selectSplitShard(0, metaData, 0)).getMessage()); expectThrows(IllegalArgumentException.class, () -> IndexMetaData.selectSplitShard(0, metaData, 0)).getMessage());
assertEquals("the number of source shards [2] must be a must be a factor of [3]", assertEquals("the number of source shards [2] must be a factor of [3]",
expectThrows(IllegalArgumentException.class, () -> IndexMetaData.selectSplitShard(0, metaData, 3)).getMessage()); expectThrows(IllegalArgumentException.class, () -> IndexMetaData.selectSplitShard(0, metaData, 3)).getMessage());
assertEquals("the number of routing shards [4] must be a multiple of the target shards [8]", assertEquals("the number of routing shards [4] must be a multiple of the target shards [8]",
@ -285,6 +285,6 @@ public class IndexMetaDataTests extends ESTestCase {
Settings notAFactorySettings = Settings.builder().put("index.number_of_shards", 2).put("index.number_of_routing_shards", 3).build(); Settings notAFactorySettings = Settings.builder().put("index.number_of_shards", 2).put("index.number_of_routing_shards", 3).build();
iae = expectThrows(IllegalArgumentException.class, iae = expectThrows(IllegalArgumentException.class,
() -> IndexMetaData.INDEX_NUMBER_OF_ROUTING_SHARDS_SETTING.get(notAFactorySettings)); () -> IndexMetaData.INDEX_NUMBER_OF_ROUTING_SHARDS_SETTING.get(notAFactorySettings));
assertEquals("the number of source shards [2] must be a must be a factor of [3]", iae.getMessage()); assertEquals("the number of source shards [2] must be a factor of [3]", iae.getMessage());
} }
} }

View File

@ -154,7 +154,7 @@ public class MetaDataCreateIndexServiceTests extends ESTestCase {
MetaDataCreateIndexService.validateShrinkIndex(state, "source", Collections.emptySet(), "target", targetSettings) MetaDataCreateIndexService.validateShrinkIndex(state, "source", Collections.emptySet(), "target", targetSettings)
).getMessage()); ).getMessage());
assertEquals("the number of source shards [8] must be a must be a multiple of [3]", assertEquals("the number of source shards [8] must be a multiple of [3]",
expectThrows(IllegalArgumentException.class, () -> expectThrows(IllegalArgumentException.class, () ->
MetaDataCreateIndexService.validateShrinkIndex(createClusterState("source", 8, randomIntBetween(0, 10), MetaDataCreateIndexService.validateShrinkIndex(createClusterState("source", 8, randomIntBetween(0, 10),
Settings.builder().put("index.blocks.write", true).build()), "source", Collections.emptySet(), "target", Settings.builder().put("index.blocks.write", true).build()), "source", Collections.emptySet(), "target",
@ -221,7 +221,7 @@ public class MetaDataCreateIndexServiceTests extends ESTestCase {
).getMessage()); ).getMessage());
assertEquals("the number of source shards [3] must be a must be a factor of [4]", assertEquals("the number of source shards [3] must be a factor of [4]",
expectThrows(IllegalArgumentException.class, () -> expectThrows(IllegalArgumentException.class, () ->
MetaDataCreateIndexService.validateSplitIndex(createClusterState("source", 3, randomIntBetween(0, 10), MetaDataCreateIndexService.validateSplitIndex(createClusterState("source", 3, randomIntBetween(0, 10),
Settings.builder().put("index.blocks.write", true).build()), "source", Collections.emptySet(), "target", Settings.builder().put("index.blocks.write", true).build()), "source", Collections.emptySet(), "target",