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
Encapsulates the common functionality for requesting statistics from tasks and combining their
responses.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classA pending task stats request, which collects samples from individual tasks and completes the response future upon gathering all of of them. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ExecutorExecutor used to run the futures.protected booleanFlag indicating whether the coordinator is still running.protected final Objectprotected final org.slf4j.Loggerprotected static final intprotected final Map<Integer,TaskStatsRequestCoordinator.PendingStatsRequest<T, V>> In progress samples.protected final ArrayDeque<Integer>A list of recent request IDs to identify late messages vs. invalid ones.protected intSample ID counter.protected final DurationRequest time out of the triggered tasks stats request. -
Constructor Summary
ConstructorsConstructorDescriptionTaskStatsRequestCoordinator(Executor executor, Duration requestTimeout) Creates a new coordinator for the cluster. -
Method Summary
Modifier and TypeMethodDescriptionintvoidhandleFailedResponse(int requestId, Throwable cause) Handles the failed stats response by canceling the corresponding unfinished pending request.voidhandleSuccessfulResponse(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.voidshutDown()Shuts down the coordinator.
-
Field Details
-
log
protected final org.slf4j.Logger log -
NUM_GHOST_SAMPLE_IDS
protected static final int NUM_GHOST_SAMPLE_IDS- See Also:
-
lock
-
executor
Executor used to run the futures. -
requestTimeout
Request time out of the triggered tasks stats request. -
pendingRequests
In progress samples. -
recentPendingRequestIds
A list of recent request IDs to identify late messages vs. invalid ones. -
requestIdCounter
protected int requestIdCounterSample ID counter. -
isShutDown
protected boolean isShutDownFlag indicating whether the coordinator is still running.
-
-
Constructor Details
-
TaskStatsRequestCoordinator
Creates a new coordinator for the cluster.- Parameters:
executor- Used to execute the futures.requestTimeout- Request time out of the triggered tasks stats request.
-
-
Method Details
-
handleFailedResponse
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.guava32.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()
-