diff --git a/server/src/main/java/org/opensearch/gateway/AsyncShardFetch.java b/server/src/main/java/org/opensearch/gateway/AsyncShardFetch.java index 0f380f5559d6b..068b6c620983c 100644 --- a/server/src/main/java/org/opensearch/gateway/AsyncShardFetch.java +++ b/server/src/main/java/org/opensearch/gateway/AsyncShardFetch.java @@ -170,7 +170,6 @@ public synchronized FetchResult fetchData(DiscoveryNodes nodes, Map failedShards = clearFailedShards(); List nodeIds = cache.findNodesToFetch(); if (nodeIds.isEmpty() == false) { // mark all node as fetching and go ahead and async fetch them @@ -206,25 +205,12 @@ public synchronized FetchResult fetchData(DiscoveryNodes nodes, Map(fetchData, allIgnoreNodesMap); } } - private List clearFailedShards() { - // get failed shards from previous fetch and remove them - List failedShards = cache.getFailedShards(); - if (failedShards != null && failedShards.isEmpty() == false) { - shardAttributesMap.keySet().removeIf(failedShards::contains); - } - return failedShards; - } - /** * Called by the response handler of the async action to fetch data. Verifies that its still working * on the same cache generation, otherwise the results are discarded. It then goes and fills the relevant data for diff --git a/server/src/main/java/org/opensearch/gateway/BaseShardCache.java b/server/src/main/java/org/opensearch/gateway/BaseShardCache.java index 488be7688993c..bc8df9043be2b 100644 --- a/server/src/main/java/org/opensearch/gateway/BaseShardCache.java +++ b/server/src/main/java/org/opensearch/gateway/BaseShardCache.java @@ -74,7 +74,7 @@ protected BaseShardCache(Logger logger, String logKey, String type) { public abstract K getData(DiscoveryNode node); /** - * Provide the list of shards which got failures, these shards should be removed + * Provide the list of shards which got failures, these shards should be retried * @return list of failed shards */ public abstract List getFailedShards(); @@ -184,7 +184,7 @@ public void processResponses(List responses, long fetchingRound) { } } - public boolean validateNodeResponse(BaseNodeEntry nodeEntry, long fetchingRound) { + private boolean validateNodeResponse(BaseNodeEntry nodeEntry, long fetchingRound) { if (nodeEntry.getFetchingRound() != fetchingRound) { assert nodeEntry.getFetchingRound() > fetchingRound : "node entries only replaced by newer rounds"; logger.trace( @@ -203,7 +203,7 @@ public boolean validateNodeResponse(BaseNodeEntry nodeEntry, long fetchingRound) return true; } - public void handleNodeFailure(BaseNodeEntry nodeEntry, FailedNodeException failure, long fetchingRound) { + private void handleNodeFailure(BaseNodeEntry nodeEntry, FailedNodeException failure, long fetchingRound) { if (nodeEntry.getFetchingRound() != fetchingRound) { assert nodeEntry.getFetchingRound() > fetchingRound : "node entries only replaced by newer rounds"; logger.trace( diff --git a/server/src/main/java/org/opensearch/gateway/ShardCache.java b/server/src/main/java/org/opensearch/gateway/ShardCache.java index a5b23df3bf3b8..9669c0e24e7c9 100644 --- a/server/src/main/java/org/opensearch/gateway/ShardCache.java +++ b/server/src/main/java/org/opensearch/gateway/ShardCache.java @@ -26,10 +26,11 @@ */ public class ShardCache extends BaseShardCache { - private final Map> cache = new HashMap<>(); + private final Map> cache; public ShardCache(Logger logger, String logKey, String type) { super(logger, logKey, type); + cache = new HashMap<>(); } @Override