gpt4 book ai didi

io.fabric8.zookeeper.utils.ZooKeeperUtils.getChildrenSafe()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-16 11:16:40 26 4
gpt4 key购买 nike

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

ZooKeeperUtils.getChildrenSafe介绍

[英]Returns an empty list if the given path doesn't exist in curator
[中]如果给定路径在curator中不存在,则返回空列表

代码示例

代码示例来源:origin: io.fabric8/fabric-zookeeper

/**
 * Returns the list of child names for the given path or an empty list if the given path doesn't exist in curator
 */
public List<String> getChildren(String path) throws Exception {
  return ZooKeeperUtils.getChildrenSafe(curator, path);
}

代码示例来源:origin: jboss-fuse/fabric8

/**
 * Returns the list of child names for the given path or an empty list if the given path doesn't exist in curator
 */
public List<String> getChildren(String path) throws Exception {
  return ZooKeeperUtils.getChildrenSafe(curator, path);
}

代码示例来源:origin: io.fabric8/fabric-rest

@GET
@Path("children")
public Map<String, String> list() throws Exception {
  String zkPath = toZooKeeperPath("");
  List<String> fileNames = ZooKeeperUtils.getChildrenSafe(getCurator(), zkPath);
  return mapToLinks(fileNames, "child/");
}

代码示例来源:origin: jboss-fuse/fabric8

@GET
@Path("children")
public Map<String, String> list() throws Exception {
  String zkPath = toZooKeeperPath("");
  List<String> fileNames = ZooKeeperUtils.getChildrenSafe(getCurator(), zkPath);
  return mapToLinks(fileNames, "child/");
}

代码示例来源:origin: jboss-fuse/fabric8

@Override
public String getRestAPI() {
  assertValid();
  String restApiFolder = ZkPath.REST_API_CLUSTERS.getPath("FabricResource/fabric8");
  try {
    CuratorFramework curatorFramework = curator.get();
    if (curatorFramework != null) {
      List<String> versions = getChildrenSafe(curatorFramework, restApiFolder);
      for (String version : versions) {
        String versionPath = restApiFolder + "/" + version;
        List<String> containers = getChildrenSafe(curatorFramework, versionPath);
        for (String container : containers) {
          String containerPath = versionPath + "/" + container;
          String answer = getFirstService(containerPath);
          if (!Strings.isNullOrEmpty(answer)) {
            return answer;
          }
        }
      }
    }
  } catch (Exception e) {
    //On exception just return uri.
    LOGGER.warn("Failed to find API " + restApiFolder + ". " + e, e);
  }
  return null;
}

代码示例来源:origin: jboss-fuse/fabric8

protected void addChildrenToMap(Map<String, Object> answer, String path, CuratorFramework curator, ObjectMapper mapper) throws Exception {
  Set<String> dontSubstituteKeys = new HashSet<String>(Arrays.asList("id", "container"));
  List<String> children = getChildrenSafe(curator, path);
  for (String child : children) {
    String childPath = path + "/" + child;

代码示例来源:origin: jboss-fuse/fabric8

@Override
public String getGitMaster() {
  assertValid();
  String gitServers = ZkPath.GIT.getPath();
  try {
    CuratorFramework curatorFramework = curator.get();
    if (curatorFramework != null) {
      List<String> servers = getChildrenSafe(curatorFramework, gitServers);
      for (String server : servers) {
        String serverPath = gitServers + "/" + server;
        String answer = getFirstServiceName(serverPath);
        if (!Strings.isNullOrEmpty(answer)) {
          return answer;
        }
      }
    }
  } catch (Exception e) {
    //On exception just return uri.
    LOGGER.warn("Failed to find container name for Git master " + gitServers + ". " + e, e);
  }
  return null;
}

代码示例来源:origin: jboss-fuse/fabric8

@Override
public String getGitUrl() {
  assertValid();
  String gitServers = ZkPath.GIT.getPath();
  try {
    CuratorFramework curatorFramework = curator.get();
    if (curatorFramework != null) {
      List<String> servers = getChildrenSafe(curatorFramework, gitServers);
      for (String server : servers) {
        String serverPath = gitServers + "/" + server;
        String answer = getFirstService(serverPath);
        if (!Strings.isNullOrEmpty(answer)) {
          return answer;
        }
      }
    }
  } catch (Exception e) {
    //On exception just return uri.
    LOGGER.warn("Failed to find Git URL " + gitServers + ". " + e, e);
  }
  return null;
}

代码示例来源:origin: jboss-fuse/fabric8

Map<String, MQBrokerStatusDTO> containerMap = entry.getValue();
String groupPath = ZkPath.MQ_CLUSTER.getPath(group);
List<String> children = getChildrenSafe(curator, groupPath);
for (String child : children) {
  String childPath = groupPath + "/" + child;

代码示例来源:origin: jboss-fuse/fabric8

@Override
public List<String> getContainers() {
  assertValid();
  try {
    return getChildrenSafe(curator.get(), ZkPath.CONFIGS_CONTAINERS.getPath());
  } catch (Exception e) {
    throw FabricException.launderThrowable(e);
  }
}

代码示例来源:origin: jboss-fuse/fabric8

try {
  List<String> list = value != null ? Arrays.asList(value.split("\n")) : Collections.<String>emptyList();
  Set<String> zkSet = new HashSet<String>(getChildrenSafe(curator.get(), ZkPath.CONTAINER_DOMAINS.getPath(containerId)));
  for (String domain : list) {
    String path = CONTAINER_DOMAIN.getPath(containerId, domain);

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com