Skip to content

Commit

Permalink
spotless apply
Browse files Browse the repository at this point in the history
Signed-off-by: Aman Khare <[email protected]>
  • Loading branch information
Aman Khare committed Mar 15, 2024
1 parent b227828 commit e0cff1a
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -793,10 +793,7 @@ public void testShardFetchMultiNodeMultiIndexesUsingBatchAction() {
ShardId shardId = clusterSearchShardsGroup.getShardId();
assertEquals(1, clusterSearchShardsGroup.getShards().length);
String nodeId = clusterSearchShardsGroup.getShards()[0].currentNodeId();
GatewayShardStarted gatewayShardStarted = response.getNodesMap()
.get(nodeId)
.getNodeGatewayStartedShardsBatch()
.get(shardId);
GatewayShardStarted gatewayShardStarted = response.getNodesMap().get(nodeId).getNodeGatewayStartedShardsBatch().get(shardId);
assertNodeGatewayStartedShardsHappyCase(gatewayShardStarted);
}
}
Expand Down Expand Up @@ -951,9 +948,7 @@ private void assertNodeStoreFilesMetadataSuccessCase(
assertNotNull(storeFileMetadata.peerRecoveryRetentionLeases());
}

private void assertNodeGatewayStartedShardsHappyCase(
GatewayShardStarted gatewayShardStarted
) {
private void assertNodeGatewayStartedShardsHappyCase(GatewayShardStarted gatewayShardStarted) {
assertNull(gatewayShardStarted.storeException());
assertNotNull(gatewayShardStarted.allocationId());
assertTrue(gatewayShardStarted.primary());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,17 @@ private static List<NodeGatewayShardStarted> adaptToNodeStartedShardList(FetchRe
return null;
}
List<NodeGatewayShardStarted> nodeShardStates = new ArrayList<>();
shardsState.getData().forEach((node, nodeGatewayStartedShard) -> { nodeShardStates.add(new NodeGatewayShardStarted(
nodeGatewayStartedShard.allocationId(),
nodeGatewayStartedShard.primary(),
nodeGatewayStartedShard.replicationCheckpoint(),
nodeGatewayStartedShard.storeException(),
node
)); });
shardsState.getData().forEach((node, nodeGatewayStartedShard) -> {
nodeShardStates.add(
new NodeGatewayShardStarted(
nodeGatewayStartedShard.allocationId(),
nodeGatewayStartedShard.primary(),
nodeGatewayStartedShard.replicationCheckpoint(),
nodeGatewayStartedShard.storeException(),
node
)
);
});
return nodeShardStates;
}

Expand Down Expand Up @@ -439,10 +443,7 @@ protected static NodeShardsResult buildNodeShardsResult(
return new NodeShardsResult(nodeShardStates, numberOfAllocationsFound);
}

private static Comparator<NodeGatewayShardStarted> createActiveShardComparator(
boolean matchAnyShard,
Set<String> inSyncAllocationIds
) {
private static Comparator<NodeGatewayShardStarted> createActiveShardComparator(boolean matchAnyShard, Set<String> inSyncAllocationIds) {
/**
* Orders the active shards copies based on below comparators
* 1. No store exception i.e. shard copy is readable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,7 @@ public HashMap<ShardRouting, AllocateUnassignedDecision> makeAllocationDecision(

// process the received data
for (ShardRouting unassignedShard : eligibleShards) {
List<NodeGatewayShardStarted> nodeShardStates = adaptToNodeShardStates(
unassignedShard,
shardsState
);
List<NodeGatewayShardStarted> nodeShardStates = adaptToNodeShardStates(unassignedShard, shardsState);
// get allocation decision for this shard
shardAllocationDecisions.put(unassignedShard, getAllocationDecision(unassignedShard, allocation, nodeShardStates, logger));
}
Expand Down Expand Up @@ -135,7 +132,8 @@ private static List<NodeGatewayShardStarted> adaptToNodeShardStates(

// build data for a shard from all the nodes
nodeResponses.forEach((node, nodeGatewayStartedShardsBatch) -> {
TransportNodesGatewayStartedShardHelper.GatewayShardStarted shardData = nodeGatewayStartedShardsBatch.getNodeGatewayStartedShardsBatch()
TransportNodesGatewayStartedShardHelper.GatewayShardStarted shardData = nodeGatewayStartedShardsBatch
.getNodeGatewayStartedShardsBatch()
.get(unassignedShard.shardId());
nodeShardStates.add(
new NodeGatewayShardStarted(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,7 @@ public static GatewayShardStarted getShardInfoOnLocalNode(
exception
);
String allocationId = shardStateMetadata.allocationId != null ? shardStateMetadata.allocationId.getId() : null;
return new GatewayShardStarted(
allocationId,
shardStateMetadata.primary,
null,
exception
);
return new GatewayShardStarted(allocationId, shardStateMetadata.primary, null, exception);
}
}

Expand Down Expand Up @@ -241,9 +236,13 @@ public static class NodeGatewayShardStarted extends GatewayShardStarted {

private final DiscoveryNode node;

public NodeGatewayShardStarted(String allocationId, boolean primary,
ReplicationCheckpoint replicationCheckpoint, Exception storeException,
DiscoveryNode node) {
public NodeGatewayShardStarted(
String allocationId,
boolean primary,
ReplicationCheckpoint replicationCheckpoint,
Exception storeException,
DiscoveryNode node
) {
super(allocationId, primary, replicationCheckpoint, storeException);
this.node = node;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@
import org.opensearch.core.index.shard.ShardId;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.env.NodeEnvironment;
import org.opensearch.gateway.TransportNodesGatewayStartedShardHelper.GatewayShardStarted;
import org.opensearch.indices.IndicesService;
import org.opensearch.indices.replication.checkpoint.ReplicationCheckpoint;
import org.opensearch.indices.store.ShardAttributes;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.TransportRequest;
import org.opensearch.transport.TransportService;
import org.opensearch.gateway.TransportNodesGatewayStartedShardHelper.GatewayShardStarted;

import java.io.IOException;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import org.opensearch.core.index.shard.ShardId;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.env.NodeEnvironment;
import org.opensearch.indices.IndicesService;
import org.opensearch.gateway.TransportNodesGatewayStartedShardHelper.GatewayShardStarted;
import org.opensearch.indices.IndicesService;
import org.opensearch.indices.store.ShardAttributes;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.TransportRequest;
Expand Down Expand Up @@ -248,8 +248,6 @@ public void writeTo(StreamOutput out) throws IOException {
}
}



/**
* This is the response from a single node, this is used in {@link NodesGatewayStartedShardsBatch} for creating
* node to its response mapping for this transport request.
Expand Down

0 comments on commit e0cff1a

Please sign in to comment.