Search in sources :

Example 26 with ConfigurationException

use of org.apache.commons.configuration.ConfigurationException in project distributedlog by twitter.

the class DistributedLogServerApp method run.

private void run() {
    try {
        logger.info("Running distributedlog server : args = {}", Arrays.toString(args));
        BasicParser parser = new BasicParser();
        CommandLine cmdline = parser.parse(options, args);
        runCmd(cmdline);
    } catch (ParseException pe) {
        logger.error("Argument error : {}", pe.getMessage());
        printUsage();
        Runtime.getRuntime().exit(-1);
    } catch (IllegalArgumentException iae) {
        logger.error("Argument error : {}", iae.getMessage());
        printUsage();
        Runtime.getRuntime().exit(-1);
    } catch (ConfigurationException ce) {
        logger.error("Configuration error : {}", ce.getMessage());
        printUsage();
        Runtime.getRuntime().exit(-1);
    } catch (IOException ie) {
        logger.error("Failed to start distributedlog server : ", ie);
        Runtime.getRuntime().exit(-1);
    }
}
Also used : BasicParser(org.apache.commons.cli.BasicParser) CommandLine(org.apache.commons.cli.CommandLine) ConfigurationException(org.apache.commons.configuration.ConfigurationException) ParseException(org.apache.commons.cli.ParseException) IOException(java.io.IOException)

Example 27 with ConfigurationException

use of org.apache.commons.configuration.ConfigurationException in project distributedlog by twitter.

the class ConfigurationSubscription method initConfig.

private boolean initConfig() {
    if (fileConfigs.isEmpty()) {
        try {
            for (FileConfigurationBuilder fileConfigBuilder : fileConfigBuilders) {
                FileConfiguration fileConfig = fileConfigBuilder.getConfiguration();
                FileChangedReloadingStrategy reloadingStrategy = new FileChangedReloadingStrategy();
                reloadingStrategy.setRefreshDelay(0);
                fileConfig.setReloadingStrategy(reloadingStrategy);
                fileConfigs.add(fileConfig);
            }
        } catch (ConfigurationException ex) {
            if (!fileNotFound(ex)) {
                LOG.error("Config init failed {}", ex);
            }
        }
    }
    return !fileConfigs.isEmpty();
}
Also used : FileConfiguration(org.apache.commons.configuration.FileConfiguration) FileChangedReloadingStrategy(org.apache.commons.configuration.reloading.FileChangedReloadingStrategy) ConfigurationException(org.apache.commons.configuration.ConfigurationException)

Example 28 with ConfigurationException

use of org.apache.commons.configuration.ConfigurationException in project distributedlog by twitter.

the class DynamicConfigurationFactory method getDynamicConfiguration.

public synchronized Optional<DynamicDistributedLogConfiguration> getDynamicConfiguration(String configPath, ConcurrentBaseConfiguration defaultConf) throws ConfigurationException {
    Preconditions.checkNotNull(configPath);
    try {
        if (!dynamicConfigs.containsKey(configPath)) {
            File configFile = new File(configPath);
            FileConfigurationBuilder properties = new PropertiesConfigurationBuilder(configFile.toURI().toURL());
            DynamicDistributedLogConfiguration dynConf = new DynamicDistributedLogConfiguration(defaultConf);
            List<FileConfigurationBuilder> fileConfigBuilders = Lists.newArrayList(properties);
            ConfigurationSubscription subscription = new ConfigurationSubscription(dynConf, fileConfigBuilders, executorService, reloadPeriod, reloadUnit);
            subscriptions.add(subscription);
            dynamicConfigs.put(configPath, dynConf);
            LOG.info("Loaded dynamic configuration at {}", configPath);
        }
        return Optional.of(dynamicConfigs.get(configPath));
    } catch (MalformedURLException ex) {
        throw new ConfigurationException(ex);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) ConfigurationException(org.apache.commons.configuration.ConfigurationException) File(java.io.File)

Example 29 with ConfigurationException

use of org.apache.commons.configuration.ConfigurationException in project distributedlog by twitter.

the class AbstractFeatureProvider method getFeatureProvider.

public static FeatureProvider getFeatureProvider(String rootScope, DistributedLogConfiguration conf, StatsLogger statsLogger) throws IOException {
    Class<? extends FeatureProvider> featureProviderClass;
    try {
        featureProviderClass = conf.getFeatureProviderClass();
    } catch (ConfigurationException e) {
        throw new IOException("Can't initialize the feature provider : ", e);
    }
    // create feature provider
    Constructor<? extends FeatureProvider> constructor;
    try {
        constructor = featureProviderClass.getDeclaredConstructor(String.class, DistributedLogConfiguration.class, StatsLogger.class);
    } catch (NoSuchMethodException e) {
        throw new IOException("No constructor found for feature provider class " + featureProviderClass + " : ", e);
    }
    try {
        return constructor.newInstance(rootScope, conf, statsLogger);
    } catch (InstantiationException e) {
        throw new IOException("Failed to instantiate feature provider : ", e);
    } catch (IllegalAccessException e) {
        throw new IOException("Encountered illegal access when instantiating feature provider : ", e);
    } catch (InvocationTargetException e) {
        Throwable targetException = e.getTargetException();
        if (targetException instanceof IOException) {
            throw (IOException) targetException;
        } else {
            throw new IOException("Encountered invocation target exception while instantiating feature provider : ", e);
        }
    }
}
Also used : DistributedLogConfiguration(com.twitter.distributedlog.DistributedLogConfiguration) StatsLogger(org.apache.bookkeeper.stats.StatsLogger) ConfigurationException(org.apache.commons.configuration.ConfigurationException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 30 with ConfigurationException

use of org.apache.commons.configuration.ConfigurationException in project oxCore by GluuFederation.

the class FileConfiguration method loadProperties.

protected void loadProperties() {
    try {
        this.propertiesConfiguration = new PropertiesConfiguration(this.fileName);
        this.loaded = true;
    } catch (ConfigurationException ex) {
        log.debug(String.format("Failed to load '%s' configuration file from config folder", this.fileName));
    }
}
Also used : ConfigurationException(org.apache.commons.configuration.ConfigurationException) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration)

Aggregations

ConfigurationException (org.apache.commons.configuration.ConfigurationException)58 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)24 File (java.io.File)18 IOException (java.io.IOException)18 ActionEvent (java.awt.event.ActionEvent)6 ActionListener (java.awt.event.ActionListener)5 MalformedURLException (java.net.MalformedURLException)5 ArrayList (java.util.ArrayList)5 ZapXmlConfiguration (org.zaproxy.zap.utils.ZapXmlConfiguration)5 DistributedLogConfiguration (com.twitter.distributedlog.DistributedLogConfiguration)4 FileInputStream (java.io.FileInputStream)4 FileWriter (java.io.FileWriter)4 Configuration (org.apache.commons.configuration.Configuration)4 FileNotFoundException (java.io.FileNotFoundException)3 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 CommonsConfiguration (com.thinkaurelius.titan.diskstorage.configuration.backend.CommonsConfiguration)2 BufferedWriter (java.io.BufferedWriter)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 SQLException (java.sql.SQLException)2