gpt4 book ai didi

org.apache.twill.zookeeper.ZKOperations.recursiveDelete()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 12:32:49 28 4
gpt4 key购买 nike

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

ZKOperations.recursiveDelete介绍

[英]Deletes the given path recursively. The delete method will keep running until the given path is successfully removed, which means if there are new node created under the given path while deleting, they'll get deleted again. If there is KeeperException during the deletion other than KeeperException.NotEmptyException or KeeperException.NoNodeException, the exception would be reflected in the result future and deletion process will stop, leaving the given path with intermediate state.
[中]递归删除给定路径。delete方法将一直运行,直到成功删除给定路径,这意味着如果在删除时在给定路径下创建了新节点,它们将再次被删除。如果删除过程中存在KeeperException而不是KeeperException。NotEmptyException或KeeperException。NoNodeException,异常将反映在未来的结果中,删除过程将停止,将给定路径保留为中间状态。

代码示例

代码示例来源:origin: org.apache.twill/twill-yarn

@Override
 protected void shutDown() throws Exception {
  LOG.info("Removing container ZK path: {}{}", zkClient.getConnectString(), path);
  ZKOperations.recursiveDelete(zkClient, path).get(TIMEOUT_SECONDS, TimeUnit.SECONDS);
 }
}

代码示例来源:origin: apache/twill

@Override
 protected void shutDown() throws Exception {
  LOG.info("Removing container ZK path: {}{}", zkClient.getConnectString(), path);
  ZKOperations.recursiveDelete(zkClient, path).get(TIMEOUT_SECONDS, TimeUnit.SECONDS);
 }
}

代码示例来源:origin: org.apache.twill/twill-zookeeper

@Override
 public void onFailure(final Throwable createFailure) {
  // If create failed not because of the NodeExistsException, just set the exception to the result future
  if (!(createFailure instanceof KeeperException.NodeExistsException)) {
   resultFuture.setException(createFailure);
   return;
  }
  // Try to delete the path
  LOG.info("Node {}{} already exists. Deleting it and retry creation", zkClient.getConnectString(), path);
  Futures.addCallback(recursiveDelete(zkClient, path), new FutureCallback<String>() {
   @Override
   public void onSuccess(String result) {
    // If delete succeeded, perform the creation again.
    createNode(zkClient, path, data, createMode, createParent, createACLs, createCallback);
   }
   @Override
   public void onFailure(Throwable t) {
    // If deletion failed because of NoNodeException, fail the result operation future
    if (!(t instanceof KeeperException.NoNodeException)) {
     createFailure.addSuppressed(t);
     resultFuture.setException(createFailure);
     return;
    }
    // If can't delete because the node no longer exists, just go ahead and recreate the node
    createNode(zkClient, path, data, createMode, createParent, createACLs, createCallback);
   }
  }, Threads.SAME_THREAD_EXECUTOR);
 }
});

代码示例来源:origin: apache/twill

@Override
 public void onFailure(final Throwable createFailure) {
  // If create failed not because of the NodeExistsException, just set the exception to the result future
  if (!(createFailure instanceof KeeperException.NodeExistsException)) {
   resultFuture.setException(createFailure);
   return;
  }
  // Try to delete the path
  LOG.info("Node {}{} already exists. Deleting it and retry creation", zkClient.getConnectString(), path);
  Futures.addCallback(recursiveDelete(zkClient, path), new FutureCallback<String>() {
   @Override
   public void onSuccess(String result) {
    // If delete succeeded, perform the creation again.
    createNode(zkClient, path, data, createMode, createParent, createACLs, createCallback);
   }
   @Override
   public void onFailure(Throwable t) {
    // If deletion failed because of NoNodeException, fail the result operation future
    if (!(t instanceof KeeperException.NoNodeException)) {
     createFailure.addSuppressed(t);
     resultFuture.setException(createFailure);
     return;
    }
    // If can't delete because the node no longer exists, just go ahead and recreate the node
    createNode(zkClient, path, data, createMode, createParent, createACLs, createCallback);
   }
  }, Threads.SAME_THREAD_EXECUTOR);
 }
});

代码示例来源:origin: org.apache.twill/twill-core

ZKOperations.recursiveDelete(zkClient, "/" + runId), KeeperException.NoNodeException.class, null));

代码示例来源:origin: apache/twill

ZKOperations.recursiveDelete(zkClient, "/" + runId), KeeperException.NoNodeException.class, null));

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