/** * Starts the tracking of online FServers. * * <p> * All RSs will be tracked after this method is called. * * @throws org.apache.zookeeper.KeeperException * @throws java.io.IOException */ public void start() throws KeeperException, IOException { watcher.registerListener(this); List<String> servers = ZKUtil.listChildrenAndWatchThem(watcher, watcher.fsZNode); add(servers); }
@Override public void nodeDeleted(String path) { if (path.startsWith(watcher.fsZNode)) { String serverName = ZKUtil.getNodeName(path); LOG.info("FServer ephemeral node deleted, processing expiration [" + serverName + "]"); ServerName sn = ServerName.parseServerName(serverName); if (!serverManager.isServerOnline(sn)) { LOG.warn(serverName.toString() + " is not online or isn't known to the master." + "The latter could be caused by a DNS misconfiguration."); return; } remove(sn); this.serverManager.expireServer(sn); } }
zooKeeper.registerListenerFirst(assignmentManager); this.fserverTracker = new FServerTracker(zooKeeper, this, this.serverManager); this.fserverTracker.start();
for (ServerName sn : this.fserverTracker.getOnlineServers()) { if (!this.serverManager.isServerOnline(sn)) {
@Override public void nodeChildrenChanged(String path) { if (path.equals(watcher.fsZNode)) { try { List<String> servers = ZKUtil.listChildrenAndWatchThem(watcher, watcher.fsZNode); add(servers); } catch (IOException e) { abortable.abort("Unexpected zk exception getting RS nodes", e); } catch (KeeperException e) { abortable.abort("Unexpected zk exception getting RS nodes", e); } } }