Skip to content

Commit

Permalink
Randomise nodes shards iterator for move
Browse files Browse the repository at this point in the history
Signed-off-by: Rishab Nahata <rnnahata@amazon.com>
  • Loading branch information
imRishN committed Aug 15, 2024
1 parent 0e9151c commit 7fe10d7
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,9 @@ public void remove() {
*/
public Iterator<ShardRouting> nodeInterleavedShardIterator(ShardMovementStrategy shardMovementStrategy) {
final Queue<Iterator<ShardRouting>> queue = new ArrayDeque<>();
for (Map.Entry<String, RoutingNode> entry : nodesToShards.entrySet()) {
List<Map.Entry<String, RoutingNode>> nodesToShardsEntrySet = new ArrayList<>(nodesToShards.entrySet());
Randomness.shuffle(nodesToShardsEntrySet);
for (Map.Entry<String, RoutingNode> entry : nodesToShardsEntrySet) {
queue.add(entry.getValue().copyShards().iterator());
}
if (shardMovementStrategy == ShardMovementStrategy.PRIMARY_FIRST) {
Expand Down

0 comments on commit 7fe10d7

Please sign in to comment.