本文整理了Java中kafka.admin.AdminClient.close()
方法的一些代码示例,展示了AdminClient.close()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AdminClient.close()
方法的具体详情如下:
包路径:kafka.admin.AdminClient
类名称:AdminClient
方法名:close
暂无
代码示例来源:origin: org.apache.kafka/kafka_2.10
} finally {
if (adminClient != null) {
adminClient.close();
代码示例来源:origin: vakinge/jeesuite-libs
public void close() {
adminClient.close();
if (kafkaConsumers != null){
for (KafkaConsumer<String, Serializable> kafkaConsumer : kafkaConsumers.values()) {
kafkaConsumer.close();
}
}
}
代码示例来源:origin: org.apache.samza/samza-kafka
@Override
public void stop() {
if (stopped.compareAndSet(false, true)) {
try {
metadataConsumer.close();
} catch (Exception e) {
LOG.warn("metadataConsumer.close for system " + systemName + " failed with exception.", e);
}
}
if (adminClient != null) {
try {
adminClient.close();
} catch (Exception e) {
LOG.warn("adminClient.close for system " + systemName + " failed with exception.", e);
}
}
}
代码示例来源:origin: org.apache.samza/samza-kafka_2.11
@Override
public void stop() {
if (stopped.compareAndSet(false, true)) {
try {
metadataConsumer.close();
} catch (Exception e) {
LOG.warn("metadataConsumer.close for system " + systemName + " failed with exception.", e);
}
}
if (adminClient != null) {
try {
adminClient.close();
} catch (Exception e) {
LOG.warn("adminClient.close for system " + systemName + " failed with exception.", e);
}
}
}
代码示例来源:origin: gnuhpc/Kafka-zk-restapi
private Set<String> listAllNewConsumerGroups() {
AdminClient adminClient = kafkaUtils.createAdminClient();
log.info("Calling the listAllConsumerGroupsFlattened");
Set activeGroups =
CollectionConvertor.seqConvertJavaList(adminClient.listAllConsumerGroupsFlattened())
.stream()
.map(GroupOverview::groupId)
.collect(toSet());
log.info("Checking the groups in storage");
Set usedTobeGroups =
storage.getMap().entrySet().stream().map(Map.Entry::getKey).collect(toSet());
activeGroups.addAll(usedTobeGroups);
log.info("Finish getting new consumers");
adminClient.close();
return activeGroups;
}
代码示例来源:origin: apache/samza
@Override
public void stop() {
if (stopped.compareAndSet(false, true)) {
try {
metadataConsumer.close();
} catch (Exception e) {
LOG.warn("metadataConsumer.close for system " + systemName + " failed with exception.", e);
}
}
if (adminClientForDelete != null) {
try {
adminClientForDelete.close();
} catch (Exception e) {
LOG.warn("AdminClient.close() for system {} failed with exception {}.", systemName, e);
}
}
if (adminClient != null) {
adminClient.close();
}
}
代码示例来源:origin: com.cerner.common.kafka/common-kafka-admin
@Override
public void close() {
zkUtils.close();
if (authorizer != null)
authorizer.close();
if (adminClient != null)
adminClient.close();
}
代码示例来源:origin: gnuhpc/Kafka-zk-restapi
private Set<String> listNewConsumerGroupsByTopic(@TopicExistConstraint String topic) {
Set<String> result = new HashSet();
Set<String> consumersList = listAllNewConsumerGroups();
for (String c : consumersList) {
AdminClient adminClient = kafkaUtils.createAdminClient();
List<AdminClient.ConsumerSummary> consumerSummaryList =
CollectionConvertor.listConvertJavaList(adminClient.describeConsumerGroup(c));
Set<String> topicSet =
consumerSummaryList
.stream()
.flatMap(cs -> CollectionConvertor.listConvertJavaList(cs.assignment()).stream())
.map(TopicPartition::topic)
.filter(t -> t.equals(topic))
.distinct()
.collect(toSet());
if (topicSet.size() != 0) {
result.add(c);
}
adminClient.close();
}
return result;
}
代码示例来源:origin: gnuhpc/Kafka-zk-restapi
private boolean isConsumerGroupActive(String consumerGroup, ConsumerType type) {
if (type == ConsumerType.NEW) {
AdminClient adminClient = kafkaUtils.createAdminClient();
boolean isActive =
CollectionConvertor.seqConvertJavaList(adminClient.listAllConsumerGroupsFlattened())
.stream()
.map(GroupOverview::groupId)
.filter(c -> c.equals(consumerGroup))
.count()
== 1;
adminClient.close();
return isActive;
} else if (type == ConsumerType.OLD) {
return AdminUtils.isConsumerGroupActive(zookeeperUtils.getZkUtils(), consumerGroup);
} else {
throw new ApiException("Unknown type " + type);
}
}
代码示例来源:origin: gnuhpc/Kafka-zk-restapi
CollectionConvertor.listConvertJavaList(adminClient.describeConsumerGroup(consumerGroup));
adminClient.close();
代码示例来源:origin: gnuhpc/Kafka-zk-restapi
CollectionConvertor.listConvertJavaList(adminClient.describeConsumerGroup(consumerGroup));
adminClient.close();
内容来源于网络,如有侵权,请联系作者删除!