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

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

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

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());
}

相关文章

微信公众号

最新文章

更多