public String createNode(CuratorFramework zk, String path, byte[] data, org.apache.zookeeper.CreateMode mode) throws Exception { String npath = PathUtils.normalize_path(path); return zk.create().withMode(mode).withACL(ZooDefs.Ids.OPEN_ACL_UNSAFE) .forPath(npath, data); }
@VisibleForTesting void internalCreateNode(String path, byte[] bytes, BackgroundCallback callback) throws Exception { client.create().withMode(CreateMode.PERSISTENT_SEQUENTIAL).inBackground(callback).forPath(path, bytes); }
public String call() throws Exception { return transport.getZKHandle().create() .withMode(CreateMode.PERSISTENT) .forPath(groupname); } });
private void doPutInForeground(final T item, String path, final MultiItem<T> givenMultiItem, byte[] bytes) throws Exception { client.create().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath(path, bytes); synchronized(putCount) { putCount.decrementAndGet(); putCount.notifyAll(); } putListenerContainer.forEach ( new Function<QueuePutListener<T>, Void>() { @Override public Void apply(QueuePutListener<T> listener) { if ( item != null ) { listener.putCompleted(item); } else { listener.putMultiCompleted(givenMultiItem); } return null; } } ); }
/** * Inserts data into queue. * * @param data the data * @return true if data was successfully added * @throws Exception errors */ public boolean offer(byte[] data) throws Exception { ensurePath.ensure(client.getZookeeperClient()); String thisPath = ZKPaths.makePath(path, PREFIX); client.create().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath(thisPath, data); return true; }
client.create().withMode(EPHEMERAL).inBackground(new BackgroundCallback() {
try client.create().withMode(CreateMode.EPHEMERAL).forPath(lockNodePath); lockCreated = true;