本文整理匯總了Java中org.boon.etcd.Etcd類的典型用法代碼示例。如果您正苦於以下問題:Java Etcd類的具體用法?Java Etcd怎麽用?Java Etcd使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Etcd類屬於org.boon.etcd包,在下文中一共展示了Etcd類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createEtcdConfiguration
import org.boon.etcd.Etcd; //導入依賴的package包/類
private DynamicWatchedConfiguration createEtcdConfiguration() {
try {
Etcd etcd = createEtcdClient();
LOGGER.debug(LOGGER.isDebugEnabled() ? "Etcd Client created: " + (etcd != null) : null);
EtcdConfigurationSource etcdConfigurationSource = new EtcdConfigurationSource(etcd, "/hystrix/");
return new DynamicWatchedConfiguration(etcdConfigurationSource);
} catch (Exception e) {
LOGGER.error("CoresOS ETCD Service not reachable, Server: " + etcdServerPort, e);
return null;
}
}
示例2: getConfiguration
import org.boon.etcd.Etcd; //導入依賴的package包/類
@Override
protected AbstractConfiguration getConfiguration() throws ConfigNotFoundException {
AbstractConfiguration config = ConfigurationManager.getConfigInstance();
boolean dynamic = config.getBoolean(DYNAMIC_CONFIG, true);
if (!dynamic) {
return new DynamicConfiguration();
}
String appId;
DeploymentContext context = ConfigurationManager.getDeploymentContext();
appId = context.getApplicationId();
if (appId == null) {
LOG.info(
"No applicationId set on archaius deployment context. Will try to use the 'application' property as fallback.");
appId = config.getString("application");
}
if (appId == null) {
throw new RuntimeException(
"Archaius deployment context's applicationId not set nor property 'application' found");
}
String[] etcdHosts = config.getStringArray(ETCD_HOSTS);
Etcd etcdClient;
if(etcdHosts != null && etcdHosts.length > 0) {
URI[] etcdHostURIs = Arrays.stream(etcdHosts).map(URI::create).toArray(URI[]::new);
etcdClient = ClientBuilder.builder().hosts(etcdHostURIs).createClient();
} else {
throw new ConfigNotFoundException("No etcd hosts configured. Could not create etcd client");
}
EtcdConfigurationSource configSource = new EtcdConfigurationSource(etcdClient, appId);
return new DynamicWatchedConfiguration(configSource);
}
示例3: createEtcdClient
import org.boon.etcd.Etcd; //導入依賴的package包/類
/***
* Create and initials etcd client
* @return Etcd
*/
private Etcd createEtcdClient() {
LOGGER.debug(LOGGER.isDebugEnabled() ? "Etcd server baseurl: " + etcdServerPort.get() : null);
ClientBuilder clientBuilder;
clientBuilder = ClientBuilder.builder().hosts(URI.create(etcdServerPort.get())).timeOutInMilliseconds(5000);
return clientBuilder.createClient();
}