use of org.apache.curator.ensemble.EnsembleProvider in project druid by druid-io.
the class CuratorModuleTest method fixedZkHosts.
@Test
public void fixedZkHosts() {
Properties props = new Properties();
props.put(curatorHostKey, "hostA");
Injector injector = newInjector(props);
// initialize related components
injector.getInstance(CuratorFramework.class);
EnsembleProvider ensembleProvider = injector.getInstance(EnsembleProvider.class);
Assert.assertTrue("EnsembleProvider should be FixedEnsembleProvider", ensembleProvider instanceof FixedEnsembleProvider);
Assert.assertEquals("The connectionString should be 'hostA'", "hostA", ensembleProvider.getConnectionString());
}
use of org.apache.curator.ensemble.EnsembleProvider in project nakadi by zalando.
the class ZooKeeperHolder method initExhibitor.
private void initExhibitor() throws Exception {
final RetryPolicy retryPolicy = new ExponentialBackoffRetry(EXHIBITOR_RETRY_TIME, EXHIBITOR_RETRY_MAX);
final EnsembleProvider ensembleProvider;
if (exhibitorAddresses != null) {
final Collection<String> exhibitorHosts = Arrays.asList(exhibitorAddresses.split("\\s*,\\s*"));
final Exhibitors exhibitors = new Exhibitors(exhibitorHosts, exhibitorPort, () -> zookeeperBrokers + zookeeperKafkaNamespace);
final ExhibitorRestClient exhibitorRestClient = new DefaultExhibitorRestClient();
ensembleProvider = new ExhibitorEnsembleProvider(exhibitors, exhibitorRestClient, "/exhibitor/v1/cluster/list", EXHIBITOR_POLLING_MS, retryPolicy);
((ExhibitorEnsembleProvider) ensembleProvider).pollForInitialEnsemble();
} else {
ensembleProvider = new FixedEnsembleProvider(zookeeperBrokers + zookeeperKafkaNamespace);
}
zooKeeper = CuratorFrameworkFactory.builder().ensembleProvider(ensembleProvider).retryPolicy(retryPolicy).build();
zooKeeper.start();
}
use of org.apache.curator.ensemble.EnsembleProvider in project druid by druid-io.
the class CuratorModuleTest method emptyExhibitorHosts.
@Test
public void emptyExhibitorHosts() {
Properties props = new Properties();
props.setProperty(CURATOR_HOST_KEY, "hostB");
props.setProperty(EXHIBITOR_HOSTS_KEY, "[]");
Injector injector = newInjector(props);
// initialize related components
injector.getInstance(CuratorFramework.class);
EnsembleProvider ensembleProvider = injector.getInstance(EnsembleProvider.class);
Assert.assertTrue("EnsembleProvider should be FixedEnsembleProvider", ensembleProvider instanceof FixedEnsembleProvider);
Assert.assertEquals("The connectionString should be 'hostB'", "hostB", ensembleProvider.getConnectionString());
}
use of org.apache.curator.ensemble.EnsembleProvider in project druid by druid-io.
the class CuratorModuleTest method fixedZkHosts.
@Test
public void fixedZkHosts() {
Properties props = new Properties();
props.setProperty(CURATOR_HOST_KEY, "hostA");
Injector injector = newInjector(props);
// initialize related components
injector.getInstance(CuratorFramework.class);
EnsembleProvider ensembleProvider = injector.getInstance(EnsembleProvider.class);
Assert.assertTrue("EnsembleProvider should be FixedEnsembleProvider", ensembleProvider instanceof FixedEnsembleProvider);
Assert.assertEquals("The connectionString should be 'hostA'", "hostA", ensembleProvider.getConnectionString());
}
use of org.apache.curator.ensemble.EnsembleProvider in project druid by druid-io.
the class CuratorModuleTest method defaultEnsembleProvider.
@Test
public void defaultEnsembleProvider() {
Injector injector = newInjector(new Properties());
// initialize related components
injector.getInstance(CuratorFramework.class);
EnsembleProvider ensembleProvider = injector.getInstance(EnsembleProvider.class);
Assert.assertTrue("EnsembleProvider should be FixedEnsembleProvider", ensembleProvider instanceof FixedEnsembleProvider);
Assert.assertEquals("The connectionString should be 'localhost'", "localhost", ensembleProvider.getConnectionString());
}
Aggregations