Class CoordinatorRequestManager

java.lang.Object
org.apache.kafka.clients.consumer.internals.CoordinatorRequestManager
All Implemented Interfaces:
RequestManager

public class CoordinatorRequestManager extends Object implements RequestManager
This is responsible for timing to send the next FindCoordinatorRequest based on the following criteria:

Whether there is an existing coordinator. Whether there is an inflight request. Whether the backoff timer has expired. The NetworkClientDelegate.PollResult contains either a wait timer or a singleton list of NetworkClientDelegate.UnsentRequest.

The FindCoordinatorRequest will be handled by the onResponse(long, FindCoordinatorResponse) callback, which subsequently invokes onResponse to handle the exception and response. Note that the coordinator node will be marked null upon receiving a failure.

  • Constructor Details

    • CoordinatorRequestManager

      public CoordinatorRequestManager(org.apache.kafka.common.utils.Time time, org.apache.kafka.common.utils.LogContext logContext, long retryBackoffMs, long retryBackoffMaxMs, BackgroundEventHandler errorHandler, String groupId)
  • Method Details

    • poll

      public NetworkClientDelegate.PollResult poll(long currentTimeMs)
      Poll for the FindCoordinator request. If we don't need to discover a coordinator, this method will return a PollResult with Long.MAX_VALUE backoff time and an empty list. If we are still backing off from a previous attempt, this method will return a PollResult with the remaining backoff time and an empty list. Otherwise, this returns will return a PollResult with a singleton list of UnsentRequest and Long.MAX_VALUE backoff time. Note that this method does not involve any actual network IO, and it only determines if we need to send a new request or not.
      Specified by:
      poll in interface RequestManager
      Parameters:
      currentTimeMs - current time in ms.
      Returns:
      NetworkClientDelegate.PollResult. This will not be null.
    • markCoordinatorUnknown

      public void markCoordinatorUnknown(String cause, long currentTimeMs)
      Mark the current coordinator null.
      Parameters:
      cause - why the coordinator is marked unknown.
      currentTimeMs - the current time in ms.
    • coordinator

      public Optional<org.apache.kafka.common.Node> coordinator()
      Returns the current coordinator node.
      Returns:
      the current coordinator node.