java.io.Closeable
, java.lang.AutoCloseable
, Releasable
public abstract class AsyncShardFetch<T extends BaseNodeResponse> extends java.lang.Object implements Releasable
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.
Modifier and Type | Class | Description |
---|---|---|
static class |
AsyncShardFetch.FetchResult<T extends BaseNodeResponse> |
The result of a fetch operation.
|
static interface |
AsyncShardFetch.Lister<NodesResponse extends BaseNodesResponse<NodeResponse>,NodeResponse extends BaseNodeResponse> |
An action that lists the relevant shard data that needs to be fetched.
|
Modifier and Type | Field | Description |
---|---|---|
protected org.apache.logging.log4j.Logger |
logger |
|
protected ShardId |
shardId |
|
protected java.lang.String |
type |
Modifier | Constructor | Description |
---|---|---|
protected |
AsyncShardFetch(org.apache.logging.log4j.Logger logger,
java.lang.String type,
ShardId shardId,
AsyncShardFetch.Lister<? extends BaseNodesResponse<T>,T> action) |
Modifier and Type | Method | Description |
---|---|---|
void |
close() |
|
AsyncShardFetch.FetchResult<T> |
fetchData(DiscoveryNodes nodes,
java.util.Set<java.lang.String> ignoreNodes) |
Fetches the data for the relevant shard.
|
int |
getNumberOfInFlightFetches() |
Returns the number of async fetches that are currently ongoing.
|
protected void |
processAsyncFetch(java.util.List<T> responses,
java.util.List<FailedNodeException> failures,
long fetchingRound) |
Called by the response handler of the async action to fetch data.
|
protected abstract void |
reroute(ShardId shardId,
java.lang.String reason) |
Implement this in order to scheduled another round that causes a call to fetch data.
|
protected final org.apache.logging.log4j.Logger logger
protected final java.lang.String type
protected final ShardId shardId
protected AsyncShardFetch(org.apache.logging.log4j.Logger logger, java.lang.String type, ShardId shardId, AsyncShardFetch.Lister<? extends BaseNodesResponse<T>,T> action)
public void close()
close
in interface java.lang.AutoCloseable
close
in interface java.io.Closeable
close
in interface Releasable
public int getNumberOfInFlightFetches()
public AsyncShardFetch.FetchResult<T> fetchData(DiscoveryNodes nodes, java.util.Set<java.lang.String> ignoreNodes)
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.
protected void processAsyncFetch(java.util.List<T> responses, java.util.List<FailedNodeException> failures, long fetchingRound)
protected abstract void reroute(ShardId shardId, java.lang.String reason)