本文整理了Java中com.spotify.helios.servicescommon.ZooKeeperRegistrar
类的一些代码示例,展示了ZooKeeperRegistrar
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperRegistrar
类的具体详情如下:
包路径:com.spotify.helios.servicescommon.ZooKeeperRegistrar
类名称:ZooKeeperRegistrar
[英]Common logic to have agents and masters register their "up" nodes in ZK, and to keep trying if ZK is down.
[中]常见的逻辑是让代理和主机在ZK中注册其“向上”节点,并在ZK关闭时继续尝试。
代码示例来源:origin: spotify/helios
@Override
protected void shutDown() throws Exception {
reactor.stopAsync().awaitTerminated();
zooKeeperRegistrar.shutDown();
}
代码示例来源:origin: spotify/helios
@Override
protected void startUp() throws Exception {
zooKeeperRegistrar.startUp();
client.getConnectionStateListenable().addListener(listener);
reactor.startAsync().awaitRunning();
reactor.signal();
}
代码示例来源:origin: spotify/helios
successfullyRegistered = zooKeeperRegistrar.tryToRegister(client);
} catch (Exception e) {
if (e instanceof ConnectionLossException) {
代码示例来源:origin: at.molindo/helios-services
@Override
protected void shutDown() throws Exception {
server.stop();
server.join();
registrar.close();
rollingUpdateService.stopAsync().awaitTerminated();
expiredJobReaper.stopAsync().awaitTerminated();
zkRegistrar.stopAsync().awaitTerminated();
zooKeeperClient.close();
}
代码示例来源:origin: at.molindo/helios-services
@Override
protected void startUp() throws Exception {
logBanner();
zkRegistrar.startAsync().awaitRunning();
model.startAsync().awaitRunning();
agent.startAsync().awaitRunning();
hostInfoReporter.startAsync();
agentInfoReporter.startAsync();
environmentVariableReporter.startAsync();
labelReporter.startAsync();
metrics.start();
if (server != null) {
try {
server.start();
} catch (Exception e) {
log.error("Unable to start server, shutting down", e);
server.stop();
}
}
}
代码示例来源: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
private boolean isAlive() {
return state().ordinal() < STOPPING.ordinal();
}
}
代码示例来源:origin: at.molindo/helios-services
@Override
protected void shutDown() throws Exception {
if (server != null) {
server.stop();
}
hostInfoReporter.stopAsync().awaitTerminated();
agentInfoReporter.stopAsync().awaitTerminated();
environmentVariableReporter.stopAsync().awaitTerminated();
labelReporter.stopAsync().awaitTerminated();
agent.stopAsync().awaitTerminated();
if (serviceRegistrar != null) {
serviceRegistrar.close();
}
zkRegistrar.stopAsync().awaitTerminated();
model.stopAsync().awaitTerminated();
metrics.stop();
zooKeeperClient.close();
try {
stateLock.release();
} catch (IOException e) {
log.error("Failed to release state lock", e);
}
try {
stateLockFile.close();
} catch (IOException e) {
log.error("Failed to close state lock file", e);
}
}
代码示例来源:origin: at.molindo/helios-services
@Override
protected void startUp() throws Exception {
logBanner();
if (!config.getNoZooKeeperMasterRegistration()) {
zkRegistrar.startAsync().awaitRunning();
}
expiredJobReaper.startAsync().awaitRunning();
rollingUpdateService.startAsync().awaitRunning();
try {
server.start();
} catch (Exception e) {
log.error("Unable to start server, shutting down", e);
server.stop();
}
final ServiceRegistration serviceRegistration = ServiceRegistration.newBuilder()
.endpoint("helios", "http", config.getHttpEndpoint().getPort(),
config.getDomain(), config.getName())
.build();
registrar.register(serviceRegistration);
}
代码示例来源: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;
}
内容来源于网络,如有侵权,请联系作者删除!