/** * Get the address of the current master if one is available. Returns null if * no current master. * * @return Server name or null if timed out. */ public ServerName getMasterAddress() { return getMasterAddress(false); }
sb.append("\nActive master address: "); try { sb.append(MasterAddressTracker.getMasterAddress(zkw)); } catch (IOException e) { sb.append("<<FAILED LOOKUP: " + e.getMessage() + ">>");
public void stop() { try { // If our address is in ZK, delete it on our way out ServerName activeMaster = null; try { activeMaster = MasterAddressTracker.getMasterAddress(this.watcher); } catch (IOException e) { LOG.warn("Failed get of master address: " + e.toString()); } if (activeMaster != null && activeMaster.equals(this.sn)) { ZKUtil.deleteNode(watcher, watcher.getMasterAddressZNode()); // We may have failed to delete the znode at the previous step, but // we delete the file anyway: a second attempt to delete the znode is // likely to fail again. ZNodeClearer.deleteMyEphemeralNodeOnDisk(); } } catch (KeeperException e) { LOG.error( this.watcher.prefix("Error deleting our own master address node"), e); } } }
FServerStatusProtocol master = null; while (keepLooping() && master == null) { masterServerName = this.masterAddressManager.getMasterAddress(); if (masterServerName == null) { if (!keepLooping()) { + this.masterAddressManager.getMasterAddress()); try {
/** * Assert there is an active master and that it has the specified address. * @param zk * @param thisMasterAddress * @throws org.apache.zookeeper.KeeperException * @throws java.io.IOException */ private void assertMaster(ZooKeeperWatcher zk, ServerName expectedAddress) throws KeeperException, IOException { ServerName readAddress = MasterAddressTracker.getMasterAddress(zk); assertNotNull(readAddress); assertTrue(expectedAddress.equals(readAddress)); }
ServerName sn = MasterAddressTracker.getMasterAddress(zkw); if (sn == null) { String msg = "ZooKeeper available but no active master location found";