Example usage for org.apache.zookeeper ZooKeeper setACL

List of usage examples for org.apache.zookeeper ZooKeeper setACL

Introduction

In this page you can find the example usage for org.apache.zookeeper ZooKeeper setACL.

Prototype

public void setACL(final String path, List<ACL> acl, int version, StatCallback cb, Object ctx) 

Source Link

Document

The asynchronous version of setACL.

Usage

From source file:org.apache.bookkeeper.zookeeper.BkZooKeeperClient.java

License:Apache License

@Override
public void setACL(final String path, final List<ACL> acl, final int version, final StatCallback cb,
        final Object context) {
    final Runnable proc = new ZkRetryRunnable(operationRetryPolicy, rateLimiter, setACLStats) {

        final StatCallback stCb = new StatCallback() {

            @Override/*  ww w. ja  va2  s .c o m*/
            public void processResult(int rc, String path, Object ctx, Stat stat) {
                BkZooWorker worker = (BkZooWorker) ctx;
                if (allowRetry(worker, rc)) {
                    backOffAndRetry(that, worker.nextRetryWaitTime());
                } else {
                    cb.processResult(rc, path, context, stat);
                }
            }

        };

        @Override
        public String toString() {
            return String.format("setACL (%s, acl = %s, version = %d)", path, acl, version);
        }

        @Override
        void zkRun() {
            ZooKeeper zkHandle = zk.get();
            if (null == zkHandle) {
                BkZooKeeperClient.super.setACL(path, acl, version, stCb, worker);
            } else {
                zkHandle.setACL(path, acl, version, stCb, worker);
            }
        }
    };
    // execute it immediately
    proc.run();
}

From source file:org.apache.bookkeeper.zookeeper.ZooKeeperClient.java

License:Apache License

@Override
public void setACL(final String path, final List<ACL> acl, final int version, final StatCallback cb,
        final Object context) {
    final Runnable proc = new ZkRetryRunnable(operationRetryPolicy, rateLimiter, setACLStats) {

        final StatCallback stCb = new StatCallback() {

            @Override//from   w w w  .  j av a  2s .  com
            public void processResult(int rc, String path, Object ctx, Stat stat) {
                ZooWorker worker = (ZooWorker) ctx;
                if (allowRetry(worker, rc)) {
                    backOffAndRetry(that, worker.nextRetryWaitTime());
                } else {
                    cb.processResult(rc, path, context, stat);
                }
            }

        };

        @Override
        public String toString() {
            return String.format("setACL (%s, acl = %s, version = %d)", path, acl, version);
        }

        @Override
        void zkRun() {
            ZooKeeper zkHandle = zk.get();
            if (null == zkHandle) {
                ZooKeeperClient.super.setACL(path, acl, version, stCb, worker);
            } else {
                zkHandle.setACL(path, acl, version, stCb, worker);
            }
        }
    };
    // execute it immediately
    proc.run();
}