Interface RequestManager
- All Known Implementing Classes:
CommitRequestManager,CoordinatorRequestManager,FetchRequestManager,HeartbeatRequestManager,OffsetsRequestManager,TopicMetadataRequestManager
public interface RequestManager
PollResult consist of UnsentRequest if there are requests to send; otherwise, return the time till
the next poll event.-
Method Summary
Modifier and TypeMethodDescriptiondefault longmaximumTimeToWait(long currentTimeMs) Returns the delay for which the application thread can safely wait before it should be responsive to results from the request managers.poll(long currentTimeMs) During normal operation of theConsumer, a request manager may need to send out network requests.default NetworkClientDelegate.PollResultOn shutdown of theConsumer, a request manager may need to send out network requests.default voidSignals the request manager that the consumer is closing to prepare for the proper actions to be taken.
-
Method Details
-
poll
During normal operation of theConsumer, a request manager may need to send out network requests. Implementations can returntheir need for network I/Oby returning the requests here. This method is called within a single-threaded context fromthe 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.- Parameters:
currentTimeMs- The current system time at which the method was called; useful for determining if time-sensitive operations should be performed
-
pollOnClose
On shutdown of theConsumer, a request manager may need to send out network requests. Implementations can signal that by returning thecloserequests here. Likepoll(long), this method is called within a single-threaded context fromthe 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 ofthe consumer's close methodbeing 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. -
maximumTimeToWait
default long maximumTimeToWait(long currentTimeMs) Returns the delay for which the application thread can safely wait before it should be responsive to results from the request managers. For example, the subscription state can change when heartbeats are sent, so blocking for longer than the heartbeat interval might mean the application thread is not responsive to changes.- Parameters:
currentTimeMs- The current system time at which the method was called; useful for determining if time-sensitive operations should be performed- Returns:
- The maximum delay in milliseconds
-
signalClose
default void signalClose()Signals the request manager that the consumer is closing to prepare for the proper actions to be taken.
-