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 Type
    Method
    Description
    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.
    poll(long currentTimeMs)
    During normal operation of the Consumer, a request manager may need to send out network requests.
    On shutdown of the Consumer, a request manager may need to send out network requests.
    default void
    Signals the request manager that the consumer is closing to prepare for the proper actions to be taken.
  • Method Details

    • poll

      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.

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

      default 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 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.

    • 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.