Class TopicMetadataRequestManager
java.lang.Object
org.apache.kafka.clients.consumer.internals.TopicMetadataRequestManager
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionTopicMetadataRequestManager(org.apache.kafka.common.utils.LogContext context, ConsumerConfig config) -
Method Summary
Modifier and TypeMethodDescriptionpoll(long currentTimeMs) During normal operation of theConsumer, a request manager may need to send out network requests.CompletableFuture<Map<String, List<org.apache.kafka.common.PartitionInfo>>> requestAllTopicsMetadata(long expirationTimeMs) Return the future of the metadata request.CompletableFuture<Map<String, List<org.apache.kafka.common.PartitionInfo>>> requestTopicMetadata(String topic, long expirationTimeMs) Return the future of the metadata 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
-
TopicMetadataRequestManager
public TopicMetadataRequestManager(org.apache.kafka.common.utils.LogContext context, ConsumerConfig config)
-
-
Method Details
-
poll
Description copied from interface:RequestManagerDuring 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.- Specified by:
pollin interfaceRequestManager- 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.
-