本文整理了Java中com.palominolabs.benchpress.config.ZookeeperConfig
类的一些代码示例,展示了ZookeeperConfig
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZookeeperConfig
类的具体详情如下:
包路径:com.palominolabs.benchpress.config.ZookeeperConfig
类名称:ZookeeperConfig
暂无
代码示例来源:origin: palominolabs/benchpress
@Provides
@Singleton
public ServiceProvider<WorkerMetadata> getServiceProvider(ServiceDiscovery<WorkerMetadata> serviceDiscovery,
ZookeeperConfig zookeeperConfig) {
return serviceDiscovery.serviceProviderBuilder()
.serviceName(zookeeperConfig.getWorkerServiceName())
.build();
}
代码示例来源:origin: palominolabs/benchpress
@Provides
@Singleton
public ServiceDiscovery<WorkerMetadata> getServiceDiscovery(ZookeeperConfig zookeeperConfig,
CuratorFramework curatorFramework, InstanceSerializerFactory instanceSerializerFactory) {
return ServiceDiscoveryBuilder.builder(WorkerMetadata.class)
.basePath(zookeeperConfig.getBasePath())
.client(curatorFramework)
.serializer(instanceSerializerFactory
.getInstanceSerializer(new TypeReference<ServiceInstance<WorkerMetadata>>() {}))
.build();
}
代码示例来源:origin: palominolabs/benchpress
@Provides
@Singleton
public CuratorFramework getCuratorFramework(ZookeeperConfig zookeeperConfig) {
return CuratorFrameworkFactory.builder()
.connectionTimeoutMs(1000)
.retryPolicy(new ExponentialBackoffRetry(1000, 10))
.connectString(zookeeperConfig.getConnectionString())
.build();
}
代码示例来源:origin: palominolabs/benchpress
private void assertNoWorkersAdvertised() throws Exception {
Collection<ServiceInstance<WorkerMetadata>> instances =
serviceDiscovery.queryForInstances(zookeeperConfig.getWorkerServiceName());
assertEquals(0, instances.size());
}
代码示例来源:origin: palominolabs/benchpress
@Before
public void setUp() throws Exception {
testingServer = new TestingServer();
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
binder().requireExplicitBindings();
install(new TestConfigModule(testingServer.getPort()));
bind(WorkerAdvertiser.class);
install(new CuratorModule());
bind(SliceRunner.class);
bind(TaskProgressClient.class).to(NoOpTaskProgressClient.class);
install(new TaskPluginRegistryModule());
install(new IpcJsonModule());
}
});
injector.injectMembers(this);
curatorLifecycleHook.start();
// TODO make ZookeeperConfig not use config-magic so we don't duplicate ServiceDiscovery setup
serviceDiscovery = ServiceDiscoveryBuilder.builder(WorkerMetadata.class)
.basePath(zookeeperConfig.getBasePath())
.client(curatorFramework)
.serializer(injector.getInstance(InstanceSerializerFactory.class)
.getInstanceSerializer(new TypeReference<ServiceInstance<WorkerMetadata>>() {}))
.build();
serviceDiscovery.start();
}
代码示例来源:origin: palominolabs/benchpress
private ServiceInstance<WorkerMetadata> getServiceInstance() throws Exception {
WorkerMetadata workerMetadata = new WorkerMetadata(workerId, listenAddress, listenPort);
return ServiceInstance.<WorkerMetadata>builder()
.name(zookeeperConfig.getWorkerServiceName())
.address(listenAddress)
.port(listenPort)
.id(workerId.toString())
.payload(workerMetadata)
.build();
}
代码示例来源:origin: palominolabs/benchpress
private void assertWorkerAdvertised(WorkerMetadata workerMetadata) throws Exception {
Collection<ServiceInstance<WorkerMetadata>> instances =
serviceDiscovery.queryForInstances(zookeeperConfig.getWorkerServiceName());
assertEquals(1, instances.size());
assertEquals(workerMetadata.getWorkerId(), instances.iterator().next().getPayload().getWorkerId());
}
代码示例来源:origin: palominolabs/benchpress
@Test
public void testDeAdvertiseAvailability() throws Exception {
workerAdvertiser.initListenInfo("127.0.0.1", 12345);
workerAdvertiser.advertiseAvailability();
Collection<ServiceInstance<WorkerMetadata>> instances =
serviceDiscovery.queryForInstances(zookeeperConfig.getWorkerServiceName());
assertEquals(1, instances.size());
workerAdvertiser.deAdvertiseAvailability();
instances = serviceDiscovery.queryForInstances(zookeeperConfig.getWorkerServiceName());
assertEquals(0, instances.size());
}
}
代码示例来源:origin: palominolabs/benchpress
/**
* @return the metadata loaded from ZK
*/
private WorkerMetadata advertiseWorker() throws Exception {
workerAdvertiser.initListenInfo(host, port);
workerAdvertiser.advertiseAvailability();
Collection<ServiceInstance<WorkerMetadata>> instances =
serviceDiscovery.queryForInstances(zookeeperConfig.getWorkerServiceName());
assertEquals(1, instances.size());
WorkerMetadata workerMetadata = instances.iterator().next().getPayload();
assertEquals(workerAdvertiser.getWorkerId(), workerMetadata.getWorkerId());
return workerMetadata;
}
代码示例来源:origin: palominolabs/benchpress
@Test
public void testAdvertiseAvailability() throws Exception {
workerAdvertiser.initListenInfo("127.0.0.1", 12345);
workerAdvertiser.advertiseAvailability();
Collection<ServiceInstance<WorkerMetadata>> instances =
serviceDiscovery.queryForInstances(zookeeperConfig.getWorkerServiceName());
assertEquals(1, instances.size());
WorkerMetadata workerMetadata = instances.iterator().next().getPayload();
assertEquals(workerAdvertiser.getWorkerId(), workerMetadata.getWorkerId());
}
内容来源于网络,如有侵权,请联系作者删除!