com.mpush.zk.ZKClient.getChildrenKeys()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(1.9k)|赞(0)|评价(0)|浏览(140)

本文整理了Java中com.mpush.zk.ZKClient.getChildrenKeys()方法的一些代码示例,展示了ZKClient.getChildrenKeys()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKClient.getChildrenKeys()方法的具体详情如下:
包路径:com.mpush.zk.ZKClient
类名称:ZKClient
方法名:getChildrenKeys

ZKClient.getChildrenKeys介绍

[英]获取子节点
[中]获取子节点

代码示例

代码示例来源:origin: mpusher/mpush

  1. @Override
  2. public List<ServiceNode> lookup(String serviceName) {
  3. List<String> childrenKeys = client.getChildrenKeys(serviceName);
  4. if (childrenKeys == null || childrenKeys.isEmpty()) {
  5. return Collections.emptyList();
  6. }
  7. return childrenKeys.stream()
  8. .map(key -> serviceName + PATH_SEPARATOR + key)
  9. .map(client::get)
  10. .filter(Objects::nonNull)
  11. .map(childData -> Jsons.fromJson(childData, CommonServiceNode.class))
  12. .filter(Objects::nonNull)
  13. .collect(Collectors.toList());
  14. }

代码示例来源:origin: mpusher/mpush

  1. @Test
  2. public void testZK() throws Exception {
  3. ZKClient.I.syncStart();
  4. ZKClient.I.registerEphemeral(ServerNodes.gs().serviceName(), "3");
  5. ZKClient.I.registerEphemeral(ServerNodes.gs().serviceName(), "4");
  6. System.err.println("==================" + ZKClient.I.getChildrenKeys(ServiceNames.GATEWAY_SERVER));
  7. List<String> rawData = ZKClient.I.getChildrenKeys(ServiceNames.GATEWAY_SERVER);
  8. if (rawData == null || rawData.isEmpty()) {
  9. return;
  10. }
  11. for (String raw : rawData) {
  12. String fullPath = ServiceNames.GATEWAY_SERVER + PATH_SEPARATOR + raw;
  13. System.err.println("==================" + ZKClient.I.get(fullPath));
  14. }
  15. }
  16. }

代码示例来源:origin: com.github.mpusher/mpush-zk

  1. @Override
  2. public List<ServiceNode> lookup(String serviceName) {
  3. List<String> childrenKeys = client.getChildrenKeys(serviceName);
  4. if (childrenKeys == null || childrenKeys.isEmpty()) {
  5. return Collections.emptyList();
  6. }
  7. return childrenKeys.stream()
  8. .map(key -> serviceName + PATH_SEPARATOR + key)
  9. .map(client::get)
  10. .filter(Objects::nonNull)
  11. .map(childData -> Jsons.fromJson(childData, CommonServiceNode.class))
  12. .filter(Objects::nonNull)
  13. .collect(Collectors.toList());
  14. }

相关文章