List of usage examples for org.apache.commons.configuration Configuration addProperty
void addProperty(String key, Object value);
From source file:com.comcast.viper.flume2storm.sink.StormSinkConfigurationTest.java
/** * Test {@link StormSinkConfiguration#from(Configuration)} * * @throws F2SConfigurationException// www .j av a 2s .co m * If the configuration is invalid */ @Test public void testFromConfiguration() throws F2SConfigurationException { int batchSize = 200; String locationServiceFactoryClassName = SimpleLocationServiceFactory.class.getCanonicalName(); String serviceProviderSerializationClassName = SimpleServiceProviderSerialization.class.getCanonicalName(); String eventSenderFactoryClassName = SimpleEventSenderFactory.class.getCanonicalName(); String connectionParametersFactoryClassName = SimpleConnectionParametersFactory.class.getCanonicalName(); Configuration config = new BaseConfiguration(); config.addProperty(StormSinkConfiguration.BATCH_SIZE, batchSize); config.addProperty(StormSinkConfiguration.LOCATION_SERVICE_FACTORY_CLASS, locationServiceFactoryClassName); config.addProperty(StormSinkConfiguration.SERVICE_PROVIDER_SERIALIZATION_CLASS, serviceProviderSerializationClassName); config.addProperty(StormSinkConfiguration.EVENT_SENDER_FACTORY_CLASS, eventSenderFactoryClassName); config.addProperty(StormSinkConfiguration.CONNECTION_PARAMETERS_FACTORY_CLASS, connectionParametersFactoryClassName); StormSinkConfiguration stormSinkConfiguration = StormSinkConfiguration.from(config); Assert.assertEquals(batchSize, stormSinkConfiguration.getBatchSize()); Assert.assertEquals(locationServiceFactoryClassName, stormSinkConfiguration.getLocationServiceFactoryClassName()); Assert.assertEquals(serviceProviderSerializationClassName, stormSinkConfiguration.getServiceProviderSerializationClassName()); Assert.assertEquals(eventSenderFactoryClassName, stormSinkConfiguration.getEventSenderFactoryClassName()); Assert.assertEquals(connectionParametersFactoryClassName, stormSinkConfiguration.getConnectionParametersFactoryClassName()); }
From source file:com.linkedin.pinot.broker.broker.HelixBrokerStarterTest.java
@BeforeTest public void setUp() throws Exception { _zookeeperInstance = ZkStarter.startLocalZkServer(); _zkClient = new ZkClient(ZkStarter.DEFAULT_ZK_STR); final String instanceId = "localhost_helixController"; _pinotResourceManager = new PinotHelixResourceManager(ZkStarter.DEFAULT_ZK_STR, HELIX_CLUSTER_NAME, instanceId, null, 10000L, true, /*isUpdateStateModel=*/false); _pinotResourceManager.start();/* w w w . ja va 2s . c om*/ final String helixZkURL = HelixConfig.getAbsoluteZkPathForHelix(ZkStarter.DEFAULT_ZK_STR); _helixZkManager = HelixSetupUtils.setup(HELIX_CLUSTER_NAME, helixZkURL, instanceId, /*isUpdateStateModel=*/false); _helixAdmin = _helixZkManager.getClusterManagmentTool(); Thread.sleep(3000); final Configuration pinotHelixBrokerProperties = DefaultHelixBrokerConfig.getDefaultBrokerConf(); pinotHelixBrokerProperties.addProperty(CommonConstants.Helix.KEY_OF_BROKER_QUERY_PORT, 8943); _helixBrokerStarter = new HelixBrokerStarter(HELIX_CLUSTER_NAME, ZkStarter.DEFAULT_ZK_STR, pinotHelixBrokerProperties); Thread.sleep(1000); ControllerRequestBuilderUtil.addFakeBrokerInstancesToAutoJoinHelixCluster(HELIX_CLUSTER_NAME, ZkStarter.DEFAULT_ZK_STR, 5, true); ControllerRequestBuilderUtil.addFakeDataInstancesToAutoJoinHelixCluster(HELIX_CLUSTER_NAME, ZkStarter.DEFAULT_ZK_STR, 1, true); final String tableName = "dining"; JSONObject buildCreateOfflineTableV2JSON = ControllerRequestBuilderUtil .buildCreateOfflineTableJSON(tableName, null, null, 1); AbstractTableConfig config = AbstractTableConfig.init(buildCreateOfflineTableV2JSON.toString()); _pinotResourceManager.addTable(config); for (int i = 1; i <= 5; i++) { addOneSegment(tableName); Thread.sleep(2000); final ExternalView externalView = _helixAdmin.getResourceExternalView(HELIX_CLUSTER_NAME, TableNameBuilder.OFFLINE_TABLE_NAME_BUILDER.forTable(tableName)); Assert.assertEquals(externalView.getPartitionSet().size(), i); } }
From source file:edu.kit.dama.staging.entities.AdalapiProtocolConfiguration.java
/** * Convert this entity in an ADALAPI-compliant configuration. Therefor, all * attributes and custom properties are put into a Configuration object as * described in the IExternalProtocolConfigurator interface. * * @return The configuration object./*w w w. j a v a2 s . c om*/ * * @see IExternalProtocolConfigurator */ public Configuration toConfiguration() { Configuration config = new HierarchicalConfiguration(); config.addProperty(ProtocolSettings.PROTOCOL_IDENTIFIER_PROPERTY, identifier); config.addProperty(ProtocolSettings.PROTOCOL_CLASS_PROPERTY, protocolClass); config.addProperty(ProtocolSettings.AUTH_CLASS_PROPERTY, authenticatorClass); Map<String, Object> props = getCustomPropertiesAsObject(); for (String o : props.keySet()) { config.addProperty(o, props.get(o)); } return config; }
From source file:com.netflix.config.ConcurrentMapConfigurationTest.java
private void testConfigurationAdd(Configuration conf) { long start = System.currentTimeMillis(); for (int i = 0; i < 100000; i++) { conf.addProperty("add-key" + i, "value"); }//from w ww . j a v a 2 s . c o m long duration = System.currentTimeMillis() - start; System.out.println("Add property for " + conf + " took " + duration + " ms"); }
From source file:com.linkedin.pinot.common.metadata.IndexLoadingConfigMetadataTest.java
private Configuration getTestResourceMetadata() { Configuration resourceMetadata = new PropertiesConfiguration(); String columnNames = null;//ww w . ja v a2 s . co m for (int i = 0; i < 10; ++i) { if (columnNames == null) { columnNames = ("col" + i); } else { columnNames += (", col" + i); } } resourceMetadata.addProperty(KEY_OF_LOADING_INVERTED_INDEX, columnNames); resourceMetadata.addProperty(KEY_OF_ENABLE_DEFAULT_COLUMNS, true); return resourceMetadata; }
From source file:com.linkedin.pinot.perf.PerfBenchmarkDriver.java
public void startServer() throws Exception { if (!conf.shouldStartServer()) { LOGGER.info("Skipping start server step. Assumes server is already started"); return;// w ww .j ava 2 s. c om } Configuration serverConfiguration = new PropertiesConfiguration(); serverConfiguration.addProperty(CommonConstants.Server.CONFIG_OF_INSTANCE_DATA_DIR.toString(), serverInstanceDataDir); serverConfiguration.addProperty(CommonConstants.Server.CONFIG_OF_INSTANCE_SEGMENT_TAR_DIR.toString(), serverInstanceSegmentTarDir); serverConfiguration.setProperty("instanceId", serverInstanceName); HelixServerStarter helixServerStarter = new HelixServerStarter(clusterName, zkAddress, serverConfiguration); }
From source file:ai.grakn.graql.internal.analytics.MedianVertexProgram.java
@Override public void storeState(final Configuration configuration) { super.storeState(configuration); statisticsResourceTypeIds// w w w. ja v a 2 s .c o m .forEach(typeId -> configuration.addProperty(RESOURCE_TYPE + "." + typeId, typeId)); }
From source file:grakn.core.graql.analytics.MedianVertexProgram.java
@Override public void storeState(final Configuration configuration) { super.storeState(configuration); statisticsResourceLabelIds/*from ww w . j av a 2 s . co m*/ .forEach(typeId -> configuration.addProperty(RESOURCE_TYPE + "." + typeId, typeId)); }
From source file:fr.mby.portal.coreimpl.configuration.PropertiesConfigurationManagerTest.java
/** * test 1./*from ww w . j a v a 2 s. co m*/ * * @throws Exception */ @Test public void test1() throws Exception { final Configuration config1 = this.configManager.initConfiguration(PropertiesConfigurationManagerTest.KEY1, PropertiesConfigurationManagerTest.TYPE1, PropertiesConfigurationManagerTest.TAG1); Assert.assertNotNull("Config not initialized !", config1); config1.addProperty("key1", 42L); final Configuration config2 = this.configManager.getConfiguration(PropertiesConfigurationManagerTest.KEY1); Assert.assertNotNull("Config cannot be retrieved !", config2); Assert.assertEquals("Bad property value in config !", 42L, config2.getLong("key1")); Assert.assertNotNull("Tags cannot be retrieved !", this.configManager.getConfigurationTags()); Assert.assertEquals("Tags count bad !", 1, this.configManager.getConfigurationTags().size()); final String configKey = this.configManager.getConfigurationTags().iterator().next(); Assert.assertEquals("Tag name bad !", PropertiesConfigurationManagerTest.KEY1, configKey); Assert.assertNotNull("Empty collection not returned !", this.configManager.getConfigurationKeys("unknownTag")); }
From source file:fr.mby.portal.coreimpl.configuration.PropertiesConfigurationManagerTest.java
/** * test 2./*www .jav a2s . c o m*/ * * @throws Exception */ @Test public void test2() throws Exception { final Configuration config1 = this.configManager.initConfiguration(PropertiesConfigurationManagerTest.KEY2, PropertiesConfigurationManagerTest.TYPE2, PropertiesConfigurationManagerTest.TAG2); Assert.assertNotNull("Config not initialized !", config1); config1.addProperty("key2", "Value2"); final Configuration config2 = this.configManager.getConfiguration(PropertiesConfigurationManagerTest.KEY2); Assert.assertNotNull("Config cannot be retrieved !", config2); Assert.assertEquals("Bad property value in config !", "Value2", config2.getString("key2")); Assert.assertNotNull("Tags cannot be retrieved !", this.configManager.getConfigurationTags()); Assert.assertEquals("Tags count bad !", 1, this.configManager.getConfigurationTags().size()); final String configKey = this.configManager.getConfigurationTags().iterator().next(); Assert.assertEquals("Tag name bad !", PropertiesConfigurationManagerTest.KEY2, configKey); Assert.assertNotNull("Empty collection not returned !", this.configManager.getConfigurationKeys("unknownTag")); }