本文整理汇总了Java中org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider类的典型用法代码示例。如果您正苦于以下问题:Java ExhibitorEnsembleProvider类的具体用法?Java ExhibitorEnsembleProvider怎么用?Java ExhibitorEnsembleProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExhibitorEnsembleProvider类属于org.apache.curator.ensemble.exhibitor包,在下文中一共展示了ExhibitorEnsembleProvider类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: instance_BindingOptionalsWithExhibitor_UsesParametersInExhibitorInstance
import org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider; //导入依赖的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
示例2: instance_BindingOptionalsWithExhibitor_UsesParametersInExhibitorInstance
import org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider; //导入依赖的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
示例3: exhibitorEnsembleProvider
import org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider; //导入依赖的package包/类
private ExhibitorEnsembleProvider exhibitorEnsembleProvider() {
Exhibitors exhibitors = new Exhibitors(Arrays.asList(exhibitorInstances.get().split(";")), restPort,
new Exhibitors.BackupConnectionStringProvider() {
@Override
public String getBackupConnectionString() throws Exception {
return backupConnections.get();
}
});
return new ExhibitorEnsembleProvider(exhibitors, restClient, restPath, pollingTimeMs, retryPolicy);
}
开发者ID:dclements,项目名称:cultivar_old,代码行数:14,代码来源:EnsembleProviderProvider.java
示例4: get_ExhibitorPresentWithBackup_ReturnsExhbitorEnsembleProvider
import org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider; //导入依赖的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
示例5: buildCuratorWithExhibitor
import org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider; //导入依赖的package包/类
private CuratorFramework buildCuratorWithExhibitor(Configuration configuration) {
LOGGER.debug("configuring zookeeper connection through Exhibitor...");
ExhibitorEnsembleProvider ensembleProvider =
new KixeyeExhibitorEnsembleProvider(
exhibitors,
new KixeyeExhibitorRestClient(configuration.getBoolean(EXHIBITOR_USE_HTTPS.getPropertyName())),
configuration.getString(EXHIBITOR_URI_PATH.getPropertyName()),
configuration.getInt(EXHIBITOR_POLL_INTERVAL.getPropertyName()),
new ExponentialBackoffRetry(
configuration.getInt(EXHIBITOR_INITIAL_SLEEP_MILLIS.getPropertyName()),
configuration.getInt(EXHIBITOR_MAX_RETRIES.getPropertyName()),
configuration.getInt(EXHIBITOR_RETRIES_MAX_MILLIS.getPropertyName())));
//without this (undocumented) step, curator will attempt (and fail) to connect to a local instance of zookeeper (default behavior if no zookeeper connection string is provided) for
//several seconds until the EnsembleProvider polls to get the SERVER list from Exhibitor. Polling before staring curator
//ensures that the SERVER list from Exhibitor is already downloaded before curator attempts to connect to zookeeper.
try {
ensembleProvider.pollForInitialEnsemble();
} catch (Exception e) {
try {
Closeables.close(ensembleProvider, true);
} catch (IOException e1) {
}
throw new BootstrapException("Failed to initialize Exhibitor with host(s) " + exhibitors.getHostnames(), e);
}
CuratorFramework curator = CuratorFrameworkFactory.builder().ensembleProvider(ensembleProvider).retryPolicy(buildZookeeperRetryPolicy(configuration)).build();
curator.getConnectionStateListenable().addListener(new ConnectionStateListener() {
public void stateChanged(CuratorFramework client, ConnectionState newState) {
LOGGER.debug("Connection state to ZooKeeper changed: " + newState);
}
});
return curator;
}
开发者ID:Kixeye,项目名称:chassis,代码行数:36,代码来源:CuratorFrameworkBuilder.java
示例6: makeCurator
import org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider; //导入依赖的package包/类
private CuratorFramework makeCurator(final String connectString, int baseSleepTimeMs, int maxRetries, int exhibitorPort, String exhibitorRestPath, int pollingMs)
{
List<String> hostnames = Lists.newArrayList();
String[] parts = connectString.split(",");
for ( String spec : parts )
{
String[] subParts = spec.split(":");
try
{
if ( subParts.length != 2 )
{
log.error("Bad connection string: " + connectString);
return null;
}
}
catch ( NumberFormatException e )
{
log.error("Bad connection string: " + connectString);
return null;
}
hostnames.add(subParts[0]);
}
ExponentialBackoffRetry retryPolicy = new ExponentialBackoffRetry(baseSleepTimeMs, maxRetries);
Exhibitors.BackupConnectionStringProvider backupConnectionStringProvider = new Exhibitors.BackupConnectionStringProvider()
{
@Override
public String getBackupConnectionString() throws Exception
{
return connectString;
}
};
CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory
.builder()
.connectString(connectString)
.retryPolicy(retryPolicy);
if ( exhibitorPort > 0 )
{
Exhibitors exhibitors = new Exhibitors(hostnames, exhibitorPort, backupConnectionStringProvider);
ExhibitorEnsembleProvider ensembleProvider = new ExhibitorEnsembleProvider(exhibitors, new DefaultExhibitorRestClient(), exhibitorRestPath + "exhibitor/v1/cluster/list", pollingMs, retryPolicy);
builder = builder.ensembleProvider(ensembleProvider);
}
else
{
log.warn("Exhibitor on the shared ZooKeeper config ensemble is not being used.");
}
return builder.build();
}
开发者ID:dcos,项目名称:exhibitor,代码行数:51,代码来源:ExhibitorCreator.java
示例7: instance_ConnectionAndExhibitorProviderProperties_ReturnsExhibitorProvider
import org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider; //导入依赖的package包/类
@Test
public void instance_ConnectionAndExhibitorProviderProperties_ReturnsExhibitorProvider() {
System.setProperty(ExhibitorProvider.PROPERTY_NAME, CONNECTION);
Injector inj = Guice.createInjector(module);
assertTrue(inj.getInstance(EnsembleProvider.class) instanceof ExhibitorEnsembleProvider);
}
开发者ID:dclements,项目名称:cultivar_old,代码行数:10,代码来源:EnsembleProviderIntegTest.java
示例8: instance_ConnectionAndExhibitorProviderProperties_ReturnsExhibitorProvider
import org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider; //导入依赖的package包/类
@Test
public void instance_ConnectionAndExhibitorProviderProperties_ReturnsExhibitorProvider() {
System.setProperty(ExhibitorProvider.PROPERTY_NAME, CONNECTION);
PropertyReader.reset();
Injector inj = Guice.createInjector(module);
assertTrue(inj.getInstance(Key.get(EnsembleProvider.class, Curator.class)) instanceof ExhibitorEnsembleProvider);
}
开发者ID:ReadyTalk,项目名称:cultivar,代码行数:12,代码来源:EnsembleProviderIntegTest.java
注:本文中的org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论