Fetcher
KafkaConsumer
uses the following configuration properties to create a Fetcher:
Name | Description |
---|---|
ConsumerNetworkClient that is given when |
Creating Fetcher Instance
Fetcher
takes the following when created:
-
Deserializer for keys
-
Deserializer for values
Fetcher
initializes the internal registries and counters.
Fetcher
registers itself with SubscriptionState as a listener to receive notifications about…FIXME
sendFetches
Method
int sendFetches()
sendFetches
…FIXME
Note
|
sendFetches is used when KafkaConsumer is requested to poll for records.
|
sendMetadataRequest
Internal Method
RequestFuture<ClientResponse> sendMetadataRequest(MetadataRequest.Builder request)
Internally, sendMetadataRequest
requests ConsumerNetworkClient for the least loaded node.
With the node, sendMetadataRequest
requests ConsumerNetworkClient to send the request to the node.
When no node was found, sendMetadataRequest
returns a RequestFuture
with NoAvailableBrokersException
.
Note
|
sendMetadataRequest is used exclusively when Fetcher is requested for a topic metadata.
|
Getting Topic Metadata — getTopicMetadata
Method
Map<String, List<PartitionInfo>> getTopicMetadata(
MetadataRequest.Builder request,
long timeout)
Internally, getTopicMetadata
sends the metadata request and requests ConsumerNetworkClient to poll until it finishes successfully or timeout
expires.
After poll
finishes, getTopicMetadata
takes the cluster information from MetadataResponse
.
When MetadataResponse
is successful, getTopicMetadata
takes topics (from Cluster
) and requests Cluster
for available partitions for every topic.
In the end, getTopicMetadata
creates a collection of topic and partitions pairs.
Caution
|
FIXME Describe the failure path |
Note
|
|
Finding Metadata for All Topics — getAllTopicMetadata
Method
Map<String, List<PartitionInfo>> getAllTopicMetadata(long timeout)
getAllTopicMetadata
gets topic metadata specifying no topics (which means all topics available).
Note
|
getAllTopicMetadata is used exclusively when KafkaConsumer requests metadata for all topics.
|