當前位置: 首頁>>代碼示例>>Java>>正文


Java Etcd類代碼示例

本文整理匯總了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;
    }
}
 
開發者ID:MrBW,項目名稱:resilient-transport-service,代碼行數:16,代碼來源:ArchaiusConfiguration.java

示例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);
}
 
開發者ID:irenical,項目名稱:jindy,代碼行數:40,代碼來源:ArchaiusEtcdFactory.java

示例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();

}
 
開發者ID:MrBW,項目名稱:resilient-transport-service,代碼行數:14,代碼來源:ArchaiusConfiguration.java


注:本文中的org.boon.etcd.Etcd類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。