Skip to content

Commit

Permalink
Add spotlessCheck violation fix
Browse files Browse the repository at this point in the history
Signed-off-by: sudarshan baliga <[email protected]>
  • Loading branch information
sudarshan-baliga committed Jul 4, 2023
1 parent fb5a983 commit 6db8ba4
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TransportNodesListShardStoreMetadata.NodesStoreFilesMetadata> TYPE = new ActionType<>(ACTION_NAME, TransportNodesListShardStoreMetadata.NodesStoreFilesMetadata::new);
public static final ActionType<TransportNodesListShardStoreMetadata.NodesStoreFilesMetadata> TYPE = new ActionType<>(
ACTION_NAME,
TransportNodesListShardStoreMetadata.NodesStoreFilesMetadata::new
);

private final Settings settings;
private final IndicesService indicesService;
Expand Down Expand Up @@ -87,7 +91,11 @@ public TransportNodesBatchListShardStoreMetadata(
}

@Override
public void list(DiscoveryNode[] nodes, Map<ShardId,String> shardIdsWithCustomDataPath, ActionListener<NodesStoreFilesMetadata> listener) {
public void list(
DiscoveryNode[] nodes,
Map<ShardId, String> shardIdsWithCustomDataPath,
ActionListener<NodesStoreFilesMetadata> listener
) {
execute(new TransportNodesBatchListShardStoreMetadata.Request(shardIdsWithCustomDataPath, nodes), listener);
}

Expand Down Expand Up @@ -125,42 +133,30 @@ protected NodeStoreFilesMetadataBatch nodeOperation(NodeRequest request) {
*/
private Map<ShardId, NodeStoreFilesMetadata> listStoreMetadata(NodeRequest request) throws IOException {
Map<ShardId, NodeStoreFilesMetadata> shardStoreMetadataMap = new HashMap<ShardId, NodeStoreFilesMetadata>();
for(Map.Entry<ShardId, String> shardToCustomDataPathEntry: request.getShardIdsWithCustomDataPath().entrySet()) {
for (Map.Entry<ShardId, String> 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
*
Expand All @@ -170,7 +166,6 @@ public static class Request extends BaseNodesRequest<Request> {

private final Map<ShardId, String> shardIdsWithCustomDataPath;


public Request(StreamInput in) throws IOException {
super(in);
shardIdsWithCustomDataPath = in.readMap(ShardId::new, StreamInput::readString);
Expand All @@ -185,7 +180,6 @@ public Map<ShardId, String> getShardIdsWithCustomDataPath() {
return shardIdsWithCustomDataPath;
}


@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
Expand All @@ -204,7 +198,11 @@ public NodesStoreFilesMetadata(StreamInput in) throws IOException {
super(in);
}

public NodesStoreFilesMetadata(ClusterName clusterName, List<NodeStoreFilesMetadataBatch> nodes, List<FailedNodeException> failures) {
public NodesStoreFilesMetadata(
ClusterName clusterName,
List<NodeStoreFilesMetadataBatch> nodes,
List<FailedNodeException> failures
) {
super(clusterName, nodes, failures);
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -295,15 +296,14 @@ public Map<ShardId, String> getShardIdsWithCustomDataPath() {
}
}


public static class NodeStoreFilesMetadataBatch extends BaseNodeResponse {
private final Map<ShardId, NodeStoreFilesMetadata> 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<ShardId, NodeStoreFilesMetadata> nodeStoreFilesMetadataBatch) {
super(node);
this.nodeStoreFilesMetadataBatch = nodeStoreFilesMetadataBatch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ private TransportNodesListShardStoreMetadataHelper.StoreFilesMetadata listStoreM
);
}


/**
* The request
*
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 6db8ba4

Please sign in to comment.