Search in sources :

Example 1 with ExhibitorRestClient

use of org.apache.curator.ensemble.exhibitor.ExhibitorRestClient 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();
}
Also used : ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) Exhibitors(org.apache.curator.ensemble.exhibitor.Exhibitors) DefaultExhibitorRestClient(org.apache.curator.ensemble.exhibitor.DefaultExhibitorRestClient) ExhibitorRestClient(org.apache.curator.ensemble.exhibitor.ExhibitorRestClient) DefaultExhibitorRestClient(org.apache.curator.ensemble.exhibitor.DefaultExhibitorRestClient) RetryPolicy(org.apache.curator.RetryPolicy) FixedEnsembleProvider(org.apache.curator.ensemble.fixed.FixedEnsembleProvider) FixedEnsembleProvider(org.apache.curator.ensemble.fixed.FixedEnsembleProvider) EnsembleProvider(org.apache.curator.ensemble.EnsembleProvider)

Aggregations

RetryPolicy (org.apache.curator.RetryPolicy)1 EnsembleProvider (org.apache.curator.ensemble.EnsembleProvider)1 DefaultExhibitorRestClient (org.apache.curator.ensemble.exhibitor.DefaultExhibitorRestClient)1 ExhibitorRestClient (org.apache.curator.ensemble.exhibitor.ExhibitorRestClient)1 Exhibitors (org.apache.curator.ensemble.exhibitor.Exhibitors)1 FixedEnsembleProvider (org.apache.curator.ensemble.fixed.FixedEnsembleProvider)1 ExponentialBackoffRetry (org.apache.curator.retry.ExponentialBackoffRetry)1