当前位置: 首页>>代码示例>>Java>>正文


Java FixedEnsembleProvider类代码示例

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


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

示例1: initializeCurator

import org.apache.curator.ensemble.fixed.FixedEnsembleProvider; //导入依赖的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: testFactory

import org.apache.curator.ensemble.fixed.FixedEnsembleProvider; //导入依赖的package包/类
@Test
public void     testFactory() throws Exception
{
    final ZooKeeper         mockZookeeper = Mockito.mock(ZooKeeper.class);
    ZookeeperFactory        zookeeperFactory = new ZookeeperFactory()
    {
        @Override
        public ZooKeeper newZooKeeper(String connectString, int sessionTimeout, Watcher watcher, boolean canBeReadOnly) throws Exception
        {
            return mockZookeeper;
        }
    };
    CuratorZookeeperClient  client = new CuratorZookeeperClient(zookeeperFactory, new FixedEnsembleProvider(server.getConnectString()), 10000, 10000, null, new RetryOneTime(1), false);
    client.start();
    Assert.assertEquals(client.getZooKeeper(), mockZookeeper);
}
 
开发者ID:apache,项目名称:curator,代码行数:17,代码来源:BasicTests.java

示例3: buildCuratorFramework

import org.apache.curator.ensemble.fixed.FixedEnsembleProvider; //导入依赖的package包/类
/**
 * Builds a {@link org.apache.curator.framework.CuratorFramework} from the specified {@link java.util.Map<String, ?>}.
 */
private synchronized CuratorFramework buildCuratorFramework(ZookeeperConfig curatorConfig) {
    CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
            .ensembleProvider(new FixedEnsembleProvider(curatorConfig.getZookeeperUrl()))
            .connectionTimeoutMs(curatorConfig.getZookeeperConnectionTimeOut())
            .sessionTimeoutMs(curatorConfig.getZookeeperSessionTimeout())
            .retryPolicy(new RetryNTimes(curatorConfig.getZookeeperRetryMax(), curatorConfig.getZookeeperRetryInterval()));

    if (!StringUtils.isNullOrBlank(curatorConfig.getZookeeperPassword())) {
        String scheme = "digest";
        byte[] auth = ("fabric:" + PasswordEncoder.decode(curatorConfig.getZookeeperPassword())).getBytes();
        builder = builder.authorization(scheme, auth).aclProvider(aclProvider.get());
    }

    CuratorFramework framework = builder.build();

    for (ConnectionStateListener listener : connectionStateListeners) {
        framework.getConnectionStateListenable().addListener(listener);
    }
    return framework;
}
 
开发者ID:tdiesler,项目名称:fabric8poc,代码行数:24,代码来源:ManagedCuratorFramework.java

示例4: setUp

import org.apache.curator.ensemble.fixed.FixedEnsembleProvider; //导入依赖的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

示例5: supplyBindingInformation

import org.apache.curator.ensemble.fixed.FixedEnsembleProvider; //导入依赖的package包/类
/**
 * Supply the binding information.
 * This implementation returns a fixed ensemble bonded to
 * the quorum supplied by {@link #buildConnectionString()}
 * @return the binding information
 */
@Override
public BindingInformation supplyBindingInformation() {
  BindingInformation binding = new BindingInformation();
  String connectString = buildConnectionString();
  binding.ensembleProvider = new FixedEnsembleProvider(connectString);
  binding.description =
      "fixed ZK quorum \"" + connectString + "\"";
  return binding;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:CuratorService.java

示例6: serviceStart

import org.apache.curator.ensemble.fixed.FixedEnsembleProvider; //导入依赖的package包/类
/**
 * Startup: start ZK. It is only after this that
 * the binding information is valid.
 * @throws Exception
 */
@Override
protected void serviceStart() throws Exception {

  setupSecurity();

  ZooKeeperServer zkServer = new ZooKeeperServer();
  FileTxnSnapLog ftxn = new FileTxnSnapLog(dataDir, dataDir);
  zkServer.setTxnLogFactory(ftxn);
  zkServer.setTickTime(tickTime);

  LOG.info("Starting Local Zookeeper service");
  factory = ServerCnxnFactory.createFactory();
  factory.configure(getAddress(port), -1);
  factory.startup(zkServer);

  String connectString = getConnectionString();
  LOG.info("In memory ZK started at {}\n", connectString);

  if (LOG.isDebugEnabled()) {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    zkServer.dumpConf(pw);
    pw.flush();
    LOG.debug(sw.toString());
  }
  binding = new BindingInformation();
  binding.ensembleProvider = new FixedEnsembleProvider(connectString);
  binding.description =
      getName() + " reachable at \"" + connectString + "\"";

  addDiagnostics(binding.description);
  // finally: set the binding information in the config
  getConfig().set(KEY_REGISTRY_ZK_QUORUM, connectString);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:40,代码来源:MicroZookeeperService.java

示例7: setUp

import org.apache.curator.ensemble.fixed.FixedEnsembleProvider; //导入依赖的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

示例8: setUp

import org.apache.curator.ensemble.fixed.FixedEnsembleProvider; //导入依赖的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

示例9: setUp

import org.apache.curator.ensemble.fixed.FixedEnsembleProvider; //导入依赖的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

示例10: setUp

import org.apache.curator.ensemble.fixed.FixedEnsembleProvider; //导入依赖的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

示例11: setUp

import org.apache.curator.ensemble.fixed.FixedEnsembleProvider; //导入依赖的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

示例12: get

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

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

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

示例13: get_ExhibitorNotPresent_ReturnsFixedEnsembleWithConnectionString

import org.apache.curator.ensemble.fixed.FixedEnsembleProvider; //导入依赖的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

示例14: setUp

import org.apache.curator.ensemble.fixed.FixedEnsembleProvider; //导入依赖的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:ReadyTalk,项目名称:cultivar,代码行数:31,代码来源:DiscoveryIntegTest.java

示例15: setUp

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

    ServiceInstance<ImmutableProperties> service1 = ServiceInstance.<ImmutableProperties>builder().id("randomid").name("service").payload(props)
            .build();

    Injector inj = Guice.createInjector(
            new AbstractModule() {
                @Override
                protected void configure() {
                    bindConstant().annotatedWith(Names.named("Cultivar.Curator.baseNamespace")).to("dev/test");
                }
            },
            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));

                }
            }),
            new RegistrationModule(),
            ServiceDiscoveryModuleBuilder.create(ImmutableProperties.class).annotation(Curator.class)
                    .basePath("/discovery").build(), ServiceProviderModuleBuilder.create(ImmutableProperties.class)
                    .name("service").discovery(Curator.class).annotation(Cultivar.class).build(),
            RegistrationServiceModuleBuilder.create(ImmutableProperties.class).discoveryAnnotation(Curator.class)
                    .targetAnnotation(Curator.class).provider(Providers.of(service1)).build());

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

    manager = inj.getInstance(CultivarStartStopManager.class);

}
 
开发者ID:ReadyTalk,项目名称:cultivar,代码行数:37,代码来源:PayloadTypesIntegTest.java


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