本文整理了Java中com.spotify.helios.servicescommon.coordination.ZooKeeperClient.start()
方法的一些代码示例,展示了ZooKeeperClient.start()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperClient.start()
方法的具体详情如下:
包路径:com.spotify.helios.servicescommon.coordination.ZooKeeperClient
类名称:ZooKeeperClient
方法名:start
暂无
代码示例来源:origin: spotify/helios
@Override
public void start() {
client.start();
client.getConnectionStateListenable().addListener(
(client, newState) -> reporter.connectionStateChanged(newState));
}
代码示例来源:origin: spotify/helios
static void initializeAcl(final String zooKeeperConnectionString,
final String zooKeeperClusterId,
final String masterUser,
final String masterPassword,
final String agentUser,
final String agentPassword)
throws KeeperException {
final ACLProvider aclProvider = heliosAclProvider(
masterUser, digest(masterUser, masterPassword),
agentUser, digest(agentUser, agentPassword));
final List<AuthInfo> authorization = Lists.newArrayList(new AuthInfo(
"digest", String.format("%s:%s", masterUser, masterPassword).getBytes()));
final RetryPolicy zooKeeperRetryPolicy = new ExponentialBackoffRetry(1000, 3);
final CuratorFramework curator = new CuratorClientFactoryImpl().newClient(
zooKeeperConnectionString,
(int) TimeUnit.SECONDS.toMillis(60),
(int) TimeUnit.SECONDS.toMillis(15),
zooKeeperRetryPolicy,
aclProvider,
authorization);
final ZooKeeperClient client = new DefaultZooKeeperClient(curator, zooKeeperClusterId);
try {
client.start();
initializeAclRecursive(client, "/", aclProvider);
} finally {
client.close();
}
}
代码示例来源:origin: spotify/helios
@Test
public void testZooKeeperClient() throws Exception {
// Create the cluster ID node
zk().curatorWithSuperAuth().newNamespaceAwareEnsurePath(Paths.configId(zkClusterId))
.ensure(zk().curatorWithSuperAuth().getZookeeperClient());
// We need to create a new curator because ZooKeeperClient will try to start it,
// and zk().curator() has already been started.
final ExponentialBackoffRetry retryPolicy = new ExponentialBackoffRetry(1000, 3);
final CuratorFramework curator = CuratorFrameworkFactory.builder()
.retryPolicy(retryPolicy)
.connectString(zk().connectString())
.build();
final ZooKeeperClient client = new DefaultZooKeeperClient(curator, zkClusterId);
client.start();
// This should work since the cluster ID exists
client.create("/test");
// Now let's remove the cluster ID
client.delete(Paths.configId(zkClusterId));
// Sleep so the watcher thread in ZooKeeperClient has a chance to update state
Thread.sleep(500);
// Try the same operation again, and it should fail this time
try {
client.ensurePath(Paths.configJobs());
fail("ZooKeeper operation should have failed because cluster ID was removed");
} catch (IllegalStateException ignore) {
// ignored
}
}
代码示例来源:origin: spotify/helios
final ZooKeeperClient client =
new DefaultZooKeeperClient(curator, config.getZooKeeperClusterId());
client.start();
zkRegistrar = ZooKeeperRegistrarService.newBuilder()
.setZooKeeperClient(client)
代码示例来源:origin: spotify/helios
client.start();
代码示例来源:origin: at.molindo/helios-services
@Override
public void start() {
client.start();
}
代码示例来源:origin: at.molindo/helios-services
/**
* Create a Zookeeper client and create the control and state nodes if needed.
*
* @param config The service configuration.
* @return A zookeeper client.
*/
private ZooKeeperClient setupZookeeperClient(final MasterConfig config) {
final RetryPolicy zooKeeperRetryPolicy = new ExponentialBackoffRetry(1000, 3);
final CuratorFramework curator = curatorClientFactory.newClient(
config.getZooKeeperConnectionString(),
config.getZooKeeperSessionTimeoutMillis(),
config.getZooKeeperConnectionTimeoutMillis(),
zooKeeperRetryPolicy,
config.getZooKeeperNamespace());
final ZooKeeperClient client = new DefaultZooKeeperClient(curator,
config.getZooKeeperClusterId());
client.start();
zkRegistrar = new ZooKeeperRegistrar(client, new MasterZooKeeperRegistrar(config.getName()));
return client;
}
}
代码示例来源:origin: at.molindo/helios-services
/**
* Create a Zookeeper client and create the control and state nodes if needed.
*
* @param config The service configuration.
* @return A zookeeper client.
*/
private ZooKeeperClient setupZookeeperClient(final AgentConfig config, final String id) {
final RetryPolicy zooKeeperRetryPolicy = new ExponentialBackoffRetry(1000, 3);
final CuratorFramework curator = new CuratorClientFactoryImpl().newClient(
config.getZooKeeperConnectionString(),
config.getZooKeeperSessionTimeoutMillis(),
config.getZooKeeperConnectionTimeoutMillis(),
zooKeeperRetryPolicy,
config.getZooKeeperNamespace());
final ZooKeeperClient client = new DefaultZooKeeperClient(curator,
config.getZooKeeperClusterId());
client.start();
// Register the agent
zkRegistrar =
new ZooKeeperRegistrar(client, new AgentZooKeeperRegistrar(this, config.getName(), id));
return client;
}
内容来源于网络,如有侵权,请联系作者删除!