@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(); } } }
public void close() { _running.set(false); clusterWatch.close(); }