Module org.elasticsearch.server
Package org.elasticsearch.gateway
Class AsyncShardFetch<T extends BaseNodeResponse>
java.lang.Object
org.elasticsearch.gateway.AsyncShardFetch<T>
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Releasable
public abstract class AsyncShardFetch<T extends BaseNodeResponse>
extends Object
implements Releasable
Allows to asynchronously fetch shard related data from other nodes for allocation, without blocking
the cluster update thread.
The async fetch logic maintains a map of which nodes are being fetched from in an async manner, and once the results are back, it makes sure to schedule a reroute to make sure those results will be taken into account.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
AsyncShardFetch.FetchResult<T extends BaseNodeResponse>
The result of a fetch operation. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AsyncShardFetch
(org.apache.logging.log4j.Logger logger, String type, ShardId shardId, String customDataPath, int expectedSize) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
fetchData
(DiscoveryNodes nodes, Set<String> ignoreNodes) Fetches the data for the relevant shard.int
Returns the number of async fetches that are currently ongoing.protected abstract void
list
(ShardId shardId, String customDataPath, DiscoveryNode[] nodes, ActionListener<BaseNodesResponse<T>> listener) protected void
processAsyncFetch
(List<T> responses, List<FailedNodeException> failures, long fetchingRound) Called by the response handler of the async action to fetch data.protected abstract void
Implement this in order to scheduled another round that causes a call to fetch data.
-
Field Details
-
logger
protected final org.apache.logging.log4j.Logger logger -
type
-
shardId
-
customDataPath
-
-
Constructor Details
-
AsyncShardFetch
-
-
Method Details
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceReleasable
-
getNumberOfInFlightFetches
public int getNumberOfInFlightFetches()Returns the number of async fetches that are currently ongoing. -
fetchData
Fetches the data for the relevant shard. If there any ongoing async fetches going on, or new ones have been initiated by this call, the result will have no data.The ignoreNodes are nodes that are supposed to be ignored for this round, since fetching is async, we need to keep them around and make sure we add them back when all the responses are fetched and returned.
-
processAsyncFetch
protected void processAsyncFetch(List<T> responses, List<FailedNodeException> failures, long fetchingRound) 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 the shard (response + failures), issuing a reroute at the end of it to make sure there will be another round of allocations taking this new data into account. -
reroute
Implement this in order to scheduled another round that causes a call to fetch data. -
list
protected abstract void list(ShardId shardId, @Nullable String customDataPath, DiscoveryNode[] nodes, ActionListener<BaseNodesResponse<T>> listener)
-