Package org.apache.blur.zookeeper

Examples of org.apache.blur.zookeeper.WatchNodeExistance$OnChange


      }
    });
  }

  private void watchForLayoutChanges(final String cluster) throws KeeperException, InterruptedException {
    WatchNodeExistance we1 = new WatchNodeExistance(_zookeeper, ZookeeperPathConstants.getTablesPath(cluster));
    we1.watch(new WatchNodeExistance.OnChange() {
      @Override
      public void action(Stat stat) {
        if (stat != null) {
          watch(cluster, ZookeeperPathConstants.getTablesPath(cluster), _watchForTablesPerCluster);
        }
      }
    });
    if (_watchForTablesPerClusterExistance.putIfAbsent(cluster, we1) != null) {
      we1.close();
    }

    WatchNodeExistance we2 = new WatchNodeExistance(_zookeeper, ZookeeperPathConstants.getTablesPath(cluster));
    we2.watch(new WatchNodeExistance.OnChange() {
      @Override
      public void action(Stat stat) {
        if (stat != null) {
          watch(cluster, ZookeeperPathConstants.getOnlineShardsPath(cluster), _watchForOnlineShardsPerCluster);
        }
      }
    });
    if (_watchForOnlineShardsPerClusterExistance.putIfAbsent(cluster, we2) != null) {
      we2.close();
    }
  }
View Full Code Here


      Set<String> oldSet = _tablesPerCluster.put(cluster, newSet);
      Set<String> newTables = getNewTables(newSet, oldSet);
      for (String table : newTables) {
        final String clusterTableKey = getClusterTableKey(cluster, table);

        WatchNodeExistance readOnlyWatcher = new WatchNodeExistance(_zk, ZookeeperPathConstants.getTableReadOnlyPath(
            cluster, table));
        readOnlyWatcher.watch(new WatchNodeExistance.OnChange() {
          @Override
          public void action(Stat stat) {
            if (stat == null) {
              _readOnly.put(clusterTableKey, Boolean.FALSE);
            } else {
              _readOnly.put(clusterTableKey, Boolean.TRUE);
            }
          }
        });
        if (_readOnlyWatchNodeExistance.putIfAbsent(clusterTableKey, readOnlyWatcher) != null) {
          readOnlyWatcher.close();
        }

        WatchNodeExistance enabledWatcher = new WatchNodeExistance(_zk, ZookeeperPathConstants.getTableEnabledPath(
            cluster, table));
        enabledWatcher.watch(new WatchNodeExistance.OnChange() {
          @Override
          public void action(Stat stat) {
            if (stat == null) {
              _enabled.put(clusterTableKey, Boolean.FALSE);
            } else {
              _enabled.put(clusterTableKey, Boolean.TRUE);
            }
          }
        });
        if (_enabledWatchNodeExistance.putIfAbsent(clusterTableKey, enabledWatcher) != null) {
          enabledWatcher.close();
        }
      }
    }
View Full Code Here

      }
    });
  }

  private void watchForLayoutChangeEvents(final String cluster) throws KeeperException, InterruptedException {
    WatchNodeExistance we1 = new WatchNodeExistance(_zookeeper, ZookeeperPathConstants.getTablesPath(cluster));
    we1.watch(new WatchNodeExistance.OnChange() {
      @Override
      public void action(Stat stat) {
        if (stat != null) {
          watchTables(cluster, _watchForTablesPerCluster);
        }
      }
    });
    if (_watchForTablesPerClusterExistance.putIfAbsent(cluster, we1) != null) {
      we1.close();
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.blur.zookeeper.WatchNodeExistance$OnChange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.