@Override public Host getHostByAddress(PartitionServerAddress address) { for (ZkHost host : hosts.values()) { if (host.getAddress().equals(address)) { return host; } } return null; }
@Override public boolean removeHost(PartitionServerAddress address) throws IOException { for (Map.Entry<String, ZkHost> entry : hosts.entrySet()) { if (entry.getValue().getAddress().equals(address)) { ZkHost host = hosts.remove(entry.getKey()); host.delete(); fireDataLocationChangeListener(); return true; } } return false; }
@Override public Host addHost(PartitionServerAddress address, List<String> flags) throws IOException { try { return ZkHost.create( zk, coordinator, ZkPath.append(ringPath, HOSTS_PATH_SEGMENT), address, dataLocationChangeListener, flags); } catch (Exception e) { throw new IOException(e); } }
public void close() { for (Host host : getHosts()) { ((ZkHost) host).close(); } }