zkRegistrar = ZooKeeperRegistrarService.newBuilder() .setZooKeeperClient(client) .setZooKeeperRegistrar(new MasterZooKeeperRegistrar(config.getName())) .build();
/** * Create a Zookeeper client and create the control and state nodes if needed. * * @param config The service configuration. * @return A zookeeper client. */ private ZooKeeperClient setupZookeeperClient(final MasterConfig config) { final RetryPolicy zooKeeperRetryPolicy = new ExponentialBackoffRetry(1000, 3); final CuratorFramework curator = curatorClientFactory.newClient( config.getZooKeeperConnectionString(), config.getZooKeeperSessionTimeoutMillis(), config.getZooKeeperConnectionTimeoutMillis(), zooKeeperRetryPolicy, config.getZooKeeperNamespace()); final ZooKeeperClient client = new DefaultZooKeeperClient(curator, config.getZooKeeperClusterId()); client.start(); zkRegistrar = new ZooKeeperRegistrar(client, new MasterZooKeeperRegistrar(config.getName())); return client; } }