@Override public List<String> addTargetChildListener(String path, CuratorWatcher listener) { try { return client.getChildren().usingWatcher(listener).forPath(path); } catch (NoNodeException e) { return null; } catch (Exception e) { throw new IllegalStateException(e.getMessage(), e); } }
@Override public List<String> addTargetChildListener(String path, CuratorWatcher listener) { try { return client.getChildren().usingWatcher(listener).forPath(path); } catch (NoNodeException e) { return null; } catch (Exception e) { throw new IllegalStateException(e.getMessage(), e); } }
@Override public void process(WatchedEvent event) throws Exception { if (listener != null) { String path = event.getPath() == null ? "" : event.getPath(); listener.childChanged(path, // if path is null, curator using watcher will throw NullPointerException. // if client connect or disconnect to server, zookeeper will queue // watched event(Watcher.Event.EventType.None, .., path = null). StringUtils.isNotEmpty(path) ? client.getChildren().usingWatcher(this).forPath(path) : Collections.<String>emptyList()); } } }
@Override public void process(WatchedEvent event) throws Exception { if (listener != null) { String path = event.getPath() == null ? "" : event.getPath(); listener.childChanged(path, // if path is null, curator using watcher will throw NullPointerException. // if client connect or disconnect to server, zookeeper will queue // watched event(Watcher.Event.EventType.None, .., path = null). StringUtils.isNotEmpty(path) ? client.getChildren().usingWatcher(this).forPath(path) : Collections.<String>emptyList()); } } }
private void listenRollbackTransactionAndRegisterWatcher() throws Exception { String parent = String.format("%s/%s/rollback", CONSTANTS_ROOT_PATH, CommonUtils.getApplication(this.endpoint)); this.curatorFramework.getChildren().usingWatcher(this).inBackground(this).forPath(parent); }
private void getInstancesDirectorysChildrenAndRegisterWatcher() throws Exception { String parent = String.format("%s/%s/instances", CONSTANTS_ROOT_PATH, CommonUtils.getApplication(this.endpoint)); this.curatorFramework.getChildren().usingWatcher(this).inBackground(this).forPath(parent); }
public void process(WatchedEvent event) throws Exception { if (EventType.NodeChildrenChanged.equals(event.getType())) { String parent = String.format("%s/%s/rollback", CONSTANTS_ROOT_PATH, CommonUtils.getApplication(this.endpoint)); this.curatorFramework.getChildren().usingWatcher(this).inBackground(this).forPath(parent); } }
@Override public List<String> addTargetChildListener(String path, CuratorWatcher listener) { try { return client.getChildren().usingWatcher(listener).forPath(path); } catch (NoNodeException e) { return null; } catch (Exception e) { throw new IllegalStateException(e.getMessage(), e); } }
@Override public void process(WatchedEvent event) throws Exception { if (listener != null) { String path = event.getPath() == null ? "" : event.getPath(); listener.childChanged(path, // if path is null, curator using watcher will throw NullPointerException. // if client connect or disconnect to server, zookeeper will queue // watched event(Watcher.Event.EventType.None, .., path = null). StringUtils.isNotEmpty(path) ? client.getChildren().usingWatcher(this).forPath(path) : Collections.<String>emptyList()); } } }
public List<String> addTargetChildListener(String path, CuratorWatcher listener) { try { return client.getChildren().usingWatcher(listener).forPath(path); } catch (NoNodeException e) { return null; } catch (Exception e) { throw new IllegalStateException(e.getMessage(), e); } }
@Override public List<String> addTargetChildListener(String path, CuratorWatcher listener) { try { return client.getChildren().usingWatcher(listener).forPath(path); } catch (NoNodeException e) { return null; } catch (Exception e) { throw new IllegalStateException(e.getMessage(), e); } }
@Override public List<String> addTargetChildListener(String path, CuratorWatcher listener) { try { return client.getChildren().usingWatcher(listener).forPath(path); } catch (NoNodeException e) { return null; } catch (Exception e) { throw new IllegalStateException(e.getMessage(), e); } }
private List<String> getWatchLogs() { // This can happen too early when /delta/activeLogs is beging setup. // Just ignore that and sync later. try { return client.getChildren().usingWatcher(patchLogWatcher).forPath(ZkConst.pActiveLogs); } catch (KeeperException.NoNodeException ex) {} catch (KeeperException ex) {} catch (Exception ex) {} return null; }
public static List<String> watchedGetChildren(CuratorFramework client, String path, Watcher watcher) throws Exception { /** * Get children and set the given watcher on the node. */ return client.getChildren().usingWatcher(watcher).forPath(path); } }
public static List<String> watchedGetChildren(CuratorFramework client, String path, Watcher watcher) throws Exception { /** * Get children and set the given watcher on the node. */ return client.getChildren().usingWatcher(watcher).forPath(path); } }
private synchronized void sync(boolean watched) throws Exception { if ( watched ) { client.getChildren().usingWatcher(watcher).inBackground(callback).forPath(path); } else { client.getChildren().inBackground(callback).forPath(path); } }
void refresh(final RefreshMode mode) throws Exception { ensurePath.ensure(client.getZookeeperClient()); List<String> children = client.getChildren().usingWatcher(childrenWatcher).forPath(path); Collections.sort(children, new Comparator<String>() { @Override public int compare(String left, String right) { return left.compareTo(right); } }); processChildren(children, mode); }
@Override public TreeData load(String key) throws Exception { Stat stat = client.checkExists().forPath(key); if (stat!= null) { byte[] bytes = dataIsCompressed ? client.getData().decompressed().usingWatcher(watcher).forPath(key) : client.getData().usingWatcher(watcher).forPath(key); List<String> children = client.getChildren().usingWatcher(watcher).forPath(key); return new TreeData(key, stat, bytes, children); } else { return null; } } });
public void process(WatchedEvent event) throws Exception { if (listener != null) { listener.childChanged(event.getPath(), client.getChildren().usingWatcher(this).forPath(event.getPath())); } } }
public void process(WatchedEvent event) throws Exception { if (listener != null) { listener.childChanged(event.getPath(), client.getChildren().usingWatcher(this).forPath(event.getPath())); } } }