Example usage for org.apache.zookeeper ZKUtil deleteRecursive

List of usage examples for org.apache.zookeeper ZKUtil deleteRecursive

Introduction

In this page you can find the example usage for org.apache.zookeeper ZKUtil deleteRecursive.

Prototype

public static void deleteRecursive(ZooKeeper zk, final String pathRoot, VoidCallback cb, Object ctx)
        throws InterruptedException, KeeperException 

Source Link

Document

Recursively delete the node with the given path.

Usage

From source file:org.apache.distributedlog.impl.metadata.ZKLogStreamMetadataStore.java

License:Apache License

@Override
public CompletableFuture<Void> deleteLog(URI uri, final String logName) {
    final CompletableFuture<Void> promise = new CompletableFuture<Void>();
    try {/*from   ww  w.j  a  va2s  .c o  m*/
        String streamPath = LogMetadata.getLogStreamPath(uri, logName);
        ZKUtil.deleteRecursive(zooKeeperClient.get(), streamPath, new AsyncCallback.VoidCallback() {
            @Override
            public void processResult(int rc, String path, Object ctx) {
                if (KeeperException.Code.OK.intValue() != rc) {
                    FutureUtils.completeExceptionally(promise,
                            new ZKException("Encountered zookeeper issue on deleting log stream " + logName,
                                    KeeperException.Code.get(rc)));
                    return;
                }
                FutureUtils.complete(promise, null);
            }
        }, null);
    } catch (ZooKeeperClient.ZooKeeperConnectionException e) {
        FutureUtils.completeExceptionally(promise,
                new ZKException("Encountered zookeeper issue on deleting log stream " + logName,
                        KeeperException.Code.CONNECTIONLOSS));
    } catch (InterruptedException e) {
        FutureUtils.completeExceptionally(promise,
                new DLInterruptedException("Interrupted while deleting log stream " + logName));
    } catch (KeeperException e) {
        FutureUtils.completeExceptionally(promise,
                new ZKException("Encountered zookeeper issue on deleting log stream " + logName, e));
    }
    return promise;
}