本文整理了Java中org.apache.zookeeper.ZKUtil.deleteRecursive()
方法的一些代码示例,展示了ZKUtil.deleteRecursive()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKUtil.deleteRecursive()
方法的具体详情如下:
包路径:org.apache.zookeeper.ZKUtil
类名称:ZKUtil
方法名:deleteRecursive
[英]Recursively delete the node with the given path.
Important: All versions, of all nodes, under the given node are deleted.
If there is an error with deleting one of the sub-nodes in the tree, this operation would abort and would be the responsibility of the app to handle the same. See #delete(String,int) for more details.
[中]递归删除具有给定路径的节点。
重要提示:删除给定节点下所有节点的所有版本。
如果删除树中的一个子节点时出错,此操作将中止,并由应用程序负责处理。有关更多详细信息,请参见#删除(字符串,int)。
代码示例来源:origin: org.apache.hadoop/hadoop-common
@Override
public Void run() throws KeeperException, InterruptedException {
ZKUtil.deleteRecursive(zkClient, znodeWorkingDir);
return null;
}
});
代码示例来源:origin: apache/zookeeper
@Override
public boolean exec() throws CliException {
printDeprecatedWarning();
String path = args[1];
try {
ZKUtil.deleteRecursive(zk, path);
} catch (IllegalArgumentException ex) {
throw new MalformedPathException(ex.getMessage());
} catch (KeeperException|InterruptedException ex) {
throw new CliWrapperException(ex);
}
return false;
}
代码示例来源:origin: twitter/distributedlog
try {
LOG.info("Delete the path associated with the log {}, ZK Path {}", name, zkPath);
ZKUtil.deleteRecursive(writerZKC.get(), zkPath);
} catch (InterruptedException ie) {
LOG.error("Interrupted while accessing ZK", ie);
代码示例来源:origin: apache/nifi
@Override
public void onComponentRemoved(final String componentId) throws IOException {
try {
ZKUtil.deleteRecursive(getZooKeeper(), getComponentPath(componentId));
} catch (final KeeperException ke) {
// Node doesn't exist so just ignore
final Code exceptionCode = ke.code();
if (Code.NONODE == exceptionCode) {
return;
}
if (Code.SESSIONEXPIRED == exceptionCode) {
invalidateClient();
onComponentRemoved(componentId);
return;
}
throw new IOException("Unable to remove state for component with ID '" + componentId + " with exception code " + exceptionCode, ke);
} catch (final InterruptedException e) {
Thread.currentThread().interrupt();
throw new IOException("Failed to remove state for component with ID '" + componentId + "' from ZooKeeper due to being interrupted", e);
}
}
代码示例来源:origin: twitter/distributedlog
public void deleteLog() throws IOException {
lock.checkOwnershipAndReacquire();
FutureUtils.result(purgeLogSegmentsOlderThanTxnId(-1));
try {
Utils.closeQuietly(lock);
zooKeeperClient.get().exists(logMetadata.getLogSegmentsPath(), false);
zooKeeperClient.get().exists(logMetadata.getMaxTxIdPath(), false);
if (logMetadata.getLogRootPath().toLowerCase().contains("distributedlog")) {
ZKUtil.deleteRecursive(zooKeeperClient.get(), logMetadata.getLogRootPath());
} else {
LOG.warn("Skip deletion of unrecognized ZK Path {}", logMetadata.getLogRootPath());
}
} catch (InterruptedException ie) {
LOG.error("Interrupted while deleting log znodes", ie);
throw new DLInterruptedException("Interrupted while deleting " + logMetadata.getLogRootPath(), ie);
} catch (KeeperException ke) {
LOG.error("Error deleting" + logMetadata.getLogRootPath() + " in zookeeper", ke);
}
}
代码示例来源:origin: apache/zookeeper
ZKUtil.deleteRecursive(zk, "/a", cb, ctx);
synchronized (ctx) {
ctx.wait();
代码示例来源:origin: org.apache.zookeeper/zookeeper
} else if (cmd.equals("rmr") && args.length >= 2) {
path = args[1];
ZKUtil.deleteRecursive(zk, path);
} else if (cmd.equals("set") && args.length >= 3) {
path = args[1];
代码示例来源:origin: io.hops/hadoop-common
@Override
public Void run() throws KeeperException, InterruptedException {
ZKUtil.deleteRecursive(zkClient, znodeWorkingDir);
return null;
}
});
代码示例来源:origin: io.prestosql.hadoop/hadoop-apache
@Override
public Void run() throws KeeperException, InterruptedException {
ZKUtil.deleteRecursive(zkClient, znodeWorkingDir);
return null;
}
});
代码示例来源:origin: ch.cern.hadoop/hadoop-common
@Override
public Void run() throws KeeperException, InterruptedException {
ZKUtil.deleteRecursive(zkClient, znodeWorkingDir);
return null;
}
});
代码示例来源:origin: com.github.jiayuhan-it/hadoop-common
@Override
public Void run() throws KeeperException, InterruptedException {
ZKUtil.deleteRecursive(zkClient, znodeWorkingDir);
return null;
}
});
代码示例来源:origin: com.srotya/linea
@Override
public void init(Map<String, String> conf, InetAddress selfAddress) throws Exception {
zkRoot = conf.getOrDefault(LINEA_ZK_ROOT, DEFAULT_ZK_ROOT);
zkConnectionString = conf.getOrDefault(LINEA_ZK_CONNECTION_STRING, DEFAULT_ZK_CONNECTION_STRNG);
try {
zk = new ZooKeeper(zkConnectionString, 60000, this);
logger.info("Connected to zookeeper using connection string:" + zkConnectionString);
} catch (IOException e) {
throw new RuntimeException(e);
}
if (autoResetZk) {
Stat exists = zk.exists(zkRoot, false);
if (exists != null) {
ZKUtil.deleteRecursive(zk, zkRoot);
}
}
Stat exists = zk.exists(zkRoot, false);
if (exists == null) {
logger.info("Missing ZkRoot, creating it:" + zkRoot);
zk.create(zkRoot, null, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
}
}
代码示例来源:origin: org.apache.bookkeeper/bookkeeper-server
ZKUtil.deleteRecursive(zk, ZkLedgerUnderreplicationManager.getBasePath(ledgersRootPath)
+ BookKeeperConstants.DEFAULT_ZK_LEDGERS_ROOT_PATH);
} catch (KeeperException.NoNodeException e) {
ZKUtil.deleteRecursive(zk, ZkLedgerUnderreplicationManager.getBasePath(ledgersRootPath) + '/'
+ BookKeeperConstants.UNDER_REPLICATION_LOCK);
} catch (KeeperException.NoNodeException e) {
ZKUtil.deleteRecursive(zk, cookiePath);
} catch (KeeperException.NoNodeException e) {
if (log.isDebugEnabled()) {
代码示例来源:origin: NationalSecurityAgency/datawave
try {
String recursiveDeletePath = ZKPaths.makePath(curatorClient.getNamespace(), path);
ZKUtil.deleteRecursive(curatorClient.getZookeeperClient().getZooKeeper(), recursiveDeletePath);
} catch (Exception e) {
log.trace("Problem deleting " + path + " (this may be ok): " + e.getMessage(), e);
代码示例来源:origin: NationalSecurityAgency/datawave
/**
* Sends an eviction message for {@code messagePath} to all other shared cache coordinators that are listening.
*/
public void sendEvictMessage(String messagePath) throws Exception {
ArgumentChecker.notNull(messagePath);
String rootPath = ZKPaths.makePath("/", "evictions");
String evictMessagePath = ZKPaths.makePath(rootPath, ZKPaths.makePath(messagePath, localName));
Stat nodeData = curatorClient.checkExists().forPath(evictMessagePath);
boolean shouldCreate = true;
if (nodeData != null) {
long delta = System.currentTimeMillis() - nodeData.getCtime();
if (delta > EVICT_MESSAGE_TIMEOUT) {
log.debug("Attempting to delete " + evictMessagePath + " since it was created " + delta + "ms ago and hasn't been cleaned up.");
ZKUtil.deleteRecursive(curatorClient.getZookeeperClient().getZooKeeper(), evictMessagePath);
} else {
shouldCreate = false;
}
}
if (shouldCreate)
curatorClient.create().creatingParentsIfNeeded().forPath(evictMessagePath);
}
代码示例来源:origin: org.apache.bookkeeper/bookkeeper-server
for (String ledgersRootPathChildren : ledgersRootPathChildrenList) {
if (MsLedgerManager.isSpecialZnode(ledgersRootPathChildren)) {
ZKUtil.deleteRecursive(zk, zkLedgersRootPath + "/" + ledgersRootPathChildren);
} else {
log.error("Found unexpected znode : {} under ledgersRootPath : {} so exiting nuke operation",
代码示例来源:origin: org.apache.bookkeeper/bookkeeper-server
for (String ledgersRootPathChildren : ledgersRootPathChildrenList) {
if (AbstractZkLedgerManager.isSpecialZnode(ledgersRootPathChildren)) {
ZKUtil.deleteRecursive(zk, zkLedgersRootPath + "/" + ledgersRootPathChildren);
} else {
log.error("Found unexpected znode : {} under ledgersRootPath : {} so exiting nuke operation",
代码示例来源:origin: org.apache.bookkeeper/bookkeeper-server
@SuppressWarnings("deprecation")
@Override
public void format(AbstractConfiguration<?> conf, LayoutManager layoutManager)
throws InterruptedException, KeeperException, IOException {
try (AbstractZkLedgerManager ledgerManager = (AbstractZkLedgerManager) newLedgerManager()) {
String ledgersRootPath = ZKMetadataDriverBase.resolveZkLedgersRootPath(conf);
List<String> children = zk.getChildren(ledgersRootPath, false);
for (String child : children) {
if (!AbstractZkLedgerManager.isSpecialZnode(child) && ledgerManager.isLedgerParentNode(child)) {
ZKUtil.deleteRecursive(zk, ledgersRootPath + "/" + child);
}
}
}
Class<? extends LedgerManagerFactory> factoryClass;
try {
factoryClass = conf.getLedgerManagerFactoryClass();
} catch (ConfigurationException e) {
throw new IOException("Failed to get ledger manager factory class from configuration : ", e);
}
layoutManager.deleteLedgerLayout();
// Create new layout information again.
createNewLMFactory(conf, layoutManager, factoryClass);
}
代码示例来源:origin: org.apache.distributedlog/distributedlog-core
try {
String streamPath = LogMetadata.getLogStreamPath(uri, logName);
ZKUtil.deleteRecursive(zooKeeperClient.get(), streamPath, new AsyncCallback.VoidCallback() {
@Override
public void processResult(int rc, String path, Object ctx) {
内容来源于网络,如有侵权,请联系作者删除!