本文整理了Java中kafka.utils.ZkUtils.BrokerIdsPath()
方法的一些代码示例,展示了ZkUtils.BrokerIdsPath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkUtils.BrokerIdsPath()
方法的具体详情如下:
包路径:kafka.utils.ZkUtils
类名称:ZkUtils
方法名:BrokerIdsPath
暂无
代码示例来源:origin: linkedin/cruise-control
void startDetection() {
try {
_zkClient.createPersistent(_failedBrokersZkPath);
} catch (ZkNodeExistsException znee) {
// let it go.
}
// Load the failed broker information from zookeeper.
loadPersistedFailedBrokerList();
// Detect broker failures.
detectBrokerFailures();
_zkClient.subscribeChildChanges(ZkUtils.BrokerIdsPath(), new BrokerFailureListener());
}
代码示例来源:origin: HomeAdvisor/Kafdrop
private int brokerId(ChildData input)
{
return Integer.parseInt(StringUtils.substringAfter(input.getPath(), ZkUtils.BrokerIdsPath() + "/"));
}
代码示例来源:origin: HomeAdvisor/Kafdrop
private int brokerId(ChildData input)
{
return Integer.parseInt(StringUtils.substringAfter(input.getPath(), ZkUtils.BrokerIdsPath() + "/"));
}
代码示例来源:origin: com.hurence.logisland/logisland-agent
private SimpleConsumer getZkConsumer(int brokerId) {
try {
Option<String> data = zkUtils.readDataMaybeNull(ZkUtils.BrokerIdsPath() + "/" + brokerId)._1;
Map<String, Object> brokerInfo = (Map<String, Object>) JSON.parseFull(data.get()).get();
String host = (String) brokerInfo.get("host");
int port = (int) brokerInfo.get("port");
return new SimpleConsumer(host, port, 10000, 100000, "ConsumerGroupCommand");
} catch (Exception ex) {
System.out.println("Could not parse broker info due to " + ex.getMessage());
return null;
}
}
代码示例来源:origin: gnuhpc/Kafka-zk-restapi
public List<BrokerInfo> listBrokers() {
List<Broker> brokerList =
CollectionConvertor.seqConvertJavaList(zkUtils.getAllBrokersInCluster());
return brokerList
.parallelStream()
.collect(Collectors.toMap(Broker::id, Broker::rack))
.entrySet()
.parallelStream()
.map(
entry -> {
String brokerInfoStr = null;
try {
brokerInfoStr =
new String(
zkClient.getData().forPath(ZkUtils.BrokerIdsPath() + "/" + entry.getKey()));
} catch (Exception e) {
e.printStackTrace();
}
BrokerInfo brokerInfo = gson.fromJson(brokerInfoStr, BrokerInfo.class);
if (entry.getValue().isEmpty()) brokerInfo.setRack("");
else {
brokerInfo.setRack(entry.getValue().get());
}
brokerInfo.setId(entry.getKey());
return brokerInfo;
})
.collect(toList());
}
代码示例来源:origin: shunfei/DCMonitor
private SimpleConsumer createSimpleConsumer(Integer brokerId) {
try {
String brokerInfo = zkClient.readData(ZkUtils.BrokerIdsPath() + "/" + brokerId, true);
if (brokerInfo == null) {
log.error("Broker clientId %d does not exist", brokerId);
return null;
}
Map<String, Object> map = Resources.jsonMapper.readValue(
brokerInfo, new TypeReference<Map<String, Object>>() {
}
);
String host = (String) map.get("host");
Integer port = (Integer) map.get("port");
return new SimpleConsumer(host, port, 10000, 100000, "KafkaConsumerInfos");
} catch (Exception e) {
log.error(e, "Could not parse broker[%d] info", brokerId);
return null;
}
}
代码示例来源:origin: HomeAdvisor/Kafdrop
brokerPathCache = new PathChildrenCache(curatorFramework, ZkUtils.BrokerIdsPath(), true);
brokerPathCache.getListenable().addListener(new BrokerListener());
brokerPathCache.getListenable().addListener((f, e) -> {
内容来源于网络,如有侵权,请联系作者删除!