Class 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.
    • Field Detail

      • log

        protected final org.slf4j.Logger log
      • 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.
      • 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.
    • Constructor Detail

      • TaskStatsRequestCoordinator

        public TaskStatsRequestCoordinator​(Executor executor,
                                           Duration requestTimeout)
        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 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 be null).
      • 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()