Class TaskStatsRequestCoordinator.PendingStatsRequest<T,V>
- java.lang.Object
-
- org.apache.flink.runtime.webmonitor.stats.TaskStatsRequestCoordinator.PendingStatsRequest<T,V>
-
- Type Parameters:
T- Type of the result collected from tasks.V- Type of the result assembled and returned when all tasks where sampled.
- Enclosing class:
- TaskStatsRequestCoordinator<T,V>
@NotThreadSafe protected abstract static class TaskStatsRequestCoordinator.PendingStatsRequest<T,V> extends Object
A pending task stats request, which collects samples from individual tasks and completes the response future upon gathering all of of them.Has to be accessed in lock scope.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanisDiscardedprotected Set<Set<ExecutionAttemptID>>pendingTasksAll tasks what did not yet return a result.protected intrequestIdID of the sampling request to this coordinator.protected CompletableFuture<V>resultFutureThe future with the final result.protected longstartTimeThe time when the request is created.protected Map<org.apache.flink.shaded.guava32.com.google.common.collect.ImmutableSet<ExecutionAttemptID>,T>statsResultByTaskGroupResults returned by individual tasks and stored by the tasks'ExecutionAttemptID.
-
Constructor Summary
Constructors Modifier Constructor Description protectedPendingStatsRequest(int requestId, Collection<? extends Set<ExecutionAttemptID>> tasksToCollect)Creates newTaskStatsRequestCoordinator.PendingStatsRequest.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract VassembleCompleteStats(long endTime)A method that is called when responses from all tasks were collected successfully.protected voidcheckDiscarded()protected voidcollectTaskStats(org.apache.flink.shaded.guava32.com.google.common.collect.ImmutableSet<ExecutionAttemptID> executionId, T taskStatsResult)Collects result from one of the tasks.protected voidcompletePromiseAndDiscard()protected voiddiscard(Throwable cause)CompletableFuture<V>getStatsFuture()A Future, which will either complete successfully if all of the samples from individual tasks are collected or exceptionally, if at least one of the task responses fails.protected booleanisComplete()
-
-
-
Field Detail
-
requestId
protected final int requestId
ID of the sampling request to this coordinator.
-
startTime
protected final long startTime
The time when the request is created.
-
pendingTasks
protected final Set<Set<ExecutionAttemptID>> pendingTasks
All tasks what did not yet return a result.
-
statsResultByTaskGroup
protected final Map<org.apache.flink.shaded.guava32.com.google.common.collect.ImmutableSet<ExecutionAttemptID>,T> statsResultByTaskGroup
Results returned by individual tasks and stored by the tasks'ExecutionAttemptID.
-
resultFuture
protected final CompletableFuture<V> resultFuture
The future with the final result.
-
isDiscarded
protected boolean isDiscarded
-
-
Constructor Detail
-
PendingStatsRequest
protected PendingStatsRequest(int requestId, Collection<? extends Set<ExecutionAttemptID>> tasksToCollect)Creates newTaskStatsRequestCoordinator.PendingStatsRequest.- Parameters:
requestId- ID of the request.tasksToCollect- tasks from which the stats responses are expected.
-
-
Method Detail
-
isComplete
protected boolean isComplete()
-
discard
protected void discard(Throwable cause)
-
collectTaskStats
protected void collectTaskStats(org.apache.flink.shaded.guava32.com.google.common.collect.ImmutableSet<ExecutionAttemptID> executionId, T taskStatsResult)
Collects result from one of the tasks.- Parameters:
executionId- ID of the Task.taskStatsResult- Result of the stats sample from the Task.
-
checkDiscarded
protected void checkDiscarded()
-
completePromiseAndDiscard
protected void completePromiseAndDiscard()
-
getStatsFuture
public CompletableFuture<V> getStatsFuture()
A Future, which will either complete successfully if all of the samples from individual tasks are collected or exceptionally, if at least one of the task responses fails.- Returns:
- A future with the result of collecting tasks statistics.
-
assembleCompleteStats
protected abstract V assembleCompleteStats(long endTime)
A method that is called when responses from all tasks were collected successfully. It is responsible for assembling the final result from the individual tasks' samples. Those samples can be accessed via theMap<ExecutionAttemptID, T> statsResultByTaskvariable.- Parameters:
endTime- The time when the final sample was collected.- Returns:
- The final combined result, which will be returned as a future by the
CompletableFuture<V> getStatsFuturemethod
-
-