private void registerInZooKeeper(String name, String root) throws Exception { IZooReaderWriter zoo = context.getZooReaderWriter(); zoo.putPersistentData(root, new byte[0], NodeExistsPolicy.SKIP); log.info("Registering tracer {} at {}", name, root); String path = zoo.putEphemeralSequential(root + "/trace-", name.getBytes(UTF_8)); zoo.exists(path, this); }
@Override public long addEntry(byte[] data) { String newPath; try { while (true) { try { if (ephemeral) { newPath = zoo.putEphemeralSequential(path + "/" + PREFIX, data); } else { newPath = zoo.putPersistentSequential(path + "/" + PREFIX, data); } String[] parts = newPath.split("/"); String last = parts[parts.length - 1]; return Long.parseLong(last.substring(PREFIX.length())); } catch (NoNodeException nne) { // the parent does not exist so try to create it zoo.putPersistentData(path, new byte[] {}, NodeExistsPolicy.SKIP); } } } catch (Exception ex) { throw new RuntimeException(ex); } }
final String asyncLockPath = zooKeeper.putEphemeralSequential(path + "/" + LOCK_PREFIX, data); log.trace("Ephemeral node {} created", asyncLockPath); Stat stat = zooKeeper.getStatus(asyncLockPath, new Watcher() {
private void registerInZooKeeper(String name, String root) throws Exception { IZooReaderWriter zoo = ZooReaderWriter.getInstance(); zoo.putPersistentData(root, new byte[0], NodeExistsPolicy.SKIP); log.info("Registering tracer " + name + " at " + root); String path = zoo.putEphemeralSequential(root + "/trace-", name.getBytes(UTF_8)); zoo.exists(path, this); }
@Override public long addEntry(byte[] data) { String newPath; try { while (true) { try { if (ephemeral) { newPath = zoo.putEphemeralSequential(path + "/" + PREFIX, data); } else { newPath = zoo.putPersistentSequential(path + "/" + PREFIX, data); } String[] parts = newPath.split("/"); String last = parts[parts.length - 1]; return Long.parseLong(last.substring(PREFIX.length())); } catch (NoNodeException nne) { // the parent does not exist so try to create it zoo.putPersistentData(path, new byte[] {}, NodeExistsPolicy.SKIP); } } } catch (Exception ex) { throw new RuntimeException(ex); } }
private void registerInZooKeeper(String name) throws Exception { String root = ZooUtil.getRoot(serverConfiguration.getInstance()) + Constants.ZTRACERS; IZooReaderWriter zoo = ZooReaderWriter.getInstance(); String path = zoo.putEphemeralSequential(root + "/trace-", name.getBytes(UTF_8)); zoo.exists(path, this); }
final String asyncLockPath = zooKeeper.putEphemeralSequential(path + "/" + LOCK_PREFIX, data); log.trace("Ephemeral node " + asyncLockPath + " created"); Stat stat = zooKeeper.getStatus(asyncLockPath, new Watcher() {