Skip to content

Commit

Permalink
Skip iterating over Routing Nodes
Browse files Browse the repository at this point in the history
Signed-off-by: Shivansh Arora <[email protected]>
  • Loading branch information
shiv0408 committed Mar 19, 2024
1 parent e2b8c0b commit bffa5cd
Showing 1 changed file with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,15 @@ public void processExistingRecoveries(RoutingAllocation allocation, List<List<Sh
for (List<ShardRouting> shardBatch : shardBatches) {
List<ShardRouting> eligibleShards = new ArrayList<>();
List<ShardRouting> ineligibleShards = new ArrayList<>();
boolean shardMatched;
// iterate over shards to check for match for each of those
for (ShardRouting shard : shardBatch) {
shardMatched = false;
// need to iterate over all the nodes to find matching shard
for (RoutingNode routingNode : routingNodes) {
ShardRouting shardFromRoutingNode = routingNode.getByShardId(shard.shardId());
if (shardFromRoutingNode != null && !shardFromRoutingNode.primary()) {
shardMatched = true;
if (shouldSkipFetchForRecovery(shardFromRoutingNode)) {
ineligibleShards.add(shardFromRoutingNode);
continue;
}
eligibleShards.add(shardFromRoutingNode);
}
if (shardMatched) {
break;
if (shard != null && !shard.primary()) {
// need to iterate over all the nodes to find matching shard
if (shouldSkipFetchForRecovery(shard)) {
ineligibleShards.add(shard);
continue;
}
eligibleShards.add(shard);
}
}
AsyncShardFetch.FetchResult<NodeStoreFilesMetadataBatch> shardState = fetchData(eligibleShards, ineligibleShards, allocation);
Expand Down

0 comments on commit bffa5cd

Please sign in to comment.