From 7418d66d1363eadafb8a4f3fcf1aebaa404bd040 Mon Sep 17 00:00:00 2001 From: Shivansh Arora Date: Wed, 20 Sep 2023 13:31:43 +0530 Subject: [PATCH] Spotless changes Signed-off-by: Shivansh Arora --- .../gateway/PrimaryShardAllocator.java | 59 +++++++++---------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/server/src/main/java/org/opensearch/gateway/PrimaryShardAllocator.java b/server/src/main/java/org/opensearch/gateway/PrimaryShardAllocator.java index 06c208f48717a..0fcfd0a96b8ac 100644 --- a/server/src/main/java/org/opensearch/gateway/PrimaryShardAllocator.java +++ b/server/src/main/java/org/opensearch/gateway/PrimaryShardAllocator.java @@ -58,7 +58,6 @@ import java.util.Collections; import java.util.Comparator; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.TreeMap; @@ -143,15 +142,16 @@ public AllocateUnassignedDecision makeAllocationDecision( private static NodeShardStates adaptToNodeShardStates(FetchResult shardsState) { NodeShardStates nodeShardStates = new NodeShardStates(); shardsState.getData().forEach((node, nodeGatewayStartedShard) -> { - nodeShardStates.getNodeShardStates().add( - new NodeShardState( - node, - nodeGatewayStartedShard.allocationId(), - nodeGatewayStartedShard.primary(), - nodeGatewayStartedShard.replicationCheckpoint(), - nodeGatewayStartedShard.storeException() - ) - ); + nodeShardStates.getNodeShardStates() + .add( + new NodeShardState( + node, + nodeGatewayStartedShard.allocationId(), + nodeGatewayStartedShard.primary(), + nodeGatewayStartedShard.replicationCheckpoint(), + nodeGatewayStartedShard.storeException() + ) + ); }); return nodeShardStates; } @@ -323,8 +323,7 @@ private static List buildNodeDecisions( }) .collect(Collectors.toList()) ); - ineligibleShards = fetchedShardData - .getNodeShardStates() + ineligibleShards = fetchedShardData.getNodeShardStates() .stream() .filter(shardData -> discoNodes.contains(shardData.getNode()) == false) .collect(Collectors.toList()); @@ -392,24 +391,24 @@ protected NodeShardsResult buildNodeShardsResult( final String finalAllocationId = allocationId; if (nodeShardState.storeException() instanceof ShardLockObtainFailedException) { logger.trace( - () -> new ParameterizedMessage( - "[{}] on node [{}] has allocation id [{}] but the store can not be " - + "opened as it's locked, treating as valid shard", - shard, - nodeShardState.getNode(), - finalAllocationId - ), - nodeShardState.storeException() + () -> new ParameterizedMessage( + "[{}] on node [{}] has allocation id [{}] but the store can not be " + + "opened as it's locked, treating as valid shard", + shard, + nodeShardState.getNode(), + finalAllocationId + ), + nodeShardState.storeException() ); } else { logger.trace( - () -> new ParameterizedMessage( - "[{}] on node [{}] has allocation id [{}] but the store can not be " + "opened, treating as no allocation id", - shard, - nodeShardState.getNode(), - finalAllocationId - ), - nodeShardState.storeException() + () -> new ParameterizedMessage( + "[{}] on node [{}] has allocation id [{}] but the store can not be " + "opened, treating as no allocation id", + shard, + nodeShardState.getNode(), + finalAllocationId + ), + nodeShardState.storeException() ); allocationId = null; } @@ -417,7 +416,7 @@ protected NodeShardsResult buildNodeShardsResult( if (allocationId != null) { assert nodeShardState.storeException() == null || nodeShardState.storeException() instanceof ShardLockObtainFailedException - : "only allow store that can be opened or that throws a ShardLockObtainFailedException while being opened but got a " + : "only allow store that can be opened or that throws a ShardLockObtainFailedException while being opened but got a " + "store throwing " + nodeShardState.storeException(); numberOfAllocationsFound++; @@ -482,8 +481,8 @@ protected static NodesToAllocate buildNodesToAllocate( } Decision decision = forceAllocate - ? allocation.deciders().canForceAllocatePrimary(shardRouting, node, allocation) - : allocation.deciders().canAllocate(shardRouting, node, allocation); + ? allocation.deciders().canForceAllocatePrimary(shardRouting, node, allocation) + : allocation.deciders().canAllocate(shardRouting, node, allocation); DecidedNode decidedNode = new DecidedNode(nodeShardState, decision); if (decision.type() == Type.THROTTLE) { throttledNodeShards.add(decidedNode);