code: private CloseableDataStore createDataStoreWithHostDiscovery(final URI location, String apiKey, MetricRegistry metricRegistry) {
          // Get the service factory for this cluster.
          String cluster = LocationUtil.getClusterForLocation(location);
          MultiThreadedServiceFactory<AuthDataStore> dataStoreFactory = createDataStoreServiceFactory(cluster, metricRegistry);
  
          // If the host discovery uses ZooKeeper -- that is, it doesn't used fixed hosts -- create a Curator for it.
          final Optional<CuratorFramework> curator = LocationUtil.getCuratorForLocation(location);
          HostDiscovery hostDiscovery = LocationUtil.getHostDiscoveryForLocation(location, curator, dataStoreFactory.getServiceName(), metricRegistry);
  
          final AuthDataStore authDataStore = ServicePoolBuilder.create(AuthDataStore.class)
                  .withHostDiscovery(hostDiscovery)
                  .withServiceFactory(dataStoreFactory)
                  .withCachingPolicy(ServiceCachingPolicyBuilder.getMultiThreadedClientPolicy())
                  .withMetricRegistry(metricRegistry)
                  .buildProxy(new ExponentialBackoffRetry(5, 50, 1000, TimeUnit.MILLISECONDS));
  
          // Set the CloseableDataStore's close() method to close the service pool proxy and, if it was required, the curator.
          Runnable onClose = new Runnable() {
              @Override
              public void run() {
                  _log.info("Closing service pool and ZooKeeper connection for {}", location);
                  ServicePoolProxies.close(authDataStore);
                  if (curator.isPresent()) {
                      try {
                          Closeables.close(curator.get(), true);
                      } catch (IOException e) {
                          // Won't happen, already caught
                      }
                  }
              }
          };
  
          DataStore dataStore = DataStoreAuthenticator.proxied(authDataStore).usingCredentials(apiKey);
          return asCloseableDataStore(dataStore, Optional.of(onClose));
      }
docs: Creates a DataStore using host discovery (ZooKeeper and Ostrich).