use of org.apache.commons.configuration.MapConfiguration in project pinot by linkedin.
the class MetricsHelperTest method testMetricsHelperRegistration.
@Test
public void testMetricsHelperRegistration() {
listenerOneOkay = false;
listenerTwoOkay = false;
Map<String, String> configKeys = new HashMap<String, String>();
configKeys.put("pinot.broker.metrics.metricsRegistryRegistrationListeners", ListenerOne.class.getName() + "," + ListenerTwo.class.getName());
Configuration configuration = new MapConfiguration(configKeys);
MetricsRegistry registry = new MetricsRegistry();
// Initialize the MetricsHelper and create a new timer
MetricsHelper.initializeMetrics(configuration.subset("pinot.broker.metrics"));
MetricsHelper.registerMetricsRegistry(registry);
MetricsHelper.newTimer(registry, new MetricName(MetricsHelperTest.class, "dummy"), TimeUnit.MILLISECONDS, TimeUnit.MILLISECONDS);
// Check that the two listeners fired
assertTrue(listenerOneOkay);
assertTrue(listenerTwoOkay);
}
use of org.apache.commons.configuration.MapConfiguration in project OpenAttestation by OpenAttestation.
the class ConfigurationUtil method fromInputStream.
/**
* Does NOT close the InputStream
*
* @param properties
* @return
* @throws IOException
*/
public static Configuration fromInputStream(InputStream properties) throws IOException {
Properties p = new Properties();
p.load(properties);
return new MapConfiguration(p);
}
use of org.apache.commons.configuration.MapConfiguration in project OpenAttestation by OpenAttestation.
the class TagCreateCaKey method main.
public static void main(String[] args) {
TagCreateCaKey cmd = new TagCreateCaKey();
cmd.setOptions(new MapConfiguration(new Properties()));
try {
//Removing to facilitate args passing
//cmd.execute(new String[] { "CN=Asset CA,OU=Datacenter,C=US" });
cmd.execute(args);
} catch (Exception ex) {
java.util.logging.Logger.getLogger(TagCreateCaKey.class.getName()).log(Level.SEVERE, null, ex);
}
}
use of org.apache.commons.configuration.MapConfiguration in project OpenAttestation by OpenAttestation.
the class TAConfig method readPropertiesFile.
private void readPropertiesFile(String propertiesFilename, CompositeConfiguration composite) throws IOException {
InputStream in = getClass().getResourceAsStream(propertiesFilename);
log.info("Reading property file " + propertiesFilename);
if (in != null) {
try {
Properties properties = new Properties();
properties.load(in);
MapConfiguration classpath = new MapConfiguration(properties);
dumpConfiguration(classpath, "classpath:/" + propertiesFilename);
composite.addConfiguration(classpath);
} finally {
in.close();
}
}
}
use of org.apache.commons.configuration.MapConfiguration in project chassis by Kixeye.
the class ZookeeperConfigurationWriterTest method basePathExists_overwrite.
@Test
public void basePathExists_overwrite() throws Exception {
Assert.assertNull(curatorFramework.checkExists().forPath(base));
try (CuratorFramework zkCurator = createCuratorFramework()) {
ZookeeperConfigurationWriter writer = new ZookeeperConfigurationWriter(applicationName, environmentName, version, zkCurator, true);
writer.write(new MapConfiguration(props), new DefaultPropertyFilter());
Assert.assertEquals(val1, new String(curatorFramework.getData().forPath(base + "/" + key1)));
Assert.assertEquals(val2, new String(curatorFramework.getData().forPath(base + "/" + key2)));
String key3 = RandomUtils.nextInt() + "";
String val3 = RandomUtils.nextInt() + "";
String newVal1 = RandomUtils.nextInt() + "";
props.clear();
//updates key1
props.put(key1, newVal1);
//adds key3
props.put(key3, val3);
//key2 should be deleted
writer.write(new MapConfiguration(props), new DefaultPropertyFilter());
Assert.assertEquals(newVal1, new String(curatorFramework.getData().forPath(base + "/" + key1)));
Assert.assertEquals(val3, new String(curatorFramework.getData().forPath(base + "/" + key3)));
Assert.assertNull(curatorFramework.checkExists().forPath(base + "/" + key2));
}
}
Aggregations