List of usage examples for org.apache.commons.configuration BaseConfiguration addProperty
public void addProperty(String key, Object value)
From source file:com.comcast.viper.flume2storm.IntegrationTest.java
/** * @throws Exception/*w w w . j ava 2s . co m*/ * If anything went wrong */ @Before public void setup() throws Exception { config = new CombinedConfiguration(); // Flume channel configuration BaseConfiguration channelConfig = new BaseConfiguration(); channelConfig.addProperty("keep-alive", "1"); // Speeds up test channelConfig.addProperty("capacity", "" + NB_EVENTS); config.addConfiguration(channelConfig, CHANNEL_CONFIG); MemoryStorage.getInstance().clear(); }
From source file:com.comcast.viper.flume2storm.IntegrationTest.java
/** * Integration test with the test implementation of the Location Service and * the Connection API/* w w w .j av a2 s.c o m*/ * * @throws Exception * If anything went wrong */ // @Test public void testTestImpl() throws Exception { // Base storm sink configuration BaseConfiguration sinkBaseConfig = new BaseConfiguration(); sinkBaseConfig.addProperty(StormSinkConfiguration.LOCATION_SERVICE_FACTORY_CLASS, SimpleLocationServiceFactory.class.getName()); sinkBaseConfig.addProperty(StormSinkConfiguration.SERVICE_PROVIDER_SERIALIZATION_CLASS, SimpleServiceProviderSerialization.class.getName()); sinkBaseConfig.addProperty(StormSinkConfiguration.EVENT_SENDER_FACTORY_CLASS, SimpleEventSenderFactory.class.getName()); sinkBaseConfig.addProperty(StormSinkConfiguration.CONNECTION_PARAMETERS_FACTORY_CLASS, SimpleConnectionParametersFactory.class.getName()); // First storm sink configuration BaseConfiguration sink1ConnectionParameters = new BaseConfiguration(); sink1ConnectionParameters.addProperty(SimpleConnectionParameters.HOSTNAME, "host1"); sink1ConnectionParameters.addProperty(SimpleConnectionParameters.PORT, 7001); CombinedConfiguration sink1Config = new CombinedConfiguration(); sink1Config.addConfiguration(sinkBaseConfig); sink1Config.addConfiguration(sink1ConnectionParameters, "connectionParams", SimpleConnectionParametersFactory.CONFIG_BASE_NAME); config.addConfiguration(sink1Config, SINK1_CONFIG); // Second storm sink configuration BaseConfiguration sink2ConnectionParameters = new BaseConfiguration(); sink2ConnectionParameters.addProperty(SimpleConnectionParameters.HOSTNAME, "host2"); sink2ConnectionParameters.addProperty(SimpleConnectionParameters.PORT, 7002); CombinedConfiguration sink2Config = new CombinedConfiguration(); sink2Config.addConfiguration(sinkBaseConfig); sink2Config.addConfiguration(sink2ConnectionParameters, "connectionParams", SimpleConnectionParametersFactory.CONFIG_BASE_NAME); config.addConfiguration(sink2Config, SINK2_CONFIG); // Flume-spout configuration BaseConfiguration flumeSpoutConfig = new BaseConfiguration(); flumeSpoutConfig.addProperty(FlumeSpoutConfiguration.LOCATION_SERVICE_FACTORY_CLASS, SimpleLocationServiceFactory.class.getName()); flumeSpoutConfig.addProperty(FlumeSpoutConfiguration.SERVICE_PROVIDER_SERIALIZATION_CLASS, SimpleServiceProviderSerialization.class.getName()); flumeSpoutConfig.addProperty(FlumeSpoutConfiguration.EVENT_RECEPTOR_FACTORY_CLASS, SimpleEventReceptorFactory.class.getName()); config.addConfiguration(flumeSpoutConfig, SPOUT_CONFIG); testAll(); }
From source file:com.comcast.viper.flume2storm.IntegrationTest.java
/** * Integration test with the Dynamic Location Service and the KryoNet * Connection API/*from w w w . jav a 2 s . c o m*/ * * @throws Exception * If anything went wrong */ @Test public void testDynamicLocationServiceWithKryoNet() throws Exception { // // Flume Configuration // // Base storm sink configuration BaseConfiguration sinkBaseConfig = new BaseConfiguration(); sinkBaseConfig.addProperty(StormSinkConfiguration.LOCATION_SERVICE_FACTORY_CLASS, DynamicLocationServiceFactory.class.getName()); sinkBaseConfig.addProperty(StormSinkConfiguration.SERVICE_PROVIDER_SERIALIZATION_CLASS, KryoNetServiceProviderSerialization.class.getName()); sinkBaseConfig.addProperty(StormSinkConfiguration.EVENT_SENDER_FACTORY_CLASS, KryoNetEventSenderFactory.class.getName()); sinkBaseConfig.addProperty(StormSinkConfiguration.CONNECTION_PARAMETERS_FACTORY_CLASS, KryoNetConnectionParametersFactory.class.getName()); // Location Service configuration BaseConfiguration locationServiceConfig = new BaseConfiguration(); locationServiceConfig.addProperty(DynamicLocationServiceConfiguration.CONNECTION_STRING, // zkServer.getConnectString()); "127.0.0.1:" + ZK_PORT); locationServiceConfig.addProperty(DynamicLocationServiceConfiguration.SESSION_TIMEOUT, 2000); locationServiceConfig.addProperty(DynamicLocationServiceConfiguration.CONNECTION_TIMEOUT, 500); locationServiceConfig.addProperty(DynamicLocationServiceConfiguration.RECONNECTION_DELAY, 1000); locationServiceConfig.addProperty(DynamicLocationServiceConfiguration.TERMINATION_TIMEOUT, 2000); locationServiceConfig.addProperty(DynamicLocationServiceConfiguration.BASE_PATH, "/unitTest"); locationServiceConfig.addProperty(DynamicLocationServiceConfiguration.SERVICE_NAME, "ut"); // First storm sink configuration BaseConfiguration sink1ConnectionParameters = new BaseConfiguration(); sink1ConnectionParameters.addProperty(KryoNetConnectionParameters.ADDRESS, KryoNetConnectionParameters.ADDRESS_DEFAULT); sink1ConnectionParameters.addProperty(KryoNetConnectionParameters.PORT, TestUtils.getAvailablePort()); CombinedConfiguration sink1Config = new CombinedConfiguration(); sink1Config.addConfiguration(sinkBaseConfig); sink1Config.addConfiguration(sink1ConnectionParameters, "connectionParams", KryoNetConnectionParametersFactory.CONFIG_BASE_NAME); sink1Config.addConfiguration(locationServiceConfig, "Location Service Configuration", DynamicLocationServiceFactory.CONFIG_BASE_NAME); config.addConfiguration(sink1Config, SINK1_CONFIG); // Second storm sink configuration BaseConfiguration sink2ConnectionParameters = new BaseConfiguration(); sink2ConnectionParameters.addProperty(KryoNetConnectionParameters.ADDRESS, KryoNetConnectionParameters.ADDRESS_DEFAULT); sink2ConnectionParameters.addProperty(KryoNetConnectionParameters.PORT, TestUtils.getAvailablePort()); CombinedConfiguration sink2Config = new CombinedConfiguration(); sink2Config.addConfiguration(sinkBaseConfig); sink2Config.addConfiguration(sink2ConnectionParameters, "connectionParams", KryoNetConnectionParametersFactory.CONFIG_BASE_NAME); sink2Config.addConfiguration(locationServiceConfig, "Location Service Configuration", DynamicLocationServiceFactory.CONFIG_BASE_NAME); config.addConfiguration(sink2Config, SINK2_CONFIG); // // Storm Configuration // // Global KryoNet configuration MapConfiguration kryoConfig = new MapConfiguration(new HashMap<String, Object>()); kryoConfig.addProperty(KryoNetParameters.CONNECTION_TIMEOUT, 500); kryoConfig.addProperty(KryoNetParameters.RECONNECTION_DELAY, 1000); kryoConfig.addProperty(KryoNetParameters.TERMINATION_TO, 2000); // Flume-spout base configuration CombinedConfiguration flumeSpoutBaseConfig = new CombinedConfiguration(); flumeSpoutBaseConfig.addProperty(FlumeSpoutConfiguration.LOCATION_SERVICE_FACTORY_CLASS, DynamicLocationServiceFactory.class.getName()); flumeSpoutBaseConfig.addProperty(FlumeSpoutConfiguration.SERVICE_PROVIDER_SERIALIZATION_CLASS, KryoNetServiceProviderSerialization.class.getName()); flumeSpoutBaseConfig.addProperty(FlumeSpoutConfiguration.EVENT_RECEPTOR_FACTORY_CLASS, KryoNetEventReceptorFactory.class.getName()); // Final flume-spout configuration CombinedConfiguration flumeSpoutConfig = new CombinedConfiguration(); flumeSpoutConfig.addConfiguration(flumeSpoutBaseConfig); flumeSpoutConfig.addConfiguration(kryoConfig, "Kryo Configuration", KryoNetParameters.CONFIG_BASE_NAME); flumeSpoutConfig.addConfiguration(locationServiceConfig, "Location Service Configuration", DynamicLocationServiceFactory.CONFIG_BASE_NAME); config.addConfiguration(flumeSpoutConfig, SPOUT_CONFIG); testAll(); }
From source file:com.comcast.viper.flume2storm.IntegrationTest.java
/** * Integration test with the Dynamic Location Service and the KryoNet * Connection API//from w w w.j a v a 2s. co m * * @throws Exception * If anything went wrong */ @Test public void staticLocationService_KryoNet() throws Exception { // // Flume Configuration // // Base storm sink configuration BaseConfiguration sinkBaseConfig = new BaseConfiguration(); sinkBaseConfig.addProperty(StormSinkConfiguration.LOCATION_SERVICE_FACTORY_CLASS, StaticLocationServiceFactory.class.getName()); sinkBaseConfig.addProperty(StormSinkConfiguration.SERVICE_PROVIDER_SERIALIZATION_CLASS, KryoNetServiceProviderSerialization.class.getName()); sinkBaseConfig.addProperty(StormSinkConfiguration.EVENT_SENDER_FACTORY_CLASS, KryoNetEventSenderFactory.class.getName()); sinkBaseConfig.addProperty(StormSinkConfiguration.CONNECTION_PARAMETERS_FACTORY_CLASS, KryoNetConnectionParametersFactory.class.getName()); // Location Service configuration BaseConfiguration flumeLocationServiceConfig = new BaseConfiguration(); flumeLocationServiceConfig.addProperty(StaticLocationServiceConfiguration.CONFIGURATION_LOADER_CLASS, KryoNetServiceProvidersLoader.class.getName()); // First storm sink configuration int sink1Port = TestUtils.getAvailablePort(); BaseConfiguration sink1ConnectionParameters = new BaseConfiguration(); sink1ConnectionParameters.addProperty(KryoNetConnectionParameters.ADDRESS, KryoNetConnectionParameters.ADDRESS_DEFAULT); sink1ConnectionParameters.addProperty(KryoNetConnectionParameters.PORT, sink1Port); CombinedConfiguration sink1Config = new CombinedConfiguration(); sink1Config.addConfiguration(sinkBaseConfig); sink1Config.addConfiguration(sink1ConnectionParameters, "connectionParams", KryoNetConnectionParametersFactory.CONFIG_BASE_NAME); sink1Config.addConfiguration(flumeLocationServiceConfig, "Location Service Configuration", StaticLocationServiceFactory.CONFIG_BASE_NAME); config.addConfiguration(sink1Config, SINK1_CONFIG); // Second storm sink configuration int sink2Port = TestUtils.getAvailablePort(); BaseConfiguration sink2ConnectionParameters = new BaseConfiguration(); sink2ConnectionParameters.addProperty(KryoNetConnectionParameters.ADDRESS, KryoNetConnectionParameters.ADDRESS_DEFAULT); sink2ConnectionParameters.addProperty(KryoNetConnectionParameters.PORT, sink2Port); CombinedConfiguration sink2Config = new CombinedConfiguration(); sink2Config.addConfiguration(sinkBaseConfig); sink2Config.addConfiguration(sink2ConnectionParameters, "connectionParams", KryoNetConnectionParametersFactory.CONFIG_BASE_NAME); sink2Config.addConfiguration(flumeLocationServiceConfig, "Location Service Configuration", StaticLocationServiceFactory.CONFIG_BASE_NAME); config.addConfiguration(sink2Config, SINK2_CONFIG); // // Storm Configuration // String sp1Id = "sp1Id"; String sp2Id = "sp2Id"; BaseConfiguration stormLocationServiceBaseConfig = new BaseConfiguration(); stormLocationServiceBaseConfig.addProperty(StaticLocationServiceConfiguration.CONFIGURATION_LOADER_CLASS, KryoNetServiceProvidersLoader.class.getName()); stormLocationServiceBaseConfig.addProperty(StaticLocationServiceConfiguration.SERVICE_PROVIDER_LIST, StringUtils.join(sp1Id, StaticLocationServiceConfiguration.SERVICE_PROVIDER_LIST_SEPARATOR, sp2Id)); BaseConfiguration stormLocationServiceSink1Config = new BaseConfiguration(); stormLocationServiceSink1Config.addProperty(KryoNetConnectionParameters.ADDRESS, KryoNetConnectionParameters.ADDRESS_DEFAULT); stormLocationServiceSink1Config.addProperty(KryoNetConnectionParameters.PORT, sink1Port); BaseConfiguration stormLocationServiceSink2Config = new BaseConfiguration(); stormLocationServiceSink2Config.addProperty(KryoNetConnectionParameters.ADDRESS, KryoNetConnectionParameters.ADDRESS_DEFAULT); stormLocationServiceSink2Config.addProperty(KryoNetConnectionParameters.PORT, sink2Port); CombinedConfiguration stormLocationServiceConfig = new CombinedConfiguration(); stormLocationServiceConfig.addConfiguration(stormLocationServiceBaseConfig); stormLocationServiceConfig.addConfiguration(stormLocationServiceSink1Config, "sink1", StringUtils.join(StaticLocationServiceConfiguration.SERVICE_PROVIDER_BASE_DEFAULT, ".", sp1Id)); stormLocationServiceConfig.addConfiguration(stormLocationServiceSink2Config, "sink2", StringUtils.join(StaticLocationServiceConfiguration.SERVICE_PROVIDER_BASE_DEFAULT, ".", sp2Id)); // Global KryoNet configuration MapConfiguration kryoConfig = new MapConfiguration(new HashMap<String, Object>()); kryoConfig.addProperty(KryoNetParameters.CONNECTION_TIMEOUT, 500); kryoConfig.addProperty(KryoNetParameters.RECONNECTION_DELAY, 1000); kryoConfig.addProperty(KryoNetParameters.TERMINATION_TO, 2000); // Flume-spout base configuration CombinedConfiguration flumeSpoutBaseConfig = new CombinedConfiguration(); flumeSpoutBaseConfig.addProperty(FlumeSpoutConfiguration.LOCATION_SERVICE_FACTORY_CLASS, StaticLocationServiceFactory.class.getName()); flumeSpoutBaseConfig.addProperty(FlumeSpoutConfiguration.SERVICE_PROVIDER_SERIALIZATION_CLASS, KryoNetServiceProviderSerialization.class.getName()); flumeSpoutBaseConfig.addProperty(FlumeSpoutConfiguration.EVENT_RECEPTOR_FACTORY_CLASS, KryoNetEventReceptorFactory.class.getName()); // Final flume-spout configuration CombinedConfiguration flumeSpoutConfig = new CombinedConfiguration(); flumeSpoutConfig.addConfiguration(flumeSpoutBaseConfig); flumeSpoutConfig.addConfiguration(kryoConfig, "Kryo Configuration", KryoNetParameters.CONFIG_BASE_NAME); flumeSpoutConfig.addConfiguration(stormLocationServiceConfig, "Location Service Configuration", StaticLocationServiceFactory.CONFIG_BASE_NAME); config.addConfiguration(flumeSpoutConfig, SPOUT_CONFIG); testAll(); }
From source file:com.vmware.bdd.rest.RestResource.java
/** * Create a cluster/*from w w w .java 2 s. c o m*/ * @param createSpec create specification * @param request * @return Return a response with Accepted status and put task uri in the Location of header that can be used to monitor the progress */ @RequestMapping(value = "/clusters", method = RequestMethod.POST, consumes = "application/json") @ResponseStatus(HttpStatus.ACCEPTED) public void createCluster(@RequestBody ClusterCreate createSpec, @RequestParam(value = "skiprefreshvc", required = false) boolean skipRefreshVC, HttpServletRequest request, HttpServletResponse response) throws Exception { verifyInitialized(); String clusterName = createSpec.getName(); logger.info(String.format("The specified node template name for creating cluster %s is %s", clusterName, createSpec.getTemplateName())); if (!CommonUtil.validateClusterName(clusterName)) { throw BddException.INVALID_PARAMETER("cluster name", clusterName); } if (CommonUtil.isBlank(createSpec.getAppManager())) { createSpec.setAppManager(Constants.IRONFAN); } else { AppManagerEntity appManager = appManagerService.findAppManagerByName(createSpec.getAppManager()); if (appManager == null) { throw BddException.NOT_FOUND("application manager", createSpec.getAppManager()); } } BaseConfiguration params = new BaseConfiguration(); params.addProperty(Constants.SKIP_REFRESH_VC, skipRefreshVC); long jobExecutionId = clusterMgr.createCluster(createSpec, params); redirectRequest(jobExecutionId, request, response); }
From source file:com.vmware.bdd.rest.RestResource.java
/** * Expand the number of nodes in a node group * @param clusterName//from w w w . ja v a2 s.c o m * @param groupName * @param instanceNum The target instance number after resize. It can be larger/smaller than existing instance number in this node group * @param request * @return Return a response with Accepted status and put task uri in the Location of header that can be used to monitor the progress */ @RequestMapping(value = "/cluster/{clusterName}/nodegroup/{groupName}/instancenum", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.ACCEPTED) public void resizeCluster(@PathVariable("clusterName") String clusterName, @PathVariable("groupName") String groupName, @RequestBody Integer instanceNum, @RequestParam(value = "force", required = false, defaultValue = "false") Boolean force, @RequestParam(value = "skiprefreshvc", required = false) boolean skipRefreshVC, HttpServletRequest request, HttpServletResponse response) throws Exception { verifyInitialized(); if (CommonUtil.isBlank(clusterName) || !CommonUtil.validateClusterName(clusterName)) { throw BddException.INVALID_PARAMETER("cluster name", clusterName); } if (CommonUtil.isBlank(groupName) || !CommonUtil.validateNodeGroupName(groupName)) { throw BddException.INVALID_PARAMETER("node group name", groupName); } if (instanceNum <= 0) { throw BddException.INVALID_PARAMETER("node group instance number", String.valueOf(instanceNum)); } BaseConfiguration params = new BaseConfiguration(); params.addProperty(Constants.SKIP_REFRESH_VC, skipRefreshVC); Long taskId = clusterMgr.resizeCluster(clusterName, groupName, instanceNum, force, params); redirectRequest(taskId, request, response); }
From source file:com.vmware.bdd.rest.RestResource.java
/** * Start or stop a normal cluster, or resume a failed cluster after adjusting the resources allocated to this cluster * @param clusterName//from www . jav a2s . c o m * @param state Can be start, stop, or resume * @param request * @return Return a response with Accepted status and put task uri in the Location of header that can be used to monitor the progress */ @RequestMapping(value = "/cluster/{clusterName}/action", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.ACCEPTED) public void startStopResumeCluster(@PathVariable("clusterName") String clusterName, @RequestParam(value = "state", required = true) String state, @RequestParam(value = "force", required = false, defaultValue = "false") Boolean force, @RequestParam(value = "skiprefreshvc", required = false) boolean skipRefreshVC, HttpServletRequest request, HttpServletResponse response) throws Exception { verifyInitialized(); clusterName = CommonUtil.decode(clusterName); if (CommonUtil.isBlank(clusterName) || !CommonUtil.validateClusterName(clusterName)) { throw BddException.INVALID_PARAMETER("cluster name", clusterName); } Long taskId; if (state.equals("stop")) { taskId = clusterMgr.stopCluster(clusterName); redirectRequest(taskId, request, response); } else if (state.equals("start")) { taskId = clusterMgr.startCluster(clusterName, force); redirectRequest(taskId, request, response); } else if (state.equals("resume")) { BaseConfiguration params = new BaseConfiguration(); params.addProperty(Constants.SKIP_REFRESH_VC, skipRefreshVC); taskId = clusterMgr.resumeClusterCreation(clusterName, params); redirectRequest(taskId, request, response); } else { throw BddException.INVALID_PARAMETER("cluster state", state); } }
From source file:org.apache.james.jmap.methods.integration.SpamAssassinModule.java
private MailetConfigImpl spamAssassinMailetConfig() { BaseConfiguration baseConfiguration = new BaseConfiguration(); Host host = Host.from(spamAssassinExtension.getSpamAssassin().getIp(), spamAssassinExtension.getSpamAssassin().getBindingPort()); baseConfiguration.addProperty(org.apache.james.transport.mailets.SpamAssassin.SPAMD_HOST, host.getHostName());//from ww w . j a va 2s . c o m baseConfiguration.addProperty(org.apache.james.transport.mailets.SpamAssassin.SPAMD_PORT, host.getPort()); MailetConfigImpl mailetConfig = new MailetConfigImpl(); mailetConfig.setConfiguration(baseConfiguration); return mailetConfig; }
From source file:org.finra.herd.dao.ReloadablePropertySourceTest.java
/** * Asserts that when a property is requested from the configruation, and it fires an error event (ex. Database is not available), the previously stored * values are not cleared.//from w w w . j av a 2 s . c om */ @Test public void testAssertGetPropertyErrorReturnPreviousValue() throws Exception { // Get a reloadable property source that loads properties from the configuration every time a property is read. BaseConfiguration configuration = new BaseConfiguration() { @Override public Object getProperty(String key) { fireError(EVENT_READ_PROPERTY, key, null, new IllegalStateException("test exception")); return null; } }; configuration.addProperty(TEST_KEY, TEST_VALUE_1); ReloadablePropertySource reloadablePropertySource = getNewReloadablePropertiesSource(0L, configuration); verifyPropertySourceValue(reloadablePropertySource, TEST_VALUE_1); }
From source file:org.neo4j.server.configuration.validation.DatabaseLocationMustBeSpecifiedRuleTest.java
@Test(expected = RuleFailedException.class) public void shouldFailWhenDatabaseLocationIsAbsentFromConfig() throws RuleFailedException { DatabaseLocationMustBeSpecifiedRule theRule = new DatabaseLocationMustBeSpecifiedRule(); BaseConfiguration config = new BaseConfiguration(); config.addProperty("foo", "bar"); theRule.validate(config);/*from w w w.j a v a2 s. c om*/ }