当前位置: 首页>>代码示例>>Java>>正文


Java ZkClient.getChildren方法代码示例

本文整理汇总了Java中org.apache.helix.manager.zk.ZkClient.getChildren方法的典型用法代码示例。如果您正苦于以下问题:Java ZkClient.getChildren方法的具体用法?Java ZkClient.getChildren怎么用?Java ZkClient.getChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.helix.manager.zk.ZkClient的用法示例。


在下文中一共展示了ZkClient.getChildren方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readZkRecursive

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
public static void readZkRecursive(String path, Map<String, ZNode> map, ZkClient zkclient) {
  try {
    Stat stat = new Stat();
    ZNRecord record = zkclient.readData(path, stat);
    List<String> childNames = zkclient.getChildren(path);
    ZNode node = new ZNode(path, record, stat);
    node.addChildren(childNames);
    map.put(path, node);

    for (String childName : childNames) {
      String childPath = path + "/" + childName;
      readZkRecursive(childPath, map, zkclient);
    }
  } catch (ZkNoNodeException e) {
    // OK
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:18,代码来源:TestHelper.java

示例2: delete

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
@Override
public Representation delete() {
  String zkPath = getZKPath();
  try {
    ZkClient zkClient =
        (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);

    List<String> childNames = zkClient.getChildren(zkPath);
    if (childNames != null) {
      for (String childName : childNames) {
        String childPath = zkPath.equals("/") ? "/" + childName : zkPath + "/" + childName;
        zkClient.deleteRecursive(childPath);
      }
    }

    getResponse().setStatus(Status.SUCCESS_OK);
  } catch (Exception e) {
    getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
        MediaType.APPLICATION_JSON);
    getResponse().setStatus(Status.SUCCESS_OK);
    LOG.error("Error in delete zkChild: " + zkPath, e);
  }
  return null;
}
 
开发者ID:apache,项目名称:helix,代码行数:25,代码来源:ZkChildResource.java

示例3: findCompressedZNodes

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
private void findCompressedZNodes(ZkClient zkClient, String path, List<String> compressedPaths) {
  List<String> children = zkClient.getChildren(path);
  if (children != null && children.size() > 0) {
    for (String child : children) {
      String childPath = (path.equals("/") ? "" : path) + "/" + child;
      findCompressedZNodes(zkClient, childPath, compressedPaths);
    }
  } else {
    byte[] data = zkClient.readData(path);
    if (data != null && GZipCompressionUtil.isCompressed(data)) {
      compressedPaths.add(path);
    }
  }

}
 
开发者ID:apache,项目名称:helix,代码行数:16,代码来源:TestEnableCompression.java

示例4: post

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
@Override
public Representation post(Representation entity) {
  String zkPath = getZKPath();

  try {
    JsonParameters jsonParameters = new JsonParameters(entity);
    String command = jsonParameters.getCommand();

    ZkClient zkClient =
        (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);

    if (command.equalsIgnoreCase(JsonParameters.ZK_DELETE_CHILDREN)) {
      List<String> childNames = zkClient.getChildren(zkPath);
      if (childNames != null) {
        for (String childName : childNames) {
          String childPath = zkPath.equals("/") ? "/" + childName : zkPath + "/" + childName;
          zkClient.deleteRecursive(childPath);
        }
      }
    } else {
      throw new HelixException("Unsupported command: " + command + ". Should be one of ["
          + JsonParameters.ZK_DELETE_CHILDREN + "]");
    }

    getResponse().setStatus(Status.SUCCESS_OK);
  } catch (Exception e) {
    getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
        MediaType.APPLICATION_JSON);
    getResponse().setStatus(Status.SUCCESS_OK);
    LOG.error("Error in post zkPath: " + zkPath, e);
  }
  return null;
}
 
开发者ID:apache,项目名称:helix,代码行数:34,代码来源:ZkPathResource.java

示例5: getInstancePropertyNameListAsString

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
public static String getInstancePropertyNameListAsString(ZkClient zkClient, String clusterName,
    String instanceName, PropertyType instanceProperty, String key, MediaType mediaType)
    throws JsonGenerationException, JsonMappingException, IOException {
  String path = PropertyPathBuilder.instanceProperty(clusterName, instanceName, instanceProperty, key);
  if (zkClient.exists(path)) {
    List<String> recordNames = zkClient.getChildren(path);
    return ObjectToJson(recordNames);
  }

  return ObjectToJson(new ArrayList<String>());
}
 
开发者ID:apache,项目名称:helix,代码行数:12,代码来源:ClusterRepresentationUtil.java

示例6: zkCopy

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
private static void zkCopy(ZkClient srcClient, String srcRootPath, ZkClient dstClient, String dstRootPath) {
  // Strip off tailing "/"
  if (!srcRootPath.equals("/") && srcRootPath.endsWith("/")) {
    srcRootPath = srcRootPath.substring(0, srcRootPath.length() - 1);
  }

  if (!dstRootPath.equals("/") && dstRootPath.endsWith("/")) {
    dstRootPath = dstRootPath.substring(0, dstRootPath.length() - 1);
  }

  // Validate paths
  PathUtils.validatePath(srcRootPath);
  PathUtils.validatePath(dstRootPath);

  if (srcRootPath.equals(dstRootPath)) {
    logger.info("srcPath == dstPath. Skip copying");
    return;
  }

  if (srcRootPath.startsWith(dstRootPath) || dstRootPath.startsWith(srcRootPath)) {
    throw new IllegalArgumentException(
        "srcPath/dstPath can't be prefix of dstPath/srcPath, was srcPath: " + srcRootPath
            + ", dstPath: " + dstRootPath);
  }

  // Recursive copy using BFS
  List<String> queue = new LinkedList<String>();
  String root = "";
  copy(srcClient, srcRootPath, dstClient, dstRootPath, Arrays.asList(root));

  queue.add(root);
  while (!queue.isEmpty()) {
    String path = queue.remove(0);
    String fromPath = concatenate(srcRootPath, path);

    List<String> children = srcClient.getChildren(fromPath);
    List<String> paths = new ArrayList<String>();
    if (children != null && children.size() > 0) {
      for (String child : children) {
        String childPath = concatenate(path, child);
        paths.add(childPath);
      }
      copy(srcClient, srcRootPath, dstClient, dstRootPath, paths);
      queue.addAll(paths);
    }
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:48,代码来源:ZkCopy.java

示例7: getInstancePropertyList

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
public static List<String> getInstancePropertyList(ZkClient zkClient, String clusterName,
    String instanceName, PropertyType property, String key) {
  String propertyPath = PropertyPathBuilder.instanceProperty(clusterName, instanceName, property, key);
  return zkClient.getChildren(propertyPath);
}
 
开发者ID:apache,项目名称:helix,代码行数:6,代码来源:ClusterRepresentationUtil.java


注:本文中的org.apache.helix.manager.zk.ZkClient.getChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。