com.github.zkclient.ZkClient.getChildren()方法的使用及代码示例

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

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

ZkClient.getChildren介绍

暂无

代码示例

代码示例来源:origin: adyliu/jafka

  1. /**
  2. * get children nodes name
  3. *
  4. * @param zkClient zkClient
  5. * @param path full path
  6. * @return children nodes name or null while path not exist
  7. */
  8. public static List<String> getChildrenParentMayNotExist(ZkClient zkClient, String path) {
  9. try {
  10. return zkClient.getChildren(path);
  11. } catch (ZkNoNodeException e) {
  12. return null;
  13. }
  14. }

代码示例来源:origin: adyliu/jafka

  1. public void handleChildChange(String parentPath, List<String> currentChilds) throws Exception {
  2. synchronized (lock) {
  3. if (zkClient == null)
  4. return;
  5. try {
  6. List<String> latestTopics = zkClient.getChildren(ZkUtils.BrokerTopicsPath);
  7. logger.debug("all Topics: " + latestTopics);
  8. eventHandler.handleTopicEvent(latestTopics);
  9. } catch (ConsumerRebalanceFailedException e) {
  10. logger.error("can't rebalance in embedded consumer); proceed to shutdown", e);
  11. serverStartable.close();
  12. } catch (Exception e) {
  13. logger.error("error in handling child changes in embedded consumer", e);
  14. }
  15. }
  16. }
  17. }

代码示例来源:origin: com.github.adyliu/zkclient

  1. @Override
  2. public List<String> call() throws Exception {
  3. exists(path, true);
  4. try {
  5. return getChildren(path, true);
  6. } catch (ZkNoNodeException e) {
  7. // ignore, the "exists" watch will listen for the parent node to appear
  8. }
  9. return null;
  10. }
  11. });

代码示例来源:origin: adyliu/zkclient

  1. @Override
  2. public List<String> call() throws Exception {
  3. exists(path, true);
  4. try {
  5. return getChildren(path, true);
  6. } catch (ZkNoNodeException e) {
  7. // ignore, the "exists" watch will listen for the parent node to appear
  8. }
  9. return null;
  10. }
  11. });

代码示例来源:origin: adyliu/zkclient

  1. public List<String> getChildren(String path) {
  2. return getChildren(path, hasListeners(path));
  3. }

代码示例来源:origin: com.github.adyliu/zkclient

  1. public List<String> getChildren(String path) {
  2. return getChildren(path, hasListeners(path));
  3. }

代码示例来源:origin: com.github.adyliu/zkclient

  1. public boolean deleteRecursive(String path) {
  2. List<String> children;
  3. try {
  4. children = getChildren(path, false);
  5. } catch (ZkNoNodeException e) {
  6. return true;
  7. }
  8. if (children != null){
  9. for (String subPath : children) {
  10. if (!deleteRecursive(path + "/" + subPath)) {
  11. return false;
  12. }
  13. }
  14. }
  15. return delete(path);
  16. }

代码示例来源:origin: adyliu/zkclient

  1. public boolean deleteRecursive(String path) {
  2. List<String> children;
  3. try {
  4. children = getChildren(path, false);
  5. } catch (ZkNoNodeException e) {
  6. return true;
  7. }
  8. if (children != null){
  9. for (String subPath : children) {
  10. if (!deleteRecursive(path + "/" + subPath)) {
  11. return false;
  12. }
  13. }
  14. }
  15. return delete(path);
  16. }

代码示例来源:origin: com.github.adyliu/zkclient

  1. @Override
  2. public void run() throws Exception {
  3. try {
  4. // if the node doesn't exist we should listen for the root node to reappear
  5. exists(path);
  6. List<String> children = getChildren(path);
  7. listener.handleChildChange(path, children);
  8. } catch (ZkNoNodeException e) {
  9. listener.handleChildChange(path, null);
  10. }
  11. }
  12. });

代码示例来源:origin: adyliu/zkclient

  1. @Override
  2. public void run() throws Exception {
  3. try {
  4. // if the node doesn't exist we should listen for the root node to reappear
  5. exists(path);
  6. List<String> children = getChildren(path);
  7. listener.handleChildChange(path, children);
  8. } catch (ZkNoNodeException e) {
  9. listener.handleChildChange(path, null);
  10. }
  11. }
  12. });

相关文章