Example #1
0
  /**
   * 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();
      }
    }
  }
Example #2
0
 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));
 }