Class TaskStatsRequestCoordinator<T,V>
- java.lang.Object
-
- org.apache.flink.runtime.webmonitor.stats.TaskStatsRequestCoordinator<T,V>
-
- Type Parameters:
T- Type of the statistics to be gathered.V- Type of the combined response.
- Direct Known Subclasses:
ThreadInfoRequestCoordinator
public class TaskStatsRequestCoordinator<T,V> extends Object
Encapsulates the common functionality for requesting statistics from tasks and combining their responses.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classTaskStatsRequestCoordinator.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.
-
Field Summary
Fields Modifier and Type Field Description protected ExecutorexecutorExecutor used to run the futures.protected booleanisShutDownFlag indicating whether the coordinator is still running.protected Objectlockprotected org.slf4j.Loggerlogprotected static intNUM_GHOST_SAMPLE_IDSprotected Map<Integer,TaskStatsRequestCoordinator.PendingStatsRequest<T,V>>pendingRequestsIn progress samples.protected ArrayDeque<Integer>recentPendingRequestIdsA list of recent request IDs to identify late messages vs. invalid ones.protected intrequestIdCounterSample ID counter.protected DurationrequestTimeoutRequest time out of the triggered tasks stats request.
-
Constructor Summary
Constructors Constructor Description TaskStatsRequestCoordinator(Executor executor, Duration requestTimeout)Creates a new coordinator for the cluster.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetNumberOfPendingRequests()voidhandleFailedResponse(int requestId, Throwable cause)Handles the failed stats response by canceling the corresponding unfinished pending request.voidhandleSuccessfulResponse(int requestId, org.apache.flink.shaded.guava33.com.google.common.collect.ImmutableSet<ExecutionAttemptID> executionIds, T result)Handles the successfully returned tasks stats response by collecting the corresponding subtask samples.voidshutDown()Shuts down the coordinator.
-
-
-
Field Detail
-
log
protected final org.slf4j.Logger log
-
NUM_GHOST_SAMPLE_IDS
protected static final int NUM_GHOST_SAMPLE_IDS
- See Also:
- Constant Field Values
-
lock
protected final Object lock
-
executor
protected final Executor executor
Executor used to run the futures.
-
requestTimeout
protected final Duration requestTimeout
Request time out of the triggered tasks stats request.
-
pendingRequests
protected final Map<Integer,TaskStatsRequestCoordinator.PendingStatsRequest<T,V>> pendingRequests
In progress samples.
-
recentPendingRequestIds
protected final ArrayDeque<Integer> recentPendingRequestIds
A list of recent request IDs to identify late messages vs. invalid ones.
-
requestIdCounter
protected int requestIdCounter
Sample ID counter.
-
isShutDown
protected boolean isShutDown
Flag indicating whether the coordinator is still running.
-
-
Method Detail
-
handleFailedResponse
public void handleFailedResponse(int requestId, @Nullable Throwable cause)Handles the failed stats response by canceling the corresponding unfinished pending request.- Parameters:
requestId- ID of the request to cancel.cause- Cause of the cancelling (can benull).
-
shutDown
public void shutDown()
Shuts down the coordinator.After shut down, no further operations are executed.
-
handleSuccessfulResponse
public void handleSuccessfulResponse(int requestId, org.apache.flink.shaded.guava33.com.google.common.collect.ImmutableSet<ExecutionAttemptID> executionIds, T result)Handles the successfully returned tasks stats response by collecting the corresponding subtask samples.- Parameters:
requestId- ID of the request.executionIds- ID of the sampled task.result- Result of stats request returned by an individual task.- Throws:
IllegalStateException- If unknown request ID and not recently finished or cancelled sample.
-
getNumberOfPendingRequests
@VisibleForTesting public int getNumberOfPendingRequests()
-
-