Class FetchRequestManager

java.lang.Object
org.apache.kafka.clients.consumer.internals.AbstractFetch
org.apache.kafka.clients.consumer.internals.FetchRequestManager
All Implemented Interfaces:
Closeable, AutoCloseable, RequestManager

public class FetchRequestManager extends AbstractFetch implements RequestManager
FetchRequestManager is responsible for generating FetchRequest that represent the SubscriptionState.fetchablePartitions(Predicate) based on the user's topic subscription/partition assignment.
  • Method Details

    • isUnavailable

      protected boolean isUnavailable(org.apache.kafka.common.Node node)
      Description copied from class: AbstractFetch
      Check if the node is disconnected and unavailable for immediate reconnection (i.e. if it is in reconnect backoff window following the disconnect).
      Specified by:
      isUnavailable in class AbstractFetch
      Parameters:
      node - Node to check for availability
      See Also:
      • NetworkClientUtils.isUnavailable(KafkaClient, Node, Time)
    • maybeThrowAuthFailure

      protected void maybeThrowAuthFailure(org.apache.kafka.common.Node node)
      Description copied from class: AbstractFetch
      Checks for an authentication error on a given node and throws the exception if it exists.
      Specified by:
      maybeThrowAuthFailure in class AbstractFetch
      Parameters:
      node - Node to check for a previous AuthenticationException; if found it is thrown
      See Also:
      • NetworkClientUtils.maybeThrowAuthFailure(KafkaClient, Node)
    • poll

      public NetworkClientDelegate.PollResult poll(long currentTimeMs)
      During normal operation of the Consumer, a request manager may need to send out network requests. Implementations can return their need for network I/O by returning the requests here. This method is called within a single-threaded context from the consumer's network I/O thread. As such, there should be no need for synchronization protection in this method's implementation.

      Note: no network I/O occurs in this method. The method itself should not block for any reason. This method is called from the consumer's network I/O thread, so quick execution of this method in all request managers is critical to ensure that we can heartbeat in a timely fashion.

      Specified by:
      poll in interface RequestManager
      Parameters:
      currentTimeMs - The current system time at which the method was called; useful for determining if time-sensitive operations should be performed
    • pollOnClose

      public NetworkClientDelegate.PollResult pollOnClose()
      On shutdown of the Consumer, a request manager may need to send out network requests. Implementations can signal that by returning the close requests here. Like RequestManager.poll(long), this method is called within a single-threaded context from the consumer's network I/O thread. As such, there should be no need for synchronization protection in this method's implementation.

      Note: no network I/O occurs in this method. The method itself should not block for any reason. This method is called as an (indirect) result of the consumer's close method being invoked. (Note that it is still invoked on the consumer's network I/O thread). Quick execution of this method in all request managers is critical to ensure that we can complete as many of the consumer's shutdown tasks as possible within the user-provided timeout.

      Specified by:
      pollOnClose in interface RequestManager