Example usage for org.apache.zookeeper ZooDefs CONFIG_NODE

List of usage examples for org.apache.zookeeper ZooDefs CONFIG_NODE

Introduction

In this page you can find the example usage for org.apache.zookeeper ZooDefs CONFIG_NODE.

Prototype

String CONFIG_NODE

To view the source code for org.apache.zookeeper ZooDefs CONFIG_NODE.

Click Source Link

Usage

From source file:org.apache.curator.framework.imps.GetConfigBuilderImpl.java

License:Apache License

@Override
public void performBackgroundOperation(final OperationAndData<Void> operationAndData) throws Exception {
    try {// w  ww .j a  va  2 s .co m
        final TimeTrace trace = client.getZookeeperClient().startTracer("GetDataBuilderImpl-Background");
        AsyncCallback.DataCallback callback = new AsyncCallback.DataCallback() {
            @Override
            public void processResult(int rc, String path, Object ctx, byte[] data, Stat stat) {
                watching.commitWatcher(rc, false);
                trace.commit();
                CuratorEvent event = new CuratorEventImpl(client, CuratorEventType.GET_CONFIG, rc, path, null,
                        ctx, stat, data, null, null, null, null);
                client.processBackgroundOperation(operationAndData, event);
            }
        };
        if (watching.isWatched()) {
            client.getZooKeeper().getConfig(true, callback, backgrounding.getContext());
        } else {
            client.getZooKeeper().getConfig(watching.getWatcher(ZooDefs.CONFIG_NODE), callback,
                    backgrounding.getContext());
        }
    } catch (Throwable e) {
        backgrounding.checkError(e, watching);
    }
}

From source file:org.apache.curator.framework.imps.GetConfigBuilderImpl.java

License:Apache License

private byte[] configInForeground() throws Exception {
    TimeTrace trace = client.getZookeeperClient().startTracer("GetConfigBuilderImpl-Foreground");
    try {/* ww  w .  j  a v a  2 s  .  c  om*/
        return RetryLoop.callWithRetry(client.getZookeeperClient(), new Callable<byte[]>() {
            @Override
            public byte[] call() throws Exception {
                if (watching.isWatched()) {
                    return client.getZooKeeper().getConfig(true, stat);
                }
                byte[] config = client.getZooKeeper().getConfig(watching.getWatcher(ZooDefs.CONFIG_NODE), stat);
                watching.commitWatcher(KeeperException.NoNodeException.Code.OK.intValue(), false);
                return config;
            }
        });
    } finally {
        trace.commit();
    }
}