コード例 #1
0
 @Override
 public void action(List<String> clusters) {
   for (String cluster : clusters) {
     if (!tableWatchers.containsKey(cluster)) {
       WatchChildren clusterWatcher =
           new WatchChildren(_zk, ZookeeperPathConstants.getTablesPath(cluster))
               .watch(new Tables(cluster));
       tableWatchers.put(cluster, clusterWatcher);
       WatchNodeExistance watchNodeExistance =
           new WatchNodeExistance(_zk, ZookeeperPathConstants.getSafemodePath(cluster))
               .watch(new SafeExistance(cluster));
       safeModeWatchers.put(cluster, watchNodeExistance);
     }
   }
   List<String> clustersToCloseAndRemove = new ArrayList<String>(clusters);
   clustersToCloseAndRemove.removeAll(tableWatchers.keySet());
   for (String cluster : clustersToCloseAndRemove) {
     WatchChildren watcher = tableWatchers.remove(cluster);
     if (watcher == null) {
       LOG.error("Error watcher is null [" + cluster + "] ");
     } else {
       watcher.close();
     }
   }
 }
コード例 #2
0
 @Override
 public List<String> getTableList(String cluster) {
   LOG.debug("trace getTableList");
   try {
     return _zk.getChildren(ZookeeperPathConstants.getTablesPath(cluster), false);
   } catch (KeeperException e) {
     throw new RuntimeException(e);
   } catch (InterruptedException e) {
     throw new RuntimeException(e);
   }
 }