diff --git a/server/src/main/java/org/opensearch/gateway/PrimaryShardAllocator.java b/server/src/main/java/org/opensearch/gateway/PrimaryShardAllocator.java index 719de2db6db95..1a92cfb31e2a1 100644 --- a/server/src/main/java/org/opensearch/gateway/PrimaryShardAllocator.java +++ b/server/src/main/java/org/opensearch/gateway/PrimaryShardAllocator.java @@ -51,7 +51,6 @@ import org.opensearch.env.ShardLockObtainFailedException; import org.opensearch.gateway.AsyncShardFetch.FetchResult; import org.opensearch.gateway.TransportNodesListGatewayStartedShards.NodeGatewayStartedShards; -import org.opensearch.indices.replication.checkpoint.ReplicationCheckpoint; import java.util.ArrayList; import java.util.Collection; @@ -137,13 +136,11 @@ public AllocateUnassignedDecision makeAllocationDecision( * @param shardsState {@link FetchResult} * */ private static List adaptToNodeShardStates(FetchResult shardsState) { - if (!shardsState.hasData()){ + if (!shardsState.hasData()) { return null; } List nodeShardStates = new ArrayList<>(); - shardsState.getData().forEach((node, nodeGatewayStartedShard) -> { - nodeShardStates.add(nodeGatewayStartedShard); - }); + shardsState.getData().forEach((node, nodeGatewayStartedShard) -> { nodeShardStates.add(nodeGatewayStartedShard); }); return nodeShardStates; } @@ -349,13 +346,13 @@ private static ShardStoreInfo shardStoreInfo(NodeGatewayStartedShards nodeShardS (NodeGatewayStartedShards state) -> state.storeException() == null ).reversed(); private static final Comparator PRIMARY_FIRST_COMPARATOR = Comparator.comparing( - NodeGatewayStartedShards::primary).reversed(); + NodeGatewayStartedShards::primary + ).reversed(); - private static final Comparator HIGHEST_REPLICATION_CHECKPOINT_FIRST_COMPARATOR = - Comparator.comparing( - NodeGatewayStartedShards::replicationCheckpoint, - Comparator.nullsLast(Comparator.naturalOrder()) - ); + private static final Comparator HIGHEST_REPLICATION_CHECKPOINT_FIRST_COMPARATOR = Comparator.comparing( + NodeGatewayStartedShards::replicationCheckpoint, + Comparator.nullsLast(Comparator.naturalOrder()) + ); /** * Builds a list of nodes. If matchAnyShard is set to false, only nodes that have an allocation id matching @@ -437,7 +434,10 @@ protected static NodeShardsResult buildNodeShardsResult( return new NodeShardsResult(nodeShardStates, numberOfAllocationsFound); } - private static Comparator createActiveShardComparator(boolean matchAnyShard, Set inSyncAllocationIds) { + private static Comparator createActiveShardComparator( + boolean matchAnyShard, + Set inSyncAllocationIds + ) { /** * Orders the active shards copies based on below comparators * 1. No store exception i.e. shard copy is readable