Class DelayedShareFetch

java.lang.Object
org.apache.kafka.server.util.timer.TimerTask
org.apache.kafka.server.purgatory.DelayedOperation
kafka.server.share.DelayedShareFetch
All Implemented Interfaces:
Runnable

public class DelayedShareFetch extends org.apache.kafka.server.purgatory.DelayedOperation
A delayed share fetch operation has been introduced in case there is a share fetch request which cannot be completed instantaneously.
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.apache.kafka.server.purgatory.DelayedOperation

    org.apache.kafka.server.purgatory.DelayedOperation.Action
  • Field Summary

    Fields inherited from class org.apache.kafka.server.util.timer.TimerTask

    delayMs
  • Constructor Summary

    Constructors
    Constructor
    Description
    DelayedShareFetch(org.apache.kafka.server.share.fetch.ShareFetch shareFetch, kafka.server.ReplicaManager replicaManager, BiConsumer<org.apache.kafka.server.share.SharePartitionKey,Throwable> exceptionHandler, LinkedHashMap<org.apache.kafka.common.TopicIdPartition,SharePartition> sharePartitions, org.apache.kafka.server.share.metrics.ShareGroupMetrics shareGroupMetrics, org.apache.kafka.common.utils.Time time, long remoteFetchMaxWaitMs)
    This function constructs an instance of delayed share fetch operation for completing share fetch requests instantaneously or with delay.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Complete the share fetch operation by fetching records for all partitions in the share fetch request irrespective of whether they have any acquired records.
    void
     
    boolean
    Try to complete the fetch operation if we can acquire records for any partition in the share fetch request.

    Methods inherited from class org.apache.kafka.server.purgatory.DelayedOperation

    forceComplete, isCompleted, run

    Methods inherited from class org.apache.kafka.server.util.timer.TimerTask

    cancel, isCancelled

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DelayedShareFetch

      public DelayedShareFetch(org.apache.kafka.server.share.fetch.ShareFetch shareFetch, kafka.server.ReplicaManager replicaManager, BiConsumer<org.apache.kafka.server.share.SharePartitionKey,Throwable> exceptionHandler, LinkedHashMap<org.apache.kafka.common.TopicIdPartition,SharePartition> sharePartitions, org.apache.kafka.server.share.metrics.ShareGroupMetrics shareGroupMetrics, org.apache.kafka.common.utils.Time time, long remoteFetchMaxWaitMs)
      This function constructs an instance of delayed share fetch operation for completing share fetch requests instantaneously or with delay.
      Parameters:
      shareFetch - The share fetch parameters of the share fetch request.
      replicaManager - The replica manager instance used to read from log/complete the request.
      exceptionHandler - The handler to complete share fetch requests with exception.
      sharePartitions - The share partitions referenced in the share fetch request.
      shareGroupMetrics - The share group metrics to record the metrics.
      time - The system time.
      remoteFetchMaxWaitMs - The max wait time for a share fetch request having remote storage fetch.
  • Method Details

    • onExpiration

      public void onExpiration()
      Specified by:
      onExpiration in class org.apache.kafka.server.purgatory.DelayedOperation
    • onComplete

      public void onComplete()
      Complete the share fetch operation by fetching records for all partitions in the share fetch request irrespective of whether they have any acquired records. This is called when the fetch operation is forced to complete either because records can be acquired for some partitions or due to MaxWaitMs timeout.

      On operation timeout, onComplete is invoked, last try occurs to acquire partitions and read from log, if acquired. The fetch will only happen from local log and not remote storage, on operation expiration.

      Specified by:
      onComplete in class org.apache.kafka.server.purgatory.DelayedOperation
    • tryComplete

      public boolean tryComplete()
      Try to complete the fetch operation if we can acquire records for any partition in the share fetch request.
      Specified by:
      tryComplete in class org.apache.kafka.server.purgatory.DelayedOperation