void setLocalAddress(HostAndPort address) throws Exception {
   if (local == null) {
     PersistentNode node =
         new PersistentNode(
             client, CreateMode.EPHEMERAL, false, pathOf(domainName), toBytes(address));
     node.start();
     local = node;
   } else {
     local.setData(toBytes(address));
   }
 }
 @Override
 public void afterStart() {
   String path = ZKPaths.makePath(getZooKeeperPath(), address.toString());
   byte[] data = address.toString().getBytes(US_ASCII);
   node = new PersistentNode(client, CreateMode.EPHEMERAL, false, path, data);
   node.start();
 }
 HostAndPort getLocalAddress() {
   return (local == null) ? null : toHostAndPort(local.getData());
 }