当前位置: 首页>>代码示例>>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;未经允许,请勿转载。