本文整理了Java中com.mpush.zk.ZKClient.getChildrenKeys()
方法的一些代码示例,展示了ZKClient.getChildrenKeys()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKClient.getChildrenKeys()
方法的具体详情如下:
包路径:com.mpush.zk.ZKClient
类名称:ZKClient
方法名:getChildrenKeys
[英]获取子节点
[中]获取子节点
代码示例来源:origin: mpusher/mpush
@Override
public List<ServiceNode> lookup(String serviceName) {
List<String> childrenKeys = client.getChildrenKeys(serviceName);
if (childrenKeys == null || childrenKeys.isEmpty()) {
return Collections.emptyList();
}
return childrenKeys.stream()
.map(key -> serviceName + PATH_SEPARATOR + key)
.map(client::get)
.filter(Objects::nonNull)
.map(childData -> Jsons.fromJson(childData, CommonServiceNode.class))
.filter(Objects::nonNull)
.collect(Collectors.toList());
}
代码示例来源:origin: mpusher/mpush
@Test
public void testZK() throws Exception {
ZKClient.I.syncStart();
ZKClient.I.registerEphemeral(ServerNodes.gs().serviceName(), "3");
ZKClient.I.registerEphemeral(ServerNodes.gs().serviceName(), "4");
System.err.println("==================" + ZKClient.I.getChildrenKeys(ServiceNames.GATEWAY_SERVER));
List<String> rawData = ZKClient.I.getChildrenKeys(ServiceNames.GATEWAY_SERVER);
if (rawData == null || rawData.isEmpty()) {
return;
}
for (String raw : rawData) {
String fullPath = ServiceNames.GATEWAY_SERVER + PATH_SEPARATOR + raw;
System.err.println("==================" + ZKClient.I.get(fullPath));
}
}
}
代码示例来源:origin: com.github.mpusher/mpush-zk
@Override
public List<ServiceNode> lookup(String serviceName) {
List<String> childrenKeys = client.getChildrenKeys(serviceName);
if (childrenKeys == null || childrenKeys.isEmpty()) {
return Collections.emptyList();
}
return childrenKeys.stream()
.map(key -> serviceName + PATH_SEPARATOR + key)
.map(client::get)
.filter(Objects::nonNull)
.map(childData -> Jsons.fromJson(childData, CommonServiceNode.class))
.filter(Objects::nonNull)
.collect(Collectors.toList());
}
内容来源于网络,如有侵权,请联系作者删除!