use of org.apache.kafka.common.message.OffsetForLeaderEpochRequestData.OffsetForLeaderTopic in project kafka by apache.
the class OffsetsForLeaderEpochClient method prepareRequest.
@Override
protected AbstractRequest.Builder<OffsetsForLeaderEpochRequest> prepareRequest(Node node, Map<TopicPartition, SubscriptionState.FetchPosition> requestData) {
OffsetForLeaderTopicCollection topics = new OffsetForLeaderTopicCollection(requestData.size());
requestData.forEach((topicPartition, fetchPosition) -> fetchPosition.offsetEpoch.ifPresent(fetchEpoch -> {
OffsetForLeaderTopic topic = topics.find(topicPartition.topic());
if (topic == null) {
topic = new OffsetForLeaderTopic().setTopic(topicPartition.topic());
topics.add(topic);
}
topic.partitions().add(new OffsetForLeaderPartition().setPartition(topicPartition.partition()).setLeaderEpoch(fetchEpoch).setCurrentLeaderEpoch(fetchPosition.currentLeader.epoch.orElse(RecordBatch.NO_PARTITION_LEADER_EPOCH)));
}));
return OffsetsForLeaderEpochRequest.Builder.forConsumer(topics);
}
use of org.apache.kafka.common.message.OffsetForLeaderEpochRequestData.OffsetForLeaderTopic in project kafka by apache.
the class RequestResponseTest method createOffsetForLeaderTopicCollection.
private OffsetForLeaderTopicCollection createOffsetForLeaderTopicCollection() {
OffsetForLeaderTopicCollection topics = new OffsetForLeaderTopicCollection();
topics.add(new OffsetForLeaderTopic().setTopic("topic1").setPartitions(asList(new OffsetForLeaderPartition().setPartition(0).setLeaderEpoch(1).setCurrentLeaderEpoch(0), new OffsetForLeaderPartition().setPartition(1).setLeaderEpoch(1).setCurrentLeaderEpoch(0))));
topics.add(new OffsetForLeaderTopic().setTopic("topic2").setPartitions(singletonList(new OffsetForLeaderPartition().setPartition(2).setLeaderEpoch(3).setCurrentLeaderEpoch(RecordBatch.NO_PARTITION_LEADER_EPOCH))));
return topics;
}
Aggregations