gpt4 book ai didi

org.apache.twill.zookeeper.ZKOperations.watchChildren()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 12:46:49 29 4
gpt4 key购买 nike

本文整理了Java中org.apache.twill.zookeeper.ZKOperations.watchChildren()方法的一些代码示例,展示了ZKOperations.watchChildren()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKOperations.watchChildren()方法的具体详情如下:
包路径:org.apache.twill.zookeeper.ZKOperations
类名称:ZKOperations
方法名:watchChildren

ZKOperations.watchChildren介绍

暂无

代码示例

代码示例来源:origin: org.apache.twill/twill-yarn

/**
 * Watch for changes to services under given path.
 * @param path to check for changes.
 */
void addWatcher(String path) {
 ZKOperations.watchChildren(zkClient, path, new ZKOperations.ChildrenCallback() {
  @Override
  public void updated(NodeChildren nodeChildren) {
   resourceReport.setServices(nodeChildren.getChildren());
  }
 });
}

代码示例来源:origin: caskdata/cdap

@Override
protected void startUp() throws Exception {
 cancellable = ZKOperations.watchChildren(zkClient, leaderElectionPath, new ZKOperations.ChildrenCallback() {
  @Override
  public void updated(NodeChildren nodeChildren) {
   childrenUpdated(nodeChildren, participants, readyFuture);
  }
 });
}

代码示例来源:origin: co.cask.cdap/cdap-common

@Override
protected void startUp() throws Exception {
 cancellable = ZKOperations.watchChildren(zkClient, leaderElectionPath, new ZKOperations.ChildrenCallback() {
  @Override
  public void updated(NodeChildren nodeChildren) {
   childrenUpdated(nodeChildren, participants, readyFuture);
  }
 });
}

代码示例来源:origin: apache/twill

/**
 * Watch for changes to services under given path.
 * @param path to check for changes.
 */
void addWatcher(String path) {
 ZKOperations.watchChildren(zkClient, path, new ZKOperations.ChildrenCallback() {
  @Override
  public void updated(NodeChildren nodeChildren) {
   resourceReport.setServices(nodeChildren.getChildren());
  }
 });
}

代码示例来源:origin: caskdata/coopr

private void setExternalChangeWatcher()
 throws ExecutionException, InterruptedException {
 ZKOperations.watchChildren(zkClient, "", new ZKOperations.ChildrenCallback() {
  @Override
  public void updated(NodeChildren nodeChildren) {
   List<String> nodes = nodeChildren.getChildren();
   List<OperationFuture<NodeData>> dataFutures = Lists.newArrayList();
   for (String node : nodes) {
    dataFutures.add(zkClient.getData(getNodePath(node)));
   }
   final ListenableFuture<List<NodeData>> fetchFuture = Futures.successfulAsList(dataFutures);
   fetchFuture.addListener(new Runnable() {
    @Override
    public void run() {
     ImmutableList.Builder<T> builder = ImmutableList.builder();
     // fetchFuture is set by this time
     List<NodeData> nodesData = Futures.getUnchecked(fetchFuture);
     for (NodeData nodeData : nodesData) {
      builder.add(serializer.deserialize(nodeData.getData()));
     }
     currentView.set(builder.build());
    }
   }, Threads.SAME_THREAD_EXECUTOR);
  }
 });
}

代码示例来源:origin: caskdata/coopr

private void setExternalChangeWatcher()
 throws ExecutionException, InterruptedException {
 ZKOperations.watchChildren(zkClient, "", new ZKOperations.ChildrenCallback() {
  @Override
  public void updated(NodeChildren nodeChildren) {
   List<String> nodes = nodeChildren.getChildren();
   final Map<String, ListenableFuture<NodeData>> nodeAndDataFutures = Maps.newHashMap();
   List<OperationFuture<NodeData>> dataFutures = Lists.newArrayList();
   for (String node : nodes) {
    OperationFuture<NodeData> dataFuture = zkClient.getData(getNodePath(node));
    dataFutures.add(dataFuture);
    nodeAndDataFutures.put(node, dataFuture);
   }
   final ListenableFuture<List<NodeData>> fetchFuture = Futures.successfulAsList(dataFutures);
   fetchFuture.addListener(new Runnable() {
    @Override
    public void run() {
     ImmutableMap.Builder<String, T> builder = ImmutableMap.builder();
     for (Map.Entry<String, ListenableFuture<NodeData>> nodeAndData : nodeAndDataFutures.entrySet()) {
      T value = serializer.deserialize(Futures.getUnchecked(nodeAndData.getValue()).getData());
      builder.put(nodeAndData.getKey(), value);
     }
     currentView.set(builder.build());
     updateWaitingForElements();
    }
   }, Threads.SAME_THREAD_EXECUTOR);
  }
 });
}

代码示例来源:origin: cdapio/cdap

private Map<String, T> reloadAll() {
 final Map<String, T> loaded = Maps.newConcurrentMap();
 ZKOperations.watchChildren(zookeeper, parentZnode, new ZKOperations.ChildrenCallback() {
  @Override
  public void updated(NodeChildren nodeChildren) {

代码示例来源:origin: org.apache.twill/twill-yarn

final Cancellable cancellable = ZKOperations.watchChildren(zkClientService, "/",
                              new ZKOperations.ChildrenCallback() {
 @Override

代码示例来源:origin: apache/twill

final Cancellable cancellable = ZKOperations.watchChildren(zkClientService, "/",
                              new ZKOperations.ChildrenCallback() {
 @Override

代码示例来源:origin: org.apache.twill/twill-yarn

ZKOperations.watchChildren(zkClientService, instancePath, new ZKOperations.ChildrenCallback() {
@Override
public void updated(NodeChildren nodeChildren) {

代码示例来源:origin: apache/twill

ZKOperations.watchChildren(zkClientService, instancePath, new ZKOperations.ChildrenCallback() {
@Override
public void updated(NodeChildren nodeChildren) {

代码示例来源:origin: org.apache.twill/twill-discovery-core

Cancellable cancellable = ZKOperations.watchChildren(zkClient, pathBase, new ZKOperations.ChildrenCallback() {
 @Override
 public void updated(NodeChildren nodeChildren) {

代码示例来源:origin: apache/twill

Cancellable cancellable = ZKOperations.watchChildren(zkClient, pathBase, new ZKOperations.ChildrenCallback() {
 @Override
 public void updated(NodeChildren nodeChildren) {

代码示例来源:origin: caskdata/coopr

@Override
protected void startUp() throws Exception {
 Futures.getUnchecked(ZKClientExt.ensureExists(zkClient, queueType.getPath()));
 refreshQueues(Futures.getUnchecked(zkClient.getChildren(queueType.getPath())));
 ZKOperations.watchChildren(zkClient, queueType.getPath(), new ZKOperations.ChildrenCallback() {
  @Override
  public void updated(NodeChildren nodeChildren) {
   refreshQueues(nodeChildren);
  }
 });
}

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com