List of usage examples for org.apache.zookeeper KeeperException create
@Deprecated public static KeeperException create(int code, String path)
From source file:org.midonet.cluster.backend.zookeeper.ZkDirectory.java
License:Apache License
@Override public void asyncGetChildren(String relativePath, DirectoryCallback<Collection<String>> callback, Watcher watcher, Object context) { String absPath = getAbsolutePath(relativePath); zk.getChildren(absPath, watcher, new AsyncCallback.Children2Callback() { @Override/*from w w w . j a v a2s .c o m*/ public void processResult(int rc, String path, Object ctx, List<String> children, Stat stat) { if (rc == KeeperException.Code.OK.intValue()) { callback.onSuccess(children, stat, ctx); } else { callback.onError(KeeperException.create(KeeperException.Code.get(rc), path), ctx); } } }, context); }
From source file:org.midonet.cluster.backend.zookeeper.ZkDirectory.java
License:Apache License
@Override public void asyncExists(String relativePath, DirectoryCallback<Boolean> callback, Object context) { String absPath = getAbsolutePath(relativePath); zk.exists(absPath, null, new AsyncCallback.StatCallback() { @Override/*from w ww . j a va2 s. co m*/ public void processResult(int rc, String path, Object ctx, Stat stat) { if (rc == KeeperException.Code.OK.intValue()) { callback.onSuccess(true, stat, ctx); } else if (rc == KeeperException.Code.NONODE.intValue()) { callback.onSuccess(false, null, ctx); } else { callback.onError(KeeperException.create(KeeperException.Code.get(rc), path), ctx); } } }, context); }
From source file:org.midonet.cluster.backend.zookeeper.ZkDirectory.java
License:Apache License
@Override public void asyncDelete(String relativePath, int version, DirectoryCallback<Void> callback, Object context) { String absPath = getAbsolutePath(relativePath); zk.delete(absPath, version, new AsyncCallback.VoidCallback() { @Override//from ww w. jav a 2s . co m public void processResult(int rc, String path, Object ctx) { if (rc == KeeperException.Code.OK.intValue()) { callback.onSuccess(null, null, ctx); } else { callback.onError(KeeperException.create(KeeperException.Code.get(rc), path), ctx); } } }, context); }
From source file:org.midonet.midolman.state.ZkDirectory.java
License:Apache License
@Override public void asyncAdd(String relativePath, final byte[] data, CreateMode mode, final DirectoryCallback.Add cb) { final String absPath = getAbsolutePath(relativePath); zk.getZooKeeper().create(absPath, data, acl, mode, new AsyncCallback.StringCallback() { @Override/*from w w w . j a v a2 s . c o m*/ public void processResult(int rc, String path, Object ctx, String name) { KeeperException.Code code = KeeperException.Code.get(rc); switch (code) { case OK: cb.onSuccess(name.substring(basePath.length())); break; default: cb.onError(KeeperException.create(code, path)); } } }, null); }
From source file:org.midonet.midolman.state.ZkDirectory.java
License:Apache License
@Override public void asyncGet(String relativePath, final DirectoryCallback<byte[]> dataCallback, TypedWatcher watcher) { zk.getZooKeeper().getData(getAbsolutePath(relativePath), wrapCallback(watcher), new AsyncCallback.DataCallback() { @Override//w w w. j av a 2s .c o m public void processResult(int rc, String path, Object ctx, byte[] data, Stat stat) { if (rc == KeeperException.Code.OK.intValue()) { dataCallback.onSuccess(data); } else { dataCallback.onError(KeeperException.create(KeeperException.Code.get(rc), path)); } } }, null); }
From source file:org.midonet.midolman.state.ZkDirectory.java
License:Apache License
@Override public void asyncGetChildren(String relativePath, final DirectoryCallback<Set<String>> cb, TypedWatcher watcher) {// w ww.ja v a 2 s .c om zk.getZooKeeper().getChildren(getAbsolutePath(relativePath), wrapCallback(watcher), new AsyncCallback.Children2Callback() { @Override public void processResult(int rc, String path, Object ctx, List<String> children, Stat stat) { if (rc == KeeperException.Code.OK.intValue()) { cb.onSuccess(new HashSet<String>(children)); } else { cb.onError(KeeperException.create(KeeperException.Code.get(rc), path)); } } }, null); }
From source file:org.midonet.midolman.state.ZkDirectory.java
License:Apache License
@Override public void asyncDelete(String relativePath, final DirectoryCallback.Void callback) { zk.getZooKeeper().delete(relativePath, -1, new AsyncCallback.VoidCallback() { @Override//from ww w. jav a2s . c o m public void processResult(int rc, String path, Object ctx) { if (rc == KeeperException.Code.OK.intValue()) { callback.onSuccess(null); } else { callback.onError(KeeperException.create(KeeperException.Code.get(rc), path)); } } }, null); }
From source file:org.midonet.midolman.state.ZkNatBlockAllocator.java
License:Apache License
private void ensureDevicePath(final NatRange natRange, final Callback<NatBlock, Exception> callback) { zk.getZooKeeper().create(paths.getNatDevicePath(natRange.deviceId), null, acl, CreateMode.PERSISTENT, new AsyncCallback.StringCallback() { @Override//w ww . ja v a 2 s. co m public void processResult(int rc, String path, Object ctx, String name) { if (rc == KeeperException.Code.OK.intValue() || rc == KeeperException.Code.NODEEXISTS.intValue()) { ensureIpPath(natRange, callback); } else { callback.onError(KeeperException.create(KeeperException.Code.get(rc), path)); } } }, null); }