コード例 #1
0
ファイル: CacheZNode.java プロジェクト: imace/tutorials
  /**
   * Checks of the Cachelet watcher has been triggered and will create/remove {@link CacheletZNode}s
   * when necessary. <br>
   * <br>
   * Notifies any listeners if Cachelets are added or removed and updates any CacheletZNodes.
   *
   * @throws KeeperException
   * @throws InterruptedException
   */
  public void update() throws KeeperException, InterruptedException {
    if (cacheletWatcher != null) {
      if (cacheletWatcher.isDeleted()) {
        return;
      } else if (cacheletWatcher.isTriggered()) {
        cacheletWatcher.reset();
        updateCacheletMap(Nimbus.getZooKeeper().getChildren(cacheZNode, cacheletWatcher));
      }

      for (CacheletZNode node : cacheletMap.values()) {
        node.update();
      }
    }
  }
コード例 #2
0
ファイル: CacheZNode.java プロジェクト: imace/tutorials
 public CacheZNode(String cacheName) throws KeeperException, InterruptedException {
   this.cacheName = cacheName;
   cacheZNode = Nimbus.ROOT_ZNODE + "/" + this.cacheName;
   cacheletWatcher = new ChildZNodeWatcher();
   updateCacheletMap(Nimbus.getZooKeeper().getChildren(cacheZNode, cacheletWatcher));
 }