Class TopicMetadataRequestManager

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

public class TopicMetadataRequestManager extends Object implements RequestManager

Manages the state of topic metadata requests. This manager returns a NetworkClientDelegate.PollResult when a request is ready to be sent. Specifically, this manager handles the following user API calls:

  • listTopics
  • partitionsFor

The manager checks the state of the TopicMetadataRequestManager.TopicMetadataRequestState before sending a new one to prevent sending it without backing off from previous attempts. Once a request is completed successfully or times out, its corresponding entry is removed.

  • Constructor Details

    • TopicMetadataRequestManager

      public TopicMetadataRequestManager(org.apache.kafka.common.utils.LogContext context, ConsumerConfig config)
  • Method Details

    • poll

      public NetworkClientDelegate.PollResult poll(long currentTimeMs)
      Description copied from interface: RequestManager
      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
    • requestAllTopicsMetadata

      public CompletableFuture<Map<String,List<org.apache.kafka.common.PartitionInfo>>> requestAllTopicsMetadata(long expirationTimeMs)
      Return the future of the metadata request.
      Returns:
      the future of the metadata request.
    • requestTopicMetadata

      public CompletableFuture<Map<String,List<org.apache.kafka.common.PartitionInfo>>> requestTopicMetadata(String topic, long expirationTimeMs)
      Return the future of the metadata request.
      Parameters:
      topic - to be requested.
      Returns:
      the future of the metadata request.