Skip to content

Commit fd9b215

Browse files
committed
Address review comments
Signed-off-by: Shivansh Arora <hishiv@amazon.com>
1 parent 1ec2ba1 commit fd9b215

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

server/src/main/java/org/opensearch/gateway/PrimaryShardAllocator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public AllocateUnassignedDecision makeAllocationDecision(
125125
return decision;
126126
}
127127
final FetchResult<NodeGatewayStartedShards> shardState = fetchData(unassignedShard, allocation);
128-
List<NodeGatewayStartedShards> nodeShardStates = adaptToNodeShardStates(shardState);
128+
List<NodeGatewayStartedShards> nodeShardStates = adaptToNodeStartedShardList(shardState);
129129
return getAllocationDecision(unassignedShard, allocation, nodeShardStates, logger);
130130
}
131131

@@ -135,7 +135,7 @@ public AllocateUnassignedDecision makeAllocationDecision(
135135
*
136136
* @param shardsState {@link FetchResult<NodeGatewayStartedShards>}
137137
* */
138-
private static List<NodeGatewayStartedShards> adaptToNodeShardStates(FetchResult<NodeGatewayStartedShards> shardsState) {
138+
private static List<NodeGatewayStartedShards> adaptToNodeStartedShardList(FetchResult<NodeGatewayStartedShards> shardsState) {
139139
if (!shardsState.hasData()) {
140140
return null;
141141
}
@@ -150,15 +150,15 @@ protected AllocateUnassignedDecision getAllocationDecision(
150150
List<NodeGatewayStartedShards> shardState,
151151
Logger logger
152152
) {
153+
final boolean explain = allocation.debugDecision();
153154
if (shardState == null) {
154155
allocation.setHasPendingAsyncFetch();
155156
List<NodeAllocationResult> nodeDecisions = null;
156-
if (allocation.debugDecision()) {
157+
if (explain) {
157158
nodeDecisions = buildDecisionsForAllNodes(unassignedShard, allocation);
158159
}
159160
return AllocateUnassignedDecision.no(AllocationStatus.FETCHING_SHARD_DATA, nodeDecisions);
160161
}
161-
final boolean explain = allocation.debugDecision();
162162
// don't create a new IndexSetting object for every shard as this could cause a lot of garbage
163163
// on cluster restart if we allocate a boat load of shards
164164
final IndexMetadata indexMetadata = allocation.metadata().getIndexSafe(unassignedShard.index());

0 commit comments

Comments
 (0)