T
- Type of the statistics to be gathered.V
- Type of the combined response.public class TaskStatsRequestCoordinator<T,V> extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
TaskStatsRequestCoordinator.PendingStatsRequest<T,V>
A pending task stats request, which collects samples from individual tasks and completes the
response future upon gathering all of of them.
|
Modifier and Type | Field and Description |
---|---|
protected Executor |
executor
Executor used to run the futures.
|
protected boolean |
isShutDown
Flag indicating whether the coordinator is still running.
|
protected Object |
lock |
protected org.slf4j.Logger |
log |
protected static int |
NUM_GHOST_SAMPLE_IDS |
protected Map<Integer,TaskStatsRequestCoordinator.PendingStatsRequest<T,V>> |
pendingRequests
In progress samples.
|
protected ArrayDeque<Integer> |
recentPendingRequestIds
A list of recent request IDs to identify late messages vs. invalid ones.
|
protected int |
requestIdCounter
Sample ID counter.
|
protected Duration |
requestTimeout
Request time out of the triggered tasks stats request.
|
Constructor and Description |
---|
TaskStatsRequestCoordinator(Executor executor,
Duration requestTimeout)
Creates a new coordinator for the cluster.
|
Modifier and Type | Method and Description |
---|---|
int |
getNumberOfPendingRequests() |
void |
handleFailedResponse(int requestId,
Throwable cause)
Handles the failed stats response by canceling the corresponding unfinished pending request.
|
void |
handleSuccessfulResponse(int requestId,
org.apache.flink.shaded.guava32.com.google.common.collect.ImmutableSet<ExecutionAttemptID> executionIds,
T result)
Handles the successfully returned tasks stats response by collecting the corresponding
subtask samples.
|
void |
shutDown()
Shuts down the coordinator.
|
protected final org.slf4j.Logger log
protected static final int NUM_GHOST_SAMPLE_IDS
protected final Object lock
protected final Executor executor
protected final Duration requestTimeout
protected final Map<Integer,TaskStatsRequestCoordinator.PendingStatsRequest<T,V>> pendingRequests
protected final ArrayDeque<Integer> recentPendingRequestIds
protected int requestIdCounter
protected boolean isShutDown
public void handleFailedResponse(int requestId, @Nullable Throwable cause)
requestId
- ID of the request to cancel.cause
- Cause of the cancelling (can be null
).public void shutDown()
After shut down, no further operations are executed.
public void handleSuccessfulResponse(int requestId, org.apache.flink.shaded.guava32.com.google.common.collect.ImmutableSet<ExecutionAttemptID> executionIds, T result)
requestId
- ID of the request.executionIds
- ID of the sampled task.result
- Result of stats request returned by an individual task.IllegalStateException
- If unknown request ID and not recently finished or cancelled
sample.@VisibleForTesting public int getNumberOfPendingRequests()
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.