本文整理了Java中org.apache.kafka.clients.consumer.Consumer.listTopics()
方法的一些代码示例,展示了Consumer.listTopics()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Consumer.listTopics()
方法的具体详情如下:
包路径:org.apache.kafka.clients.consumer.Consumer
类名称:Consumer
方法名:listTopics
暂无
代码示例来源:origin: openzipkin/brave
@Override public Map<String, List<PartitionInfo>> listTopics() {
return delegate.listTopics();
}
代码示例来源:origin: openzipkin/brave
@Override public Map<String, List<PartitionInfo>> listTopics(Duration timeout) {
return delegate.listTopics(timeout);
}
代码示例来源:origin: apache/incubator-gobblin
@Override
public List<KafkaTopic> getTopics() {
return FluentIterable.from(this.consumer.listTopics().entrySet())
.transform(new Function<Entry<String, List<PartitionInfo>>, KafkaTopic>() {
@Override
public KafkaTopic apply(Entry<String, List<PartitionInfo>> filteredTopicEntry) {
return new KafkaTopic(filteredTopicEntry.getKey(), Lists.transform(filteredTopicEntry.getValue(),
PARTITION_INFO_TO_KAFKA_PARTITION));
}
}).toList();
}
代码示例来源:origin: apache/storm
@Override
public Set<TopicPartition> getAllSubscribedPartitions(Consumer<?, ?> consumer) {
topics.clear();
Set<TopicPartition> allPartitions = new HashSet<>();
for (Map.Entry<String, List<PartitionInfo>> entry : consumer.listTopics().entrySet()) {
if (pattern.matcher(entry.getKey()).matches()) {
for (PartitionInfo partitionInfo : entry.getValue()) {
allPartitions.add(new TopicPartition(partitionInfo.topic(), partitionInfo.partition()));
topics.add(partitionInfo.topic());
}
}
}
return allPartitions;
}
代码示例来源:origin: linkedin/cruise-control
for (String topic : _metricConsumer.listTopics().keySet()) {
if (topicPattern.matcher(topic).matches()) {
return;
代码示例来源:origin: apache/metron
@Override
public Set<String> listTopics() {
try (Consumer<String, String> consumer = kafkaConsumerFactory.createConsumer()) {
final Map<String, List<PartitionInfo>> topicsInfo = consumer.listTopics();
final Set<String> topics = topicsInfo == null ? new HashSet<>() : topicsInfo.keySet();
topics.remove(CONSUMER_OFFSETS_TOPIC);
return topics;
}
}
代码示例来源:origin: io.opentracing.contrib/opentracing-kafka-client
@Override
public Map<String, List<PartitionInfo>> listTopics(Duration duration) {
return consumer.listTopics(duration);
}
代码示例来源:origin: linkedin/li-apache-kafka-clients
@Override
public Map<String, List<PartitionInfo>> listTopics() {
return _kafkaConsumer.listTopics();
}
代码示例来源:origin: io.opentracing.contrib/opentracing-kafka-client
@Override
public Map<String, List<PartitionInfo>> listTopics() {
return consumer.listTopics();
}
代码示例来源:origin: rayokota/kafka-graphs
@Override
public Map<String, List<PartitionInfo>> listTopics(Duration timeout) {
return kafkaConsumer.listTopics(timeout);
}
代码示例来源:origin: opentracing-contrib/java-kafka-client
@Override
public Map<String, List<PartitionInfo>> listTopics() {
return consumer.listTopics();
}
代码示例来源:origin: linkedin/li-apache-kafka-clients
@Override
public Map<String, List<PartitionInfo>> listTopics(Duration timeout) {
return _kafkaConsumer.listTopics(timeout);
}
代码示例来源:origin: rayokota/kafka-graphs
@Override
public Map<String, List<PartitionInfo>> listTopics() {
return kafkaConsumer.listTopics();
}
代码示例来源:origin: opentracing-contrib/java-kafka-client
@Override
public Map<String, List<PartitionInfo>> listTopics(Duration duration) {
return consumer.listTopics(duration);
}
代码示例来源:origin: io.zipkin.brave/brave-instrumentation-kafka-clients
@Override public Map<String, List<PartitionInfo>> listTopics() {
return delegate.listTopics();
}
代码示例来源:origin: org.apache.kafka/kafka-streams
private void refreshChangelogInfo() {
try {
partitionInfo.putAll(restoreConsumer.listTopics());
} catch (final TimeoutException e) {
log.debug("Could not fetch topic metadata within the timeout, will retry in the next run loop");
}
}
代码示例来源:origin: apache/samza
@Override
public Set<SystemStream> getAllSystemStreams() {
return ((Set<String>) this.metadataConsumer.listTopics().keySet()).stream()
.map(x -> new SystemStream(systemName, x))
.collect(Collectors.toSet());
}
代码示例来源:origin: vert-x3/vertx-kafka-client
@Override
public KafkaReadStream<K, V> listTopics(Handler<AsyncResult<Map<String,List<PartitionInfo>>>> handler) {
this.submitTask((consumer, future) -> {
Map<String, List<PartitionInfo>> topics = consumer.listTopics();
if (future != null) {
future.complete(topics);
}
}, handler);
return this;
}
代码示例来源:origin: salesforce/mirus
private List<TopicPartition> fetchMatchingPartitions(Consumer<byte[], byte[]> consumer) {
return consumer
.listTopics()
.entrySet()
.stream()
.filter(
e ->
topicsWhitelist.contains(e.getKey())
|| topicsRegexPattern.matcher(e.getKey()).matches())
.flatMap(e -> e.getValue().stream())
.map(partitionInfo -> new TopicPartition(partitionInfo.topic(), partitionInfo.partition()))
.collect(Collectors.toList());
}
代码示例来源:origin: salesforce/mirus
private Set<TopicPartition> destinationPartitionIds() {
synchronized (destinationConsumer) {
return destinationConsumer
.listTopics()
.values()
.stream()
.flatMap(Collection::stream)
.map(
partitionInfo ->
keyStrategy.topicPartitionKey(partitionInfo.topic(), partitionInfo.partition()))
.collect(Collectors.toSet());
}
}
内容来源于网络,如有侵权,请联系作者删除!