Skip to content

Commit

Permalink
Made minor refactor in RSBA
Browse files Browse the repository at this point in the history
Signed-off-by: Shivansh Arora <[email protected]>
  • Loading branch information
shiv0408 committed Dec 14, 2023
1 parent 8ec38e5 commit 48b3a90
Showing 1 changed file with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void processExistingRecoveries(RoutingAllocation allocation, List<Set<Sha
continue; // still fetching
}
for (ShardRouting shard : eligibleFetchShards) {
Map<DiscoveryNode, StoreFilesMetadata> nodeShardStores = getNodeShardStores(shard, shardState);
Map<DiscoveryNode, StoreFilesMetadata> nodeShardStores = convertToNodeStoreFilesMetadataMap(shard, shardState);

Runnable cancellationAction = getShardCancellationAction(shard, allocation, nodeShardStores);
if (cancellationAction != null) {
Expand Down Expand Up @@ -166,33 +166,23 @@ public HashMap<ShardRouting, AllocateUnassignedDecision> makeAllocationDecision(
);

for (ShardRouting unassignedShard : shardsEligibleForFetch) {
if (!shardsState.hasData()) {
logger.trace("{}: ignoring allocation, still fetching shard stores", unassignedShard);
allocation.setHasPendingAsyncFetch();
List<NodeAllocationResult> nodeDecisions = null;
if (explain) {
nodeDecisions = buildDecisionsForAllNodes(unassignedShard, allocation);
}
shardAllocationDecisions.put(
unassignedShard,
AllocateUnassignedDecision.no(UnassignedInfo.AllocationStatus.FETCHING_SHARD_DATA, nodeDecisions)
);
continue;
}
Tuple<Decision, Map<String, NodeAllocationResult>> result = nodeAllocationDecisions.get(unassignedShard);
shardAllocationDecisions.put(
unassignedShard,
getAllocationDecision(unassignedShard, allocation, getNodeShardStores(unassignedShard, shardsState), result, logger)
getAllocationDecision(unassignedShard, allocation, convertToNodeStoreFilesMetadataMap(unassignedShard, shardsState), result, logger)
);
}
return shardAllocationDecisions;
}

private Map<DiscoveryNode, StoreFilesMetadata> getNodeShardStores(
private Map<DiscoveryNode, StoreFilesMetadata> convertToNodeStoreFilesMetadataMap(
ShardRouting unassignedShard,
FetchResult<NodeStoreFilesMetadataBatch> data
) {
assert data.hasData();
if (!data.hasData()) {
// if we don't have any data, return null
return null;
}
return new HashMap<>(
data.getData()
.entrySet()
Expand Down

0 comments on commit 48b3a90

Please sign in to comment.