• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java EnsembleProvider类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.curator.ensemble.EnsembleProvider的典型用法代码示例。如果您正苦于以下问题:Java EnsembleProvider类的具体用法?Java EnsembleProvider怎么用?Java EnsembleProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



EnsembleProvider类属于org.apache.curator.ensemble包,在下文中一共展示了EnsembleProvider类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: initializeCurator

import org.apache.curator.ensemble.EnsembleProvider; //导入依赖的package包/类
private Completable initializeCurator()
{
    // Create/start CuratorFramework client
    RetryPolicy retryPolicy = new BoundedExponentialBackoffRetry(retryBaseTime, retryMaxTime, retryLimit);
    EnsembleProvider ensembleProvider = new FixedEnsembleProvider(connectionString);
    curator = CuratorFrameworkFactory.builder()
        .ensembleProvider(ensembleProvider)
        .retryPolicy(retryPolicy)
        .namespace(namespace)
        .sessionTimeoutMs(sessionTimeout)
        .connectionTimeoutMs(connectionTimeout)
        .build();
    curator.start();

    // Create a NodeCache for each config descriptor
    // This creates N node caches at a time on the RxJava IO scheduler thread pool.
    return Observable.from(configDescriptors)
        .flatMap(desc -> buildNodeCache(desc)
            .subscribeOn(Schedulers.io())
            .map(nc -> this.configNodeCaches.put(desc, nc)), getConcurrentNodeCacheCreations())
        .toCompletable();
}
 
开发者ID:kikinteractive,项目名称:ice,代码行数:23,代码来源:ZooKeeperDynamicConfigSource.java


示例2: instance_BindingOptionalsWithExhibitor_UsesParametersInExhibitorInstance

import org.apache.curator.ensemble.EnsembleProvider; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void instance_BindingOptionalsWithExhibitor_UsesParametersInExhibitorInstance() throws Exception {
    Injector inj = Guice.createInjector(module, new AbstractModule() {
        @Override
        protected void configure() {
            bindConstant().annotatedWith(Names.named("Cultivar.zookeeper.connectionString")).to("localhost:2181");
            bindConstant().annotatedWith(Names.named("Cultivar.zookeeper.exhibitorString")).to("localhost");
            bindConstant().annotatedWith(Names.named("Cultivar.properties.exhibitor.pollingTimeMillis")).to(1000);
            bindConstant().annotatedWith(Names.named("Cultivar.properties.exhibitor.restPath")).to("/exhibitor");
            bindConstant().annotatedWith(Names.named("Cultivar.properties.exhibitor.restPort")).to(8081);

            bind(ExhibitorRestClient.class).toInstance(client);
            bind(RetryPolicy.class).annotatedWith(Names.named("Cultivar.properties.exhibitor.retryPolicy"))
                    .toInstance(new RetryNTimes(RETRY_NUMBER, 1));
        }
    });

    ExhibitorEnsembleProvider provider = (ExhibitorEnsembleProvider) inj.getInstance(EnsembleProvider.class);

    provider.pollForInitialEnsemble();

    verify(client, times(RETRY_NUMBER + 1)).getRaw(eq("localhost"), eq(8081), eq("/exhibitor"), anyString());
    verifyNoMoreInteractions(client);
}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:26,代码来源:EnsembleProviderIntegTest.java


示例3: configure

import org.apache.curator.ensemble.EnsembleProvider; //导入依赖的package包/类
@Override
protected void configure() {
    if (dependencies != null) {
        install(dependencies);
    }

    requireBinding(Key.get(EnsembleProvider.class, annotation));
    requireBinding(Key.get(RetryPolicy.class, annotation));

    bind(CuratorFramework.class).annotatedWith(annotation).toProvider(CuratorFrameworkProvider.class)
            .in(Singleton.class);

    bind(CuratorManagementService.class).annotatedWith(annotation).to(DefaultCuratorManagementService.class)
            .in(Singleton.class);

    expose(Key.get(CuratorFramework.class, annotation));
    expose(Key.get(CuratorManagementService.class, annotation));
}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:19,代码来源:CuratorInnerModule.java


示例4: configure

import org.apache.curator.ensemble.EnsembleProvider; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected void configure() {

    bind(
            (Key<Optional<String>>) Key.get(Types.newParameterizedType(Optional.class, String.class),
                    Names.named("Cultivar.private.properties.backupConnections"))).toProvider(
            ConnectionProvider.class);

    bind(
            (Key<Optional<String>>) Key.get(Types.newParameterizedType(Optional.class, String.class),
                    Names.named("Cultivar.private.properties.exhibitorInstances"))).toProvider(
            ExhibitorProvider.class);

    bind(EnsembleProvider.class).toProvider(EnsembleProviderProvider.class).in(Singleton.class);

    expose(EnsembleProvider.class);
}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:19,代码来源:EnsembleProviderModule.java


示例5: CuratorZookeeperClient

import org.apache.curator.ensemble.EnsembleProvider; //导入依赖的package包/类
/**
 * @param zookeeperFactory factory for creating {@link ZooKeeper} instances
 * @param ensembleProvider the ensemble provider
 * @param sessionTimeoutMs session timeout
 * @param connectionTimeoutMs connection timeout
 * @param watcher default watcher or null
 * @param retryPolicy the retry policy to use
 * @param canBeReadOnly if true, allow ZooKeeper client to enter
 *                      read only mode in case of a network partition. See
 *                      {@link ZooKeeper#ZooKeeper(String, int, Watcher, long, byte[], boolean)}
 *                      for details
 * @param connectionHandlingPolicy connection handling policy - use one of the pre-defined policies or write your own
 * @since 3.0.0
 */
public CuratorZookeeperClient(ZookeeperFactory zookeeperFactory, EnsembleProvider ensembleProvider, int sessionTimeoutMs, int connectionTimeoutMs, Watcher watcher, RetryPolicy retryPolicy, boolean canBeReadOnly, ConnectionHandlingPolicy connectionHandlingPolicy)
{
    this.connectionHandlingPolicy = connectionHandlingPolicy;
    if ( sessionTimeoutMs < connectionTimeoutMs )
    {
        log.warn(String.format("session timeout [%d] is less than connection timeout [%d]", sessionTimeoutMs, connectionTimeoutMs));
    }

    retryPolicy = Preconditions.checkNotNull(retryPolicy, "retryPolicy cannot be null");
    ensembleProvider = Preconditions.checkNotNull(ensembleProvider, "ensembleProvider cannot be null");

    this.connectionTimeoutMs = connectionTimeoutMs;
    state = new ConnectionState(zookeeperFactory, ensembleProvider, sessionTimeoutMs, connectionTimeoutMs, watcher, tracer, canBeReadOnly, connectionHandlingPolicy);
    setRetryPolicy(retryPolicy);
}
 
开发者ID:apache,项目名称:curator,代码行数:30,代码来源:CuratorZookeeperClient.java


示例6: instance_BindingOptionalsWithExhibitor_UsesParametersInExhibitorInstance

import org.apache.curator.ensemble.EnsembleProvider; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void instance_BindingOptionalsWithExhibitor_UsesParametersInExhibitorInstance() throws Exception {
    Injector inj = Guice.createInjector(module, new AbstractModule() {
        @Override
        protected void configure() {
            bindConstant().annotatedWith(Names.named("Cultivar.zookeeper.connectionString")).to("localhost:2181");
            bindConstant().annotatedWith(Names.named("Cultivar.zookeeper.exhibitorString")).to("localhost");
            bindConstant().annotatedWith(Names.named("Cultivar.properties.exhibitor.pollingTimeMillis")).to(1000);
            bindConstant().annotatedWith(Names.named("Cultivar.properties.exhibitor.restPath")).to("/exhibitor");
            bindConstant().annotatedWith(Names.named("Cultivar.properties.exhibitor.restPort")).to(8081);

            bind(ExhibitorRestClient.class).toInstance(client);
            bind(RetryPolicy.class).annotatedWith(Names.named("Cultivar.properties.exhibitor.retryPolicy"))
                    .toInstance(new RetryNTimes(RETRY_NUMBER, 1));
        }
    });

    ExhibitorEnsembleProvider provider = (ExhibitorEnsembleProvider) inj.getInstance(Key.get(
            EnsembleProvider.class, Curator.class));

    provider.pollForInitialEnsemble();

    verify(client, times(RETRY_NUMBER + 1)).getRaw(eq("localhost"), eq(8081), eq("/exhibitor"), anyString());
    verifyNoMoreInteractions(client);
}
 
开发者ID:ReadyTalk,项目名称:cultivar,代码行数:27,代码来源:EnsembleProviderIntegTest.java


示例7: setUp

import org.apache.curator.ensemble.EnsembleProvider; //导入依赖的package包/类
@Before
public void setUp() throws Exception {

    Injector inj = Guice.createInjector(
            Stage.PRODUCTION,
            new CuratorModule(new AbstractModule() {
                @Override
                protected void configure() {
                    bindConstant().annotatedWith(Names.named("Cultivar.Curator.baseNamespace")).to("dev/test");

                    bind(EnsembleProvider.class).annotatedWith(Curator.class).toInstance(
                            new FixedEnsembleProvider(testingCluster.getConnectString()));
                    bind(RetryPolicy.class).annotatedWith(Curator.class).toInstance(
                            new ExponentialBackoffRetry(10, 10));

                }
            }), NamespaceModuleBuilder.create().newNamespace(null).targetAnnotation(Cultivar.class).build(),
            NamespaceModuleBuilder.create().newNamespace("foo").targetAnnotation(Names.named("foo")).build());

    manager = inj.getInstance(CultivarStartStopManager.class);

    namespacedNullFramework = inj.getInstance(Key.get(CuratorFramework.class, Cultivar.class));
    namespacedFooFramework = inj.getInstance(Key.get(CuratorFramework.class, Names.named("foo")));

    manager.startAsync().awaitRunning();
}
 
开发者ID:ReadyTalk,项目名称:cultivar,代码行数:27,代码来源:NamespaceModuleBuilderIntegTest.java


示例8: configure

import org.apache.curator.ensemble.EnsembleProvider; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected void configure() {

    bind(
            (Key<Optional<String>>) Key.get(Types.newParameterizedType(Optional.class, String.class),
                    Names.named("Cultivar.private.properties.backupConnections"))).toProvider(
            ConnectionProvider.class);

    bind(
            (Key<Optional<String>>) Key.get(Types.newParameterizedType(Optional.class, String.class),
                    Names.named("Cultivar.private.properties.exhibitorInstances"))).toProvider(
            ExhibitorProvider.class);

    bind(EnsembleProvider.class).annotatedWith(Curator.class).toProvider(EnsembleProviderProvider.class)
            .in(Singleton.class);

    expose(EnsembleProvider.class).annotatedWith(Curator.class);
}
 
开发者ID:ReadyTalk,项目名称:cultivar,代码行数:20,代码来源:EnsembleProviderModule.java


示例9: setUp

import org.apache.curator.ensemble.EnsembleProvider; //导入依赖的package包/类
@Before
public void setUp() throws Exception {

    inj = Guice.createInjector(
            new CuratorModule(new AbstractModule() {
                @Override
                protected void configure() {
                    bind(EnsembleProvider.class).annotatedWith(Curator.class).toInstance(
                            new FixedEnsembleProvider(testingCluster.getConnectString()));
                    bind(RetryPolicy.class).annotatedWith(Curator.class).toInstance(
                            new ExponentialBackoffRetry(1000, 3));

                }
            }),
            ServiceDiscoveryModuleBuilder.create().annotation(Curator.class).basePath("/discovery").build(),
            ServiceProviderModuleBuilder.create(Void.class).name("service").discovery(Curator.class)
                    .annotation(Cultivar.class).build());

    discovery = inj.getInstance(Key.get(new TypeLiteral<ServiceDiscovery<Void>>() {
    }, Curator.class));

    service1 = ServiceInstance.<Void> builder().name("service").build();

    service2 = ServiceInstance.<Void> builder().name("service").build();

    provider = inj.getInstance(Key.get(new TypeLiteral<ServiceProvider<Void>>() {
    }, Cultivar.class));

    manager = inj.getInstance(CultivarStartStopManager.class);

}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:32,代码来源:DiscoveryIntegTest.java


示例10: setUp

import org.apache.curator.ensemble.EnsembleProvider; //导入依赖的package包/类
@Before
public void setUp() throws Exception {

    inj = Guice.createInjector(new CuratorModule(new AbstractModule() {
        @Override
        protected void configure() {
            bind(EnsembleProvider.class).annotatedWith(Curator.class).toInstance(
                    new FixedEnsembleProvider(testingCluster.getConnectString()));
            bind(RetryPolicy.class).annotatedWith(Curator.class).toInstance(new ExponentialBackoffRetry(1000, 3));

        }
    }));

}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:15,代码来源:CuratorModuleIntegTest.java


示例11: instance_ConnectionProviderPropertyAndOverrideBound_SetsConnectionStringToOverride

import org.apache.curator.ensemble.EnsembleProvider; //导入依赖的package包/类
@Test
public void instance_ConnectionProviderPropertyAndOverrideBound_SetsConnectionStringToOverride() {
    Injector inj = Guice.createInjector(module, new AbstractModule() {
        @Override
        protected void configure() {
            bindConstant().annotatedWith(Names.named("Cultivar.zookeeper.connectionString")).to("localhost:2181");

        }
    });

    assertEquals("localhost:2181", inj.getInstance(EnsembleProvider.class).getConnectionString());
}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:13,代码来源:EnsembleProviderIntegTest.java


示例12: setUp

import org.apache.curator.ensemble.EnsembleProvider; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    Injector inj = Guice.createInjector(new CuratorModule(new AbstractModule() {
        @Override
        protected void configure() {
            bind(EnsembleProvider.class).annotatedWith(Curator.class).toInstance(
                    new FixedEnsembleProvider(testingCluster.getConnectString()));
            bind(RetryPolicy.class).annotatedWith(Curator.class).toInstance(new ExponentialBackoffRetry(1000, 3));

        }
    }));

    manager = inj.getInstance(CultivarStartStopManager.class);

    CuratorManagementService managementService = inj.getInstance(Key.get(CuratorManagementService.class,
            Curator.class));

    managementService.addConnectionListener(new ConnectionStateListener() {
        @Override
        public void stateChanged(final CuratorFramework client, final ConnectionState newState) {
            if (ConnectionState.CONNECTED.equals(newState)) {
                connectionLatch.countDown();
            }

        }
    });

    state = inj.getInstance(LastKnownState.class);

    manager.startAsync().awaitRunning();
}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:32,代码来源:LastKnownStateIntegTest.java


示例13: setUp

import org.apache.curator.ensemble.EnsembleProvider; //导入依赖的package包/类
@Before
public void setUp() throws Exception {

    Injector inj1 = Guice.createInjector(Stage.PRODUCTION, new CuratorModule(new AbstractModule() {
        @Override
        protected void configure() {
            bind(EnsembleProvider.class).annotatedWith(Curator.class).toInstance(
                    new FixedEnsembleProvider(testingCluster.getConnectString()));
            bind(RetryPolicy.class).annotatedWith(Curator.class).toInstance(new RetryNTimes(10, 100));

        }
    }));

    Injector inj2 = Guice.createInjector(Stage.PRODUCTION, new CuratorModule(new AbstractModule() {
        @Override
        protected void configure() {
            bind(EnsembleProvider.class).annotatedWith(Curator.class).toInstance(
                    new FixedEnsembleProvider(testingCluster.getConnectString()));
            bind(RetryPolicy.class).annotatedWith(Curator.class).toInstance(new RetryNTimes(10, 100));

        }
    }));

    manager1 = inj1.getInstance(CultivarStartStopManager.class);
    manager2 = inj2.getInstance(CultivarStartStopManager.class);

    manager1.startAsync();
    manager2.startAsync();

    manager1.awaitRunning();
    manager2.awaitRunning();

    DistributedBarrierFactory factory1 = inj1.getInstance(DistributedBarrierFactory.class);
    DistributedBarrierFactory factory2 = inj2.getInstance(DistributedBarrierFactory.class);

    barrierA1 = factory1.create("/test");
    barrierA2 = factory2.create("/test");
}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:39,代码来源:DistributedBarrierIntegTest.java


示例14: setUp

import org.apache.curator.ensemble.EnsembleProvider; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    LOG.info("*** SERVERS *** {}", testingCluster.getConnectString());

    Injector inj1 = Guice.createInjector(Stage.PRODUCTION, new CuratorModule(new AbstractModule() {
        @Override
        protected void configure() {
            bind(EnsembleProvider.class).annotatedWith(Curator.class).toInstance(
                    new FixedEnsembleProvider(testingCluster.getConnectString()));
            bind(RetryPolicy.class).annotatedWith(Curator.class).toInstance(new RetryNTimes(10, 10));

        }
    }));

    Injector inj2 = Guice.createInjector(Stage.PRODUCTION, new CuratorModule(new AbstractModule() {
        @Override
        protected void configure() {
            bind(EnsembleProvider.class).annotatedWith(Curator.class).toInstance(
                    new FixedEnsembleProvider(testingCluster.getConnectString()));
            bind(RetryPolicy.class).annotatedWith(Curator.class).toInstance(new RetryNTimes(10, 10));

        }
    }));

    manager1 = inj1.getInstance(CultivarStartStopManager.class);
    manager2 = inj2.getInstance(CultivarStartStopManager.class);

    manager1.startAsync();
    manager2.startAsync();

    manager1.awaitRunning();
    manager2.awaitRunning();

    DistributedDoubleBarrierFactory factory1 = inj1.getInstance(DistributedDoubleBarrierFactory.class);
    DistributedDoubleBarrierFactory factory2 = inj2.getInstance(DistributedDoubleBarrierFactory.class);

    barrierA1 = factory1.create("/test", 2);
    barrierA2 = factory2.create("/test", 2);
}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:40,代码来源:DistributedDoubleBarrierIntegTest.java


示例15: get

import org.apache.curator.ensemble.EnsembleProvider; //导入依赖的package包/类
@Override
public EnsembleProvider get() {

    if (exhibitorInstances.isPresent()) {
        return exhibitorEnsembleProvider();
    }

    return new FixedEnsembleProvider(backupConnections.get());
}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:10,代码来源:EnsembleProviderProvider.java


示例16: get_ExhibitorNotPresent_ReturnsFixedEnsembleWithConnectionString

import org.apache.curator.ensemble.EnsembleProvider; //导入依赖的package包/类
@Test
public void get_ExhibitorNotPresent_ReturnsFixedEnsembleWithConnectionString() {
    String conn = "localhost:2181";

    EnsembleProviderProvider provider = new EnsembleProviderProvider(Optional.<String> absent(), Optional.of(conn));

    EnsembleProvider ensembleProvider = provider.get();

    assertTrue(ensembleProvider instanceof FixedEnsembleProvider);
    assertEquals(conn, ensembleProvider.getConnectionString());
}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:12,代码来源:EnsembleProviderProviderTest.java


示例17: get_ExhibitorPresentWithBackup_ReturnsExhbitorEnsembleProvider

import org.apache.curator.ensemble.EnsembleProvider; //导入依赖的package包/类
@Test
public void get_ExhibitorPresentWithBackup_ReturnsExhbitorEnsembleProvider() {
    String conn = "localhost:2181";
    String exhbitor = "exhibitor:2181";

    EnsembleProviderProvider provider = new EnsembleProviderProvider(Optional.of(exhbitor), Optional.of(conn));

    EnsembleProvider ensembleProvider = provider.get();

    assertTrue(ensembleProvider instanceof ExhibitorEnsembleProvider);
}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:12,代码来源:EnsembleProviderProviderTest.java


示例18: setUp

import org.apache.curator.ensemble.EnsembleProvider; //导入依赖的package包/类
@Before
public void setUp() {
    dependencies = new AbstractModule() {
        @Override
        protected void configure() {
            bind(EnsembleProvider.class).annotatedWith(Curator.class).toInstance(ensembleProvider);
            bind(RetryPolicy.class).annotatedWith(Curator.class).toInstance(retryPolicy);

        }
    };
}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:12,代码来源:CuratorModuleTest.java


示例19: ConnectionState

import org.apache.curator.ensemble.EnsembleProvider; //导入依赖的package包/类
ConnectionState(ZookeeperFactory zookeeperFactory, EnsembleProvider ensembleProvider, int sessionTimeoutMs, int connectionTimeoutMs, Watcher parentWatcher, AtomicReference<TracerDriver> tracer, boolean canBeReadOnly, ConnectionHandlingPolicy connectionHandlingPolicy)
{
    this.ensembleProvider = ensembleProvider;
    this.sessionTimeoutMs = sessionTimeoutMs;
    this.connectionTimeoutMs = connectionTimeoutMs;
    this.tracer = tracer;
    this.connectionHandlingPolicy = connectionHandlingPolicy;
    if ( parentWatcher != null )
    {
        parentWatchers.offer(parentWatcher);
    }

    zooKeeper = new HandleHolder(zookeeperFactory, this, ensembleProvider, sessionTimeoutMs, canBeReadOnly);
}
 
开发者ID:apache,项目名称:curator,代码行数:15,代码来源:ConnectionState.java


示例20: HandleHolder

import org.apache.curator.ensemble.EnsembleProvider; //导入依赖的package包/类
HandleHolder(ZookeeperFactory zookeeperFactory, Watcher watcher, EnsembleProvider ensembleProvider, int sessionTimeout, boolean canBeReadOnly)
{
    this.zookeeperFactory = zookeeperFactory;
    this.watcher = watcher;
    this.ensembleProvider = ensembleProvider;
    this.sessionTimeout = sessionTimeout;
    this.canBeReadOnly = canBeReadOnly;
}
 
开发者ID:apache,项目名称:curator,代码行数:9,代码来源:HandleHolder.java



注:本文中的org.apache.curator.ensemble.EnsembleProvider类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DependencyFilterUtils类代码示例发布时间:2022-05-21
下一篇:
Java ObjectUtilities类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap