From fd9b21530ad9eca15fc737d4c30e44194ac5aa14 Mon Sep 17 00:00:00 2001 From: Shivansh Arora Date: Mon, 5 Feb 2024 01:00:47 +0530 Subject: [PATCH] Address review comments Signed-off-by: Shivansh Arora --- .../org/opensearch/gateway/PrimaryShardAllocator.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/org/opensearch/gateway/PrimaryShardAllocator.java b/server/src/main/java/org/opensearch/gateway/PrimaryShardAllocator.java index 1a92cfb31e2a1..1b1e0a6c21ef3 100644 --- a/server/src/main/java/org/opensearch/gateway/PrimaryShardAllocator.java +++ b/server/src/main/java/org/opensearch/gateway/PrimaryShardAllocator.java @@ -125,7 +125,7 @@ public AllocateUnassignedDecision makeAllocationDecision( return decision; } final FetchResult shardState = fetchData(unassignedShard, allocation); - List nodeShardStates = adaptToNodeShardStates(shardState); + List nodeShardStates = adaptToNodeStartedShardList(shardState); return getAllocationDecision(unassignedShard, allocation, nodeShardStates, logger); } @@ -135,7 +135,7 @@ public AllocateUnassignedDecision makeAllocationDecision( * * @param shardsState {@link FetchResult} * */ - private static List adaptToNodeShardStates(FetchResult shardsState) { + private static List adaptToNodeStartedShardList(FetchResult shardsState) { if (!shardsState.hasData()) { return null; } @@ -150,15 +150,15 @@ protected AllocateUnassignedDecision getAllocationDecision( List shardState, Logger logger ) { + final boolean explain = allocation.debugDecision(); if (shardState == null) { allocation.setHasPendingAsyncFetch(); List nodeDecisions = null; - if (allocation.debugDecision()) { + if (explain) { nodeDecisions = buildDecisionsForAllNodes(unassignedShard, allocation); } return AllocateUnassignedDecision.no(AllocationStatus.FETCHING_SHARD_DATA, nodeDecisions); } - final boolean explain = allocation.debugDecision(); // don't create a new IndexSetting object for every shard as this could cause a lot of garbage // on cluster restart if we allocate a boat load of shards final IndexMetadata indexMetadata = allocation.metadata().getIndexSafe(unassignedShard.index());