Class CoordinatorRequestManager
java.lang.Object
org.apache.kafka.clients.consumer.internals.CoordinatorRequestManager
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionCoordinatorRequestManager(org.apache.kafka.common.utils.Time time, org.apache.kafka.common.utils.LogContext logContext, long retryBackoffMs, long retryBackoffMaxMs, BackgroundEventHandler errorHandler, String groupId) -
Method Summary
Modifier and TypeMethodDescriptionOptional<org.apache.kafka.common.Node> Returns the current coordinator node.voidmarkCoordinatorUnknown(String cause, long currentTimeMs) Mark the current coordinator null.poll(long currentTimeMs) Poll for the FindCoordinator request.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.kafka.clients.consumer.internals.RequestManager
maximumTimeToWait, pollOnClose, signalClose
-
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
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:
pollin interfaceRequestManager- Parameters:
currentTimeMs- current time in ms.- Returns:
NetworkClientDelegate.PollResult. This will not benull.
-
markCoordinatorUnknown
Mark the current coordinator null.- Parameters:
cause- why the coordinator is marked unknown.currentTimeMs- the current time in ms.
-
coordinator
Returns the current coordinator node.- Returns:
- the current coordinator node.
-