Java Code Examples for kafka.common.TopicAndPartition#partition()
The following examples show how to use
kafka.common.TopicAndPartition#partition() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KafkaPartitionLevelConsumerTest.java From incubator-pinot with Apache License 2.0 | 5 votes |
@Override public FetchResponse fetch(FetchRequest request) { scala.collection.Traversable<Tuple2<TopicAndPartition, PartitionFetchInfo>> requestInfo = request.requestInfo(); java.util.Map<TopicAndPartition, Short> errorMap = new HashMap<>(); while (requestInfo.headOption().isDefined()) { // jfim: IntelliJ erroneously thinks the following line is an incompatible type error, but it's only because // it doesn't understand scala covariance when called from Java (ie. it thinks head() is of type A even though // it's really of type Tuple2[TopicAndPartition, PartitionFetchInfo]) Tuple2<TopicAndPartition, PartitionFetchInfo> t2 = requestInfo.head(); TopicAndPartition topicAndPartition = t2._1(); PartitionFetchInfo partitionFetchInfo = t2._2(); if (!topicAndPartition.topic().equals(topicName)) { errorMap.put(topicAndPartition, Errors.UNKNOWN_TOPIC_OR_PARTITION.code()); } else if (partitionLeaderIndices.length < topicAndPartition.partition()) { errorMap.put(topicAndPartition, Errors.UNKNOWN_TOPIC_OR_PARTITION.code()); } else if (partitionLeaderIndices[topicAndPartition.partition()] != index) { errorMap.put(topicAndPartition, Errors.NOT_LEADER_FOR_PARTITION.code()); } else { // Do nothing, we'll generate a fake message } requestInfo = requestInfo.tail(); } return new MockFetchResponse(errorMap); }
Example 2
Source File: OffsetMonitor.java From uReplicator with Apache License 2.0 | 4 votes |
private static String getOffsetLagName(TopicAndPartition tp) { return "OffsetMonitorLag." + tp.topic().replace('.', '_') + "." + tp.partition(); }
Example 3
Source File: PulsarKafkaSimpleConsumer.java From pulsar with Apache License 2.0 | 4 votes |
public static String getTopicName(TopicAndPartition topicMetadata) { return topicMetadata.partition() > -1 ? TopicName.get(topicMetadata.topic()).getPartition(topicMetadata.partition()).toString() : topicMetadata.topic(); }