Skip to content

Commit fa25099

Browse files
committed
reshardAddShards
1 parent 8d10925 commit fa25099

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,11 +1998,12 @@ public Builder numberOfShards(int numberOfShards) {
19981998

19991999
/**
20002000
* Builder to create IndexMetadata that has an increased shard count (used for re-shard).
2001-
* The new shard count must be a multiple of the original shardcount.
2001+
* The new shard count must be a multiple of the original shardcount as well as a factor
2002+
* of routingNumShards.
20022003
* We do not support shrinking the shard count.
20032004
* @param targetShardCount target shard count after resharding
20042005
*/
2005-
public Builder reshardAddShards(int targetShardCount, final int sourceNumShards) {
2006+
public Builder reshardAddShards(int targetShardCount) {
20062007
if (targetShardCount % numberOfShards() != 0) {
20072008
throw new IllegalArgumentException(
20082009
"New shard count ["
@@ -2015,6 +2016,7 @@ public Builder reshardAddShards(int targetShardCount, final int sourceNumShards)
20152016
+ "]"
20162017
);
20172018
}
2019+
final int sourceNumShards = numberOfShards();
20182020
settings = Settings.builder().put(settings).put(SETTING_NUMBER_OF_SHARDS, targetShardCount).build();
20192021
var newPrimaryTerms = new long[targetShardCount];
20202022
Arrays.fill(newPrimaryTerms, this.primaryTerms.length, newPrimaryTerms.length, SequenceNumbers.UNASSIGNED_PRIMARY_TERM);

0 commit comments

Comments
 (0)