Search in sources :

Example 6 with ExhibitorEnsembleProvider

use of org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider in project druid by druid-io.

the class CuratorModuleTest method exhibitorEnsembleProvider.

@Test
public void exhibitorEnsembleProvider() {
    Properties props = new Properties();
    props.put(curatorHostKey, "hostA");
    props.put(exhibitorHostsKey, "[\"hostB\"]");
    Injector injector = newInjector(props);
    // initialize related components
    injector.getInstance(CuratorFramework.class);
    EnsembleProvider ensembleProvider = injector.getInstance(EnsembleProvider.class);
    Assert.assertTrue("EnsembleProvider should be ExhibitorEnsembleProvider", ensembleProvider instanceof ExhibitorEnsembleProvider);
}
Also used : Injector(com.google.inject.Injector) ExhibitorEnsembleProvider(org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider) Properties(java.util.Properties) ExhibitorEnsembleProvider(org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider) EnsembleProvider(org.apache.curator.ensemble.EnsembleProvider) FixedEnsembleProvider(org.apache.curator.ensemble.fixed.FixedEnsembleProvider) Test(org.junit.Test)

Example 7 with ExhibitorEnsembleProvider

use of org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider in project druid by druid-io.

the class CuratorModule method makeEnsembleProvider.

@Provides
@LazySingleton
public EnsembleProvider makeEnsembleProvider(CuratorConfig config, ExhibitorConfig exConfig) {
    if (exConfig.getHosts().isEmpty()) {
        return new FixedEnsembleProvider(config.getZkHosts());
    }
    return new ExhibitorEnsembleProvider(new Exhibitors(exConfig.getHosts(), exConfig.getRestPort(), newBackupProvider(config.getZkHosts())), new DefaultExhibitorRestClient(exConfig.getUseSsl()), exConfig.getRestUriPath(), exConfig.getPollingMs(), new BoundedExponentialBackoffRetry(BASE_SLEEP_TIME_MS, MAX_SLEEP_TIME_MS, MAX_RETRIES)) {

        @Override
        public void start() throws Exception {
            log.info("Poll the list of zookeeper servers for initial ensemble");
            this.pollForInitialEnsemble();
            super.start();
        }
    };
}
Also used : Exhibitors(org.apache.curator.ensemble.exhibitor.Exhibitors) DefaultExhibitorRestClient(org.apache.curator.ensemble.exhibitor.DefaultExhibitorRestClient) ExhibitorEnsembleProvider(org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider) FixedEnsembleProvider(org.apache.curator.ensemble.fixed.FixedEnsembleProvider) BoundedExponentialBackoffRetry(org.apache.curator.retry.BoundedExponentialBackoffRetry) LazySingleton(io.druid.guice.LazySingleton) Provides(com.google.inject.Provides)

Example 8 with ExhibitorEnsembleProvider

use of org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider in project druid by druid-io.

the class CuratorModule method makeEnsembleProvider.

@Provides
@LazySingleton
public EnsembleProvider makeEnsembleProvider(CuratorConfig config, ExhibitorConfig exConfig) {
    if (exConfig.getHosts().isEmpty()) {
        return new FixedEnsembleProvider(config.getZkHosts());
    }
    RetryPolicy retryPolicy = new BoundedExponentialBackoffRetry(BASE_SLEEP_TIME_MS, MAX_SLEEP_TIME_MS, MAX_RETRIES);
    return new ExhibitorEnsembleProvider(new Exhibitors(exConfig.getHosts(), exConfig.getRestPort(), newBackupProvider(config.getZkHosts())), new DefaultExhibitorRestClient(exConfig.getUseSsl()), exConfig.getRestUriPath(), exConfig.getPollingMs(), retryPolicy) {

        @Override
        public void start() throws Exception {
            log.debug("Polling the list of ZooKeeper servers for the initial ensemble");
            this.pollForInitialEnsemble();
            super.start();
        }
    };
}
Also used : Exhibitors(org.apache.curator.ensemble.exhibitor.Exhibitors) DefaultExhibitorRestClient(org.apache.curator.ensemble.exhibitor.DefaultExhibitorRestClient) ExhibitorEnsembleProvider(org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider) RetryPolicy(org.apache.curator.RetryPolicy) FixedEnsembleProvider(org.apache.curator.ensemble.fixed.FixedEnsembleProvider) BoundedExponentialBackoffRetry(org.apache.curator.retry.BoundedExponentialBackoffRetry) LazySingleton(org.apache.druid.guice.LazySingleton) Provides(com.google.inject.Provides)

Example 9 with ExhibitorEnsembleProvider

use of org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider in project druid by apache.

the class CuratorModuleTest method exhibitorEnsembleProvider.

@Test
public void exhibitorEnsembleProvider() {
    Properties props = new Properties();
    props.setProperty(CURATOR_HOST_KEY, "hostA");
    props.setProperty(EXHIBITOR_HOSTS_KEY, "[\"hostB\"]");
    Injector injector = newInjector(props);
    // initialize related components
    injector.getInstance(CuratorFramework.class);
    EnsembleProvider ensembleProvider = injector.getInstance(EnsembleProvider.class);
    Assert.assertTrue("EnsembleProvider should be ExhibitorEnsembleProvider", ensembleProvider instanceof ExhibitorEnsembleProvider);
}
Also used : Injector(com.google.inject.Injector) ExhibitorEnsembleProvider(org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider) Properties(java.util.Properties) ExhibitorEnsembleProvider(org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider) EnsembleProvider(org.apache.curator.ensemble.EnsembleProvider) FixedEnsembleProvider(org.apache.curator.ensemble.fixed.FixedEnsembleProvider) Test(org.junit.Test)

Aggregations

ExhibitorEnsembleProvider (org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider)9 FixedEnsembleProvider (org.apache.curator.ensemble.fixed.FixedEnsembleProvider)6 DefaultExhibitorRestClient (org.apache.curator.ensemble.exhibitor.DefaultExhibitorRestClient)5 Exhibitors (org.apache.curator.ensemble.exhibitor.Exhibitors)5 Injector (com.google.inject.Injector)3 Provides (com.google.inject.Provides)3 Properties (java.util.Properties)3 EnsembleProvider (org.apache.curator.ensemble.EnsembleProvider)3 BoundedExponentialBackoffRetry (org.apache.curator.retry.BoundedExponentialBackoffRetry)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 RetryPolicy (org.apache.curator.RetryPolicy)2 ExponentialBackoffRetry (org.apache.curator.retry.ExponentialBackoffRetry)2 LazySingleton (org.apache.druid.guice.LazySingleton)2 BootstrapException (com.kixeye.chassis.bootstrap.BootstrapException)1 LazySingleton (io.druid.guice.LazySingleton)1 FileNotFoundException (java.io.FileNotFoundException)1 UnknownHostException (java.net.UnknownHostException)1 ExecuteException (org.apache.commons.exec.ExecuteException)1 CuratorFramework (org.apache.curator.framework.CuratorFramework)1