From 6db8ba441fbf16e5a8109d22a37c7b6db42d07e5 Mon Sep 17 00:00:00 2001 From: sudarshan baliga Date: Tue, 4 Jul 2023 13:47:09 +0530 Subject: [PATCH] Add spotlessCheck violation fix Signed-off-by: sudarshan baliga --- .../gateway/AsyncShardsFetchPerNode.java | 1 - .../gateway/ReplicaShardAllocator.java | 3 +- ...sportNodesBatchListShardStoreMetadata.java | 76 +++++++++---------- .../TransportNodesListShardStoreMetadata.java | 6 +- 4 files changed, 44 insertions(+), 42 deletions(-) diff --git a/server/src/main/java/org/opensearch/gateway/AsyncShardsFetchPerNode.java b/server/src/main/java/org/opensearch/gateway/AsyncShardsFetchPerNode.java index 6e028a2f4513b..e0656871e2afa 100644 --- a/server/src/main/java/org/opensearch/gateway/AsyncShardsFetchPerNode.java +++ b/server/src/main/java/org/opensearch/gateway/AsyncShardsFetchPerNode.java @@ -17,7 +17,6 @@ import java.util.Map; - /** * This class is responsible for fetching shard data from nodes. It is analogous to AsyncShardFetch class except * that we fetch batch of shards in this class from single transport request to a node. diff --git a/server/src/main/java/org/opensearch/gateway/ReplicaShardAllocator.java b/server/src/main/java/org/opensearch/gateway/ReplicaShardAllocator.java index e549344dda9d0..8026415915491 100644 --- a/server/src/main/java/org/opensearch/gateway/ReplicaShardAllocator.java +++ b/server/src/main/java/org/opensearch/gateway/ReplicaShardAllocator.java @@ -386,7 +386,8 @@ private MatchingNodes findMatchingNodes( && shard.unassignedInfo().getFailedNodeIds().contains(discoNode.getId())) { continue; } - TransportNodesListShardStoreMetadataHelper.StoreFilesMetadata storeFilesMetadata = nodeStoreEntry.getValue().storeFilesMetadata(); + TransportNodesListShardStoreMetadataHelper.StoreFilesMetadata storeFilesMetadata = nodeStoreEntry.getValue() + .storeFilesMetadata(); // we don't have any files at all, it is an empty index if (storeFilesMetadata.isEmpty()) { continue; diff --git a/server/src/main/java/org/opensearch/indices/store/TransportNodesBatchListShardStoreMetadata.java b/server/src/main/java/org/opensearch/indices/store/TransportNodesBatchListShardStoreMetadata.java index 280e7f03eeb34..4fb555ba80a42 100644 --- a/server/src/main/java/org/opensearch/indices/store/TransportNodesBatchListShardStoreMetadata.java +++ b/server/src/main/java/org/opensearch/indices/store/TransportNodesBatchListShardStoreMetadata.java @@ -48,13 +48,17 @@ public class TransportNodesBatchListShardStoreMetadata extends TransportNodesAct TransportNodesBatchListShardStoreMetadata.Request, TransportNodesBatchListShardStoreMetadata.NodesStoreFilesMetadata, TransportNodesBatchListShardStoreMetadata.NodeRequest, - TransportNodesBatchListShardStoreMetadata.NodeStoreFilesMetadataBatch> implements - AsyncShardsFetchPerNode.Lister< - TransportNodesBatchListShardStoreMetadata.NodesStoreFilesMetadata, - TransportNodesBatchListShardStoreMetadata.NodeStoreFilesMetadataBatch> { + TransportNodesBatchListShardStoreMetadata.NodeStoreFilesMetadataBatch> + implements + AsyncShardsFetchPerNode.Lister< + TransportNodesBatchListShardStoreMetadata.NodesStoreFilesMetadata, + TransportNodesBatchListShardStoreMetadata.NodeStoreFilesMetadataBatch> { public static final String ACTION_NAME = "internal:cluster/nodes/indices/shard/store/batch"; - public static final ActionType TYPE = new ActionType<>(ACTION_NAME, TransportNodesListShardStoreMetadata.NodesStoreFilesMetadata::new); + public static final ActionType TYPE = new ActionType<>( + ACTION_NAME, + TransportNodesListShardStoreMetadata.NodesStoreFilesMetadata::new + ); private final Settings settings; private final IndicesService indicesService; @@ -87,7 +91,11 @@ public TransportNodesBatchListShardStoreMetadata( } @Override - public void list(DiscoveryNode[] nodes, Map shardIdsWithCustomDataPath, ActionListener listener) { + public void list( + DiscoveryNode[] nodes, + Map shardIdsWithCustomDataPath, + ActionListener listener + ) { execute(new TransportNodesBatchListShardStoreMetadata.Request(shardIdsWithCustomDataPath, nodes), listener); } @@ -125,42 +133,30 @@ protected NodeStoreFilesMetadataBatch nodeOperation(NodeRequest request) { */ private Map listStoreMetadata(NodeRequest request) throws IOException { Map shardStoreMetadataMap = new HashMap(); - for(Map.Entry shardToCustomDataPathEntry: request.getShardIdsWithCustomDataPath().entrySet()) { + for (Map.Entry shardToCustomDataPathEntry : request.getShardIdsWithCustomDataPath().entrySet()) { final ShardId shardId = shardToCustomDataPathEntry.getKey(); try { logger.debug("Listing store meta data for {}", shardId); - TransportNodesListShardStoreMetadataHelper.StoreFilesMetadata nodeStoreFilesMetadata = TransportNodesListShardStoreMetadataHelper.getStoreFilesMetadata( - logger, - indicesService, - clusterService, - shardId, - shardToCustomDataPathEntry.getValue(), - settings, - nodeEnv - ); - shardStoreMetadataMap.put( - shardId, - new NodeStoreFilesMetadata( - nodeStoreFilesMetadata, - null - ) - ); + TransportNodesListShardStoreMetadataHelper.StoreFilesMetadata nodeStoreFilesMetadata = + TransportNodesListShardStoreMetadataHelper.getStoreFilesMetadata( + logger, + indicesService, + clusterService, + shardId, + shardToCustomDataPathEntry.getValue(), + settings, + nodeEnv + ); + shardStoreMetadataMap.put(shardId, new NodeStoreFilesMetadata(nodeStoreFilesMetadata, null)); } catch (Exception storeFileFetchException) { logger.trace(new ParameterizedMessage("Unable to fetch store files for shard [{}]", shardId), storeFileFetchException); - shardStoreMetadataMap.put( - shardId, - new NodeStoreFilesMetadata( - null, - storeFileFetchException - ) - ); + shardStoreMetadataMap.put(shardId, new NodeStoreFilesMetadata(null, storeFileFetchException)); } } logger.debug("Loaded store meta data for {} shards", shardStoreMetadataMap); return shardStoreMetadataMap; } - /** * The request * @@ -170,7 +166,6 @@ public static class Request extends BaseNodesRequest { private final Map shardIdsWithCustomDataPath; - public Request(StreamInput in) throws IOException { super(in); shardIdsWithCustomDataPath = in.readMap(ShardId::new, StreamInput::readString); @@ -185,7 +180,6 @@ public Map getShardIdsWithCustomDataPath() { return shardIdsWithCustomDataPath; } - @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); @@ -204,7 +198,11 @@ public NodesStoreFilesMetadata(StreamInput in) throws IOException { super(in); } - public NodesStoreFilesMetadata(ClusterName clusterName, List nodes, List failures) { + public NodesStoreFilesMetadata( + ClusterName clusterName, + List nodes, + List failures + ) { super(clusterName, nodes, failures); } @@ -239,7 +237,10 @@ public NodeStoreFilesMetadata(StreamInput in) throws IOException { this.storeFileFetchException = null; } - public NodeStoreFilesMetadata(TransportNodesListShardStoreMetadataHelper.StoreFilesMetadata storeFilesMetadata, Exception storeFileFetchException) { + public NodeStoreFilesMetadata( + TransportNodesListShardStoreMetadataHelper.StoreFilesMetadata storeFilesMetadata, + Exception storeFileFetchException + ) { this.storeFilesMetadata = storeFilesMetadata; this.storeFileFetchException = storeFileFetchException; } @@ -295,15 +296,14 @@ public Map getShardIdsWithCustomDataPath() { } } - public static class NodeStoreFilesMetadataBatch extends BaseNodeResponse { private final Map nodeStoreFilesMetadataBatch; + protected NodeStoreFilesMetadataBatch(StreamInput in) throws IOException { super(in); - this.nodeStoreFilesMetadataBatch = in.readMap(ShardId::new, NodeStoreFilesMetadata::new); + this.nodeStoreFilesMetadataBatch = in.readMap(ShardId::new, NodeStoreFilesMetadata::new); } - public NodeStoreFilesMetadataBatch(DiscoveryNode node, Map nodeStoreFilesMetadataBatch) { super(node); this.nodeStoreFilesMetadataBatch = nodeStoreFilesMetadataBatch; diff --git a/server/src/main/java/org/opensearch/indices/store/TransportNodesListShardStoreMetadata.java b/server/src/main/java/org/opensearch/indices/store/TransportNodesListShardStoreMetadata.java index 0e5d79ecef368..6436b288aea4e 100644 --- a/server/src/main/java/org/opensearch/indices/store/TransportNodesListShardStoreMetadata.java +++ b/server/src/main/java/org/opensearch/indices/store/TransportNodesListShardStoreMetadata.java @@ -156,7 +156,6 @@ private TransportNodesListShardStoreMetadataHelper.StoreFilesMetadata listStoreM ); } - /** * The request * @@ -287,7 +286,10 @@ public NodeStoreFilesMetadata(StreamInput in) throws IOException { storeFilesMetadata = new TransportNodesListShardStoreMetadataHelper.StoreFilesMetadata(in); } - public NodeStoreFilesMetadata(DiscoveryNode node, TransportNodesListShardStoreMetadataHelper.StoreFilesMetadata storeFilesMetadata) { + public NodeStoreFilesMetadata( + DiscoveryNode node, + TransportNodesListShardStoreMetadataHelper.StoreFilesMetadata storeFilesMetadata + ) { super(node); this.storeFilesMetadata = storeFilesMetadata; }