Skip to content

Commit 4dd5219

Browse files
Aman Khareshiv0408
Aman Khare
authored andcommitted
Minor refactoring
Signed-off-by: Aman Khare <amkhar@amazon.com>
1 parent 0221ee7 commit 4dd5219

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
import org.opensearch.env.ShardLockObtainFailedException;
5252
import org.opensearch.gateway.AsyncShardFetch.FetchResult;
5353
import org.opensearch.gateway.TransportNodesListGatewayStartedShards.NodeGatewayStartedShards;
54-
import org.opensearch.indices.replication.checkpoint.ReplicationCheckpoint;
5554

5655
import java.util.ArrayList;
5756
import java.util.Collection;
@@ -60,9 +59,7 @@
6059
import java.util.HashSet;
6160
import java.util.Iterator;
6261
import java.util.List;
63-
import java.util.Map;
6462
import java.util.Set;
65-
import java.util.TreeMap;
6663
import java.util.stream.Collectors;
6764
import java.util.stream.Stream;
6865

@@ -101,7 +98,7 @@ protected static boolean isResponsibleFor(final ShardRouting shard) {
10198
* @param allocation routing allocation object
10299
* @return allocation decision taken for this shard
103100
*/
104-
protected AllocateUnassignedDecision skipSnapshotRestore(ShardRouting unassignedShard, RoutingAllocation allocation) {
101+
protected AllocateUnassignedDecision getInEligibleShardDecision(ShardRouting unassignedShard, RoutingAllocation allocation) {
105102
if (isResponsibleFor(unassignedShard) == false) {
106103
// this allocator is not responsible for allocating this shard
107104
return AllocateUnassignedDecision.NOT_TAKEN;
@@ -124,7 +121,7 @@ public AllocateUnassignedDecision makeAllocationDecision(
124121
final RoutingAllocation allocation,
125122
final Logger logger
126123
) {
127-
AllocateUnassignedDecision decision = skipSnapshotRestore(unassignedShard, allocation);
124+
AllocateUnassignedDecision decision = getInEligibleShardDecision(unassignedShard, allocation);
128125
if (decision != null) {
129126
return decision;
130127
}

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,36 +33,25 @@
3333
package org.opensearch.gateway;
3434

3535
import org.apache.logging.log4j.Logger;
36-
import org.apache.logging.log4j.message.ParameterizedMessage;
3736
import org.opensearch.cluster.node.DiscoveryNode;
38-
import org.opensearch.cluster.routing.RecoverySource;
3937
import org.opensearch.cluster.routing.RoutingNode;
4038
import org.opensearch.cluster.routing.RoutingNodes;
4139
import org.opensearch.cluster.routing.ShardRouting;
42-
import org.opensearch.cluster.routing.UnassignedInfo;
4340
import org.opensearch.cluster.routing.UnassignedInfo.AllocationStatus;
4441
import org.opensearch.cluster.routing.allocation.AllocateUnassignedDecision;
4542
import org.opensearch.cluster.routing.allocation.NodeAllocationResult;
4643
import org.opensearch.cluster.routing.allocation.RoutingAllocation;
47-
import org.opensearch.env.ShardLockObtainFailedException;
4844
import org.opensearch.gateway.AsyncShardFetch.FetchResult;
4945
import org.opensearch.gateway.TransportNodesListGatewayStartedShardsBatch.NodeGatewayStartedShardsBatch;
5046
import org.opensearch.gateway.TransportNodesListGatewayStartedShardsBatch.NodeGatewayStartedShards;
51-
import org.opensearch.indices.replication.checkpoint.ReplicationCheckpoint;
5247

53-
import java.util.ArrayList;
54-
import java.util.Collection;
5548
import java.util.Collections;
5649
import java.util.Comparator;
5750
import java.util.HashMap;
5851
import java.util.HashSet;
59-
import java.util.Iterator;
6052
import java.util.List;
6153
import java.util.Map;
6254
import java.util.Set;
63-
import java.util.TreeMap;
64-
import java.util.stream.Collectors;
65-
import java.util.stream.Stream;
6655

6756
/**
6857
* PrimaryShardBatchAllocator is similar to {@link org.opensearch.gateway.PrimaryShardAllocator} only difference is
@@ -130,7 +119,7 @@ public HashMap<ShardRouting, AllocateUnassignedDecision> makeAllocationDecision(
130119
if (matchingShard == null) {
131120
matchingShard = shard;
132121
}
133-
AllocateUnassignedDecision decision = skipSnapshotRestore(matchingShard, allocation);
122+
AllocateUnassignedDecision decision = getInEligibleShardDecision(matchingShard, allocation);
134123
if (decision != null) {
135124
shardsNotEligibleForFetch.add(shard);
136125
shardAllocationDecisions.put(shard, decision);

0 commit comments

Comments
 (0)