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


Java ZooKeeperConfigurationSource類代碼示例

本文整理匯總了Java中com.netflix.config.source.ZooKeeperConfigurationSource的典型用法代碼示例。如果您正苦於以下問題:Java ZooKeeperConfigurationSource類的具體用法?Java ZooKeeperConfigurationSource怎麽用?Java ZooKeeperConfigurationSource使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ZooKeeperConfigurationSource類屬於com.netflix.config.source包,在下文中一共展示了ZooKeeperConfigurationSource類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initializeZookeeperConfigurationSource

import com.netflix.config.source.ZooKeeperConfigurationSource; //導入依賴的package包/類
private void initializeZookeeperConfigurationSource() {
    if (running) {
        LOGGER.warn("Detected creation of node {}, but zookeeper configuration source already running. This should not happen. Ignoring event...", instanceConfigPath);
        return;
    }
    this.zooKeeperConfigurationSource = new ZooKeeperConfigurationSource(curatorFramework, instanceConfigPath);
    listeners.forEach(new Function<WatchedUpdateListener, Void>() {
        @Nullable
        @Override
        public Void apply(@Nullable WatchedUpdateListener watchedUpdateListener) {
            zooKeeperConfigurationSource.addUpdateListener(watchedUpdateListener);
            return null;
        }
    });
    try {
        zooKeeperConfigurationSource.start();
    } catch (Exception e) {
        LOGGER.error("errro starting zookeeper configuration source", e);
        throw new BootstrapException("Error initializing zookeeper configuration source", e);
    }
    running = true;
}
 
開發者ID:Kixeye,項目名稱:chassis,代碼行數:23,代碼來源:DynamicZookeeperConfigurationSource.java

示例2: installZkConfig

import com.netflix.config.source.ZooKeeperConfigurationSource; //導入依賴的package包/類
@PostConstruct
public void installZkConfig() throws Exception {
    String zkConfigRootPath = "/config/"+appName;
    ZooKeeperConfigurationSource zkConfigSource = new ZooKeeperConfigurationSource(client, zkConfigRootPath);
    zkConfigSource.start();
    DynamicWatchedConfiguration zkDynamicConfig = new DynamicWatchedConfiguration(zkConfigSource);
    ConfigurationManager.install(zkDynamicConfig);
}
 
開發者ID:IBYoung,項目名稱:vert.3x-gateway,代碼行數:9,代碼來源:ArchaiusZkConfig.java

示例3: getConfiguration

import com.netflix.config.source.ZooKeeperConfigurationSource; //導入依賴的package包/類
@Override
protected AbstractConfiguration getConfiguration() throws Exception {
  AbstractConfiguration config = ConfigurationManager.getConfigInstance();
  boolean dynamic = config.getBoolean(DYNAMIC_CONFIG, true);
  if (!dynamic) {
    return new DynamicConfiguration();
  }

  String appId = null;
  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 zooKeeperConnString = config.getString(ZOOKEEPER_HOSTS);
  String rootConfigPath = "/" + appId;

  CuratorFramework client = CuratorFrameworkFactory.newClient(zooKeeperConnString, new ExponentialBackoffRetry(1000, 3));
  ZooKeeperConfigurationSource configSource = new ZooKeeperConfigurationSource(client, rootConfigPath);

  // do the first update synchronously
  try {
    client.start();
    configSource.start();
  } catch (Exception e) {
    configSource.close();
    throw e;
  }

  return new DynamicWatchedConfiguration(configSource);
}
 
開發者ID:irenical,項目名稱:jindy,代碼行數:40,代碼來源:ArchaiusZooKeeperFactory.java

示例4: getApplicationConfiguration

import com.netflix.config.source.ZooKeeperConfigurationSource; //導入依賴的package包/類
/**
 * @see ConfigurationProvider#getApplicationConfiguration(String, String, String, com.kixeye.chassis.bootstrap.aws.ServerInstanceContext)
 */
@Override
public AbstractConfiguration getApplicationConfiguration(String environment, String applicationName, String applicationVersion, ServerInstanceContext serverInstanceContext) {
    String instanceId = serverInstanceContext == null ? "local" : serverInstanceContext.getInstanceId();

    String configRoot = getPath(environment, applicationName, applicationVersion);
    String primaryConfigPath = configRoot += "/config";
    String instanceConfigNode = instanceId + "-config";

    checkPath(primaryConfigPath);

    ZooKeeperConfigurationSource source = new ZooKeeperConfigurationSource(curatorFramework, primaryConfigPath);

    try {
        source.start();
    } catch (Exception e) {
        source.close();
        BootstrapException.zookeeperInitializationFailed(zookeeperConnectionString, primaryConfigPath, e);
    }

    logger.debug("Initializing zookeeper configuration from host " + zookeeperConnectionString + " at path " + primaryConfigPath);

    ConcurrentCompositeConfiguration configuration = new ConcurrentCompositeConfiguration();
    configuration.addConfiguration(getServerInstanceSpecificApplicationConfiguration(configRoot, instanceConfigNode));
    configuration.addConfiguration(new DynamicWatchedConfiguration(source));

    return configuration;
}
 
開發者ID:Kixeye,項目名稱:chassis,代碼行數:31,代碼來源:ZookeeperConfigurationProvider.java


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