@PostConstruct
 public void start() throws Exception {
   handler = new RemotePoolManagerHandler(new CellAddressCore(serviceName));
   cache = new PathChildrenCache(client, getZooKeeperPath(), true);
   cache.getListenable().addListener(this);
   cache.start();
 }
 Map<String, HostAndPort> cores() {
   return cores
       .getCurrentData()
       .stream()
       .collect(
           toMap(d -> ZKPaths.getNodeFromPath(d.getPath()), d -> toHostAndPort(d.getData())));
 }
 private void rebuildHandler() {
   List<CellAddressCore> backends =
       cache
           .getCurrentData()
           .stream()
           .map(ChildData::getPath)
           .map(ZKPaths::getNodeFromPath)
           .map(CellAddressCore::new)
           .collect(toList());
   SerializablePoolManagerHandler handler;
   if (backends.isEmpty()) {
     handler = new RemotePoolManagerHandler(new CellAddressCore(serviceName));
   } else if (backends.size() == 1) {
     handler = new RemotePoolManagerHandler(backends.get(0));
   } else {
     handler = new RendezvousPoolManagerHandler(new CellAddressCore(serviceName), backends);
   }
   this.handler = handler;
   requests.stream().filter(requests::remove).forEach(r -> r.send(handler));
 }
 void onChange(Consumer<PathChildrenCacheEvent> consumer) {
   cores.getListenable().addListener((client, event) -> consumer.accept(event));
 }
 HostAndPort readAddressOf(String domainName) {
   ChildData data = cores.getCurrentData(pathOf(domainName));
   return (data == null) ? null : toHostAndPort(data.getData());
 }
 void start() throws Exception {
   cores.start();
 }
 @PreDestroy
 public void stop() throws IOException {
   if (cache != null) {
     cache.close();
   }
 }