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);
}
}
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();
}
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);
}
}
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);
}
}
}
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));
}
}
Aggregations