Example usage for org.apache.commons.configuration ConfigurationException ConfigurationException

List of usage examples for org.apache.commons.configuration ConfigurationException ConfigurationException

Introduction

In this page you can find the example usage for org.apache.commons.configuration ConfigurationException ConfigurationException.

Prototype

public ConfigurationException(Throwable cause) 

Source Link

Document

Constructs a new ConfigurationException with specified nested Throwable.

Usage

From source file:com.github.nethad.clustermeister.api.impl.YamlConfiguration.java

public YamlConfiguration(String configFilePath) throws ConfigurationException {
    this.setExpressionEngine(new DefaultExpressionEngine());
    try {// ww  w. ja  v a  2s . c o  m
        load(new FileReader(configFilePath));
    } catch (FileNotFoundException ex) {
        throw new ConfigurationException(ex);
    }
}

From source file:com.linkedin.pinot.server.starter.SingleNodeServerStarter.java

/**
 * Construct from config file path//  w  w  w .  ja  v a2s  .c o  m
 * @param configFilePath Path to the config file
 * @throws Exception
 */
public static void buildServerConfig(File configFilePath) throws Exception {
    if (!configFilePath.exists()) {
        LOGGER.error("configuration file: " + configFilePath.getAbsolutePath() + " does not exist.");
        throw new ConfigurationException(
                "configuration file: " + configFilePath.getAbsolutePath() + " does not exist.");
    }

    // build _serverConf
    final PropertiesConfiguration serverConf = new PropertiesConfiguration();
    serverConf.setDelimiterParsingDisabled(false);
    serverConf.load(configFilePath);
    _serverConf = new ServerConf(serverConf);
}

From source file:edu.berkeley.sparrow.daemon.SparrowDaemon.java

public void initialize(Configuration conf) throws Exception {
    Level logLevel = Level.toLevel(conf.getString(SparrowConf.LOG_LEVEL, ""), DEFAULT_LOG_LEVEL);
    Logger.getRootLogger().setLevel(logLevel);

    // Start as many node monitors as specified in config
    String[] nmPorts = conf.getStringArray(SparrowConf.NM_THRIFT_PORTS);
    String[] inPorts = conf.getStringArray(SparrowConf.INTERNAL_THRIFT_PORTS);

    if (nmPorts.length != inPorts.length) {
        throw new ConfigurationException(SparrowConf.NM_THRIFT_PORTS + " and "
                + SparrowConf.INTERNAL_THRIFT_PORTS + " not of equal length");
    }/*from  w w  w . j  a  v a  2s .  co m*/
    if (nmPorts.length > 1 && (!conf.getString(SparrowConf.DEPLYOMENT_MODE, "").equals("standalone"))) {
        throw new ConfigurationException("Mutliple NodeMonitors only allowed " + "in standalone deployment");
    }
    if (nmPorts.length == 0) {
        (new NodeMonitorThrift()).initialize(conf, NodeMonitorThrift.DEFAULT_NM_THRIFT_PORT,
                NodeMonitorThrift.DEFAULT_INTERNAL_THRIFT_PORT);
    } else {
        for (int i = 0; i < nmPorts.length; i++) {
            (new NodeMonitorThrift()).initialize(conf, Integer.parseInt(nmPorts[i]),
                    Integer.parseInt(inPorts[i]));
        }
    }

    SchedulerThrift scheduler = new SchedulerThrift();
    scheduler.initialize(conf);
}

From source file:com.linkedin.pinot.core.query.config.SegmentPrunerConfig.java

private void checkRequiredKeys() throws ConfigurationException {
    for (String keyString : REQUIRED_KEYS) {
        if (!_segmentPrunerSetConfig.containsKey(keyString)) {
            throw new ConfigurationException("Cannot find required key : " + keyString);
        }//from   w w w . ja va 2 s .  co  m
    }
}

From source file:ch.epfl.eagle.daemon.EagleDaemon.java

public void initialize(Configuration conf) throws Exception {
    Level logLevel = Level.toLevel(conf.getString(EagleConf.LOG_LEVEL, ""), DEFAULT_LOG_LEVEL);
    Logger.getRootLogger().setLevel(logLevel);

    // Start as many node monitors as specified in config
    String[] nmPorts = conf.getStringArray(EagleConf.NM_THRIFT_PORTS);
    String[] inPorts = conf.getStringArray(EagleConf.INTERNAL_THRIFT_PORTS);

    if (nmPorts.length != inPorts.length) {
        throw new ConfigurationException(
                EagleConf.NM_THRIFT_PORTS + " and " + EagleConf.INTERNAL_THRIFT_PORTS + " not of equal length");
    }/*  w ww  . j  a  v a 2s  .  c o  m*/
    if (nmPorts.length > 1 && (!conf.getString(EagleConf.DEPLOYMENT_MODE, "").equals("standalone"))) {
        throw new ConfigurationException("Mutliple NodeMonitors only allowed " + "in standalone deployment");
    }
    if (nmPorts.length == 0) {
        (new NodeMonitorThrift()).initialize(conf, NodeMonitorThrift.DEFAULT_NM_THRIFT_PORT,
                NodeMonitorThrift.DEFAULT_INTERNAL_THRIFT_PORT);
    } else {
        for (int i = 0; i < nmPorts.length; i++) {
            (new NodeMonitorThrift()).initialize(conf, Integer.parseInt(nmPorts[i]),
                    Integer.parseInt(inPorts[i]));
        }
    }

    SchedulerThrift scheduler = new SchedulerThrift();
    scheduler.initialize(conf);
}

From source file:com.linkedin.pinot.core.query.config.QueryExecutorConfig.java

private void checkRequiredKeys() throws ConfigurationException {
    for (String keyString : REQUIRED_KEYS) {
        if (!_queryExecutorConfig.containsKey(keyString)) {
            throw new ConfigurationException("Cannot find required key : " + keyString);
        }/*from  www .  j av  a2 s . c om*/
    }
}

From source file:com.twitter.distributedlog.service.config.ServiceStreamConfigProvider.java

public ServiceStreamConfigProvider(String configPath, String defaultConfigPath,
        StreamPartitionConverter partitionConverter, ScheduledExecutorService executorService, int reloadPeriod,
        TimeUnit reloadUnit) throws ConfigurationException {
    this.configBaseDir = new File(configPath);
    if (!configBaseDir.exists()) {
        throw new ConfigurationException(
                "Stream configuration base directory " + configPath + " does not exist");
    }/* w w  w .ja v  a2 s.  c  o  m*/
    this.defaultConfigFile = new File(configPath);
    if (!defaultConfigFile.exists()) {
        throw new ConfigurationException(
                "Stream configuration default config " + defaultConfigPath + " does not exist");
    }

    // Construct reloading default configuration
    this.partitionConverter = partitionConverter;
    this.configFactory = new DynamicConfigurationFactory(executorService, reloadPeriod, reloadUnit);
    // We know it exists from the check above.
    this.defaultDynConf = configFactory.getDynamicConfiguration(defaultConfigPath).get();
}

From source file:edu.kit.dama.ui.simon.util.SimonConfigurator.java

public void setConfigLocation(File pPath) throws ConfigurationException {
    if (pPath == null) {
        throw new IllegalArgumentException("Argument pPath must not be null");
    }/*from  w w w  .  j  av a  2 s  .co m*/
    if (!pPath.exists() || !pPath.isDirectory()) {
        throw new ConfigurationException("Argument pPath must be an existing directory");
    }

    if (!pPath.equals(configPath)) {
        LOGGER.debug("Reloading configuration");
        configPath = pPath;
        probes.clear();
        configs.clear();
        configure();
    } else {
        LOGGER.debug("New config file is equal to current config file. Skipping reconfiguration.");
    }

    if (observer != null) {
        LOGGER.debug("Stopping directory observer");
        try {
            LOGGER.debug(" - Removing observer from monitor");
            configMontitor.removeObserver(observer);
            LOGGER.debug(" - Destroying observer");
            observer.destroy();
        } catch (Exception e) {
            LOGGER.info("Failed to stop observer, ignoring this.", e);
        }
        observer = null;
    }

    LOGGER.debug("Setting up directory observer for current configuration path {}", pPath);
    observer = new FileAlterationObserver(pPath);
    try {
        LOGGER.debug(" - Initializing directory observer");
        observer.initialize();
        LOGGER.debug(" - Directory observer successfully initialized. Adding listener.");
        observer.addListener(this);
        configMontitor.addObserver(observer);
    } catch (Exception e) {
        LOGGER.info("Failed to initialize directory observer. Configuration changes won't be tracked.", e);
        observer = null;
    }

}

From source file:net.i2cat.netconf.NetconfSession.java

public NetconfSession(SessionContext sessionContext, TransportFactory transportFactory)
        throws TransportNotRegisteredException, ConfigurationException {
    this.transportFactory = transportFactory;
    this.sessionContext = sessionContext;

    URI uri = sessionContext.getURI();

    if (uri.getScheme() == null || uri.getHost() == null || uri.getUserInfo() == null)
        throw new ConfigurationException("Insufficient information in session context's URI: " + uri);

    if (!transportFactory.isAwareOfScheme(uri.getScheme())) {
        throw new TransportNotRegisteredException(
                "Scheme '" + uri.getScheme() + "' given in URI has not been registered with TransportFactory.");
    }//w  w  w  . jav a2  s . c  o m
}

From source file:com.linkedin.pinot.server.starter.ServerBuilder.java

/**
 * Construct from config file path/*from   w  ww. jav  a2s .  c o  m*/
 * @param configFilePath Path to the config file
 * @param metricsRegistry
 * @throws Exception
 */
public ServerBuilder(File configFilePath, MetricsRegistry metricsRegistry) throws Exception {
    this.metricsRegistry = metricsRegistry;
    if (!configFilePath.exists()) {
        LOGGER.error("configuration file: " + configFilePath.getAbsolutePath() + " does not exist.");
        throw new ConfigurationException(
                "configuration file: " + configFilePath.getAbsolutePath() + " does not exist.");
    }

    // build _serverConf
    PropertiesConfiguration serverConf = new PropertiesConfiguration();
    serverConf.setDelimiterParsingDisabled(false);
    serverConf.load(configFilePath);
    _serverConf = new ServerConf(serverConf);

    initMetrics();
}