Search in sources :

Example 1 with ConfigurationSubscription

use of com.twitter.distributedlog.config.ConfigurationSubscription in project distributedlog by twitter.

the class DynamicConfigurationFeatureProvider method start.

@Override
public void start() throws IOException {
    List<FileConfigurationBuilder> fileConfigBuilders = Lists.newArrayListWithExpectedSize(2);
    String baseConfigPath = conf.getFileFeatureProviderBaseConfigPath();
    Preconditions.checkNotNull(baseConfigPath);
    File baseConfigFile = new File(baseConfigPath);
    FileConfigurationBuilder baseProperties = new PropertiesConfigurationBuilder(baseConfigFile.toURI().toURL());
    fileConfigBuilders.add(baseProperties);
    String overlayConfigPath = conf.getFileFeatureProviderOverlayConfigPath();
    if (null != overlayConfigPath) {
        File overlayConfigFile = new File(overlayConfigPath);
        FileConfigurationBuilder overlayProperties = new PropertiesConfigurationBuilder(overlayConfigFile.toURI().toURL());
        fileConfigBuilders.add(overlayProperties);
    }
    try {
        this.featuresConfSubscription = new ConfigurationSubscription(this.featuresConf, fileConfigBuilders, executorService, conf.getDynamicConfigReloadIntervalSec(), TimeUnit.SECONDS);
    } catch (ConfigurationException e) {
        throw new IOException("Failed to register subscription on features configuration");
    }
    this.featuresConfSubscription.registerListener(this);
}
Also used : PropertiesConfigurationBuilder(com.twitter.distributedlog.config.PropertiesConfigurationBuilder) ConfigurationException(org.apache.commons.configuration.ConfigurationException) ConfigurationSubscription(com.twitter.distributedlog.config.ConfigurationSubscription) IOException(java.io.IOException) FileConfigurationBuilder(com.twitter.distributedlog.config.FileConfigurationBuilder) File(java.io.File)

Aggregations

ConfigurationSubscription (com.twitter.distributedlog.config.ConfigurationSubscription)1 FileConfigurationBuilder (com.twitter.distributedlog.config.FileConfigurationBuilder)1 PropertiesConfigurationBuilder (com.twitter.distributedlog.config.PropertiesConfigurationBuilder)1 File (java.io.File)1 IOException (java.io.IOException)1 ConfigurationException (org.apache.commons.configuration.ConfigurationException)1