use of org.apache.commons.configuration2.convert.DefaultListDelimiterHandler in project hadoop by apache.
the class GangliaSink30 method init.
@Override
@SuppressWarnings("unchecked")
public void init(SubsetConfiguration conf) {
super.init(conf);
conf.setListDelimiterHandler(new DefaultListDelimiterHandler(','));
Iterator<String> it = (Iterator<String>) conf.getKeys();
while (it.hasNext()) {
String propertyName = it.next();
if (propertyName.startsWith(TAGS_FOR_PREFIX_PROPERTY_PREFIX)) {
String contextName = propertyName.substring(TAGS_FOR_PREFIX_PROPERTY_PREFIX.length());
String[] tags = conf.getStringArray(propertyName);
boolean useAllTags = false;
Set<String> set = new HashSet<>();
for (String tag : tags) {
tag = tag.trim();
useAllTags |= tag.equals("*");
if (tag.length() > 0) {
set.add(tag);
}
}
if (useAllTags) {
set = null;
}
useTagsMap.put(contextName, set);
}
}
}
use of org.apache.commons.configuration2.convert.DefaultListDelimiterHandler in project hadoop by apache.
the class MetricsConfig method loadFirst.
/**
* Load configuration from a list of files until the first successful load
* @param conf the configuration object
* @param files the list of filenames to try
* @return the configuration object
*/
static MetricsConfig loadFirst(String prefix, String... fileNames) {
for (String fname : fileNames) {
try {
Configuration cf = new Configurations().propertiesBuilder(fname).configure(new Parameters().properties().setFileName(fname).setListDelimiterHandler(new DefaultListDelimiterHandler(','))).getConfiguration().interpolatedConfiguration();
LOG.info("loaded properties from " + fname);
LOG.debug(toString(cf));
MetricsConfig mc = new MetricsConfig(cf, prefix);
LOG.debug(mc);
return mc;
} catch (ConfigurationException e) {
// Commons Configuration defines the message text when file not found
if (e.getMessage().startsWith("Could not locate")) {
continue;
}
throw new MetricsConfigException(e);
}
}
LOG.warn("Cannot locate configuration: tried " + Joiner.on(",").join(fileNames));
// default to an empty configuration
return new MetricsConfig(new PropertiesConfiguration(), prefix);
}
Aggregations