use of com.netflix.config.source.ZooKeeperConfigurationSource in project chassis by Kixeye.
the class ZookeeperConfigurationProvider method getApplicationConfiguration.
/**
* @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;
}
use of com.netflix.config.source.ZooKeeperConfigurationSource in project chassis by Kixeye.
the class DynamicZookeeperConfigurationSource method initializeZookeeperConfigurationSource.
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;
}
Aggregations