List of usage examples for org.apache.commons.configuration BaseConfiguration BaseConfiguration
BaseConfiguration
From source file:com.comcast.viper.flume2storm.sink.StormSinkConfigurationTest.java
/** * Test invalid argument for/*from w w w . jav a 2 s. c o m*/ * {@link StormSinkConfiguration#setEventSenderFactoryClassName(String)} * * @throws F2SConfigurationException * If value is invalid */ @Test(expected = F2SConfigurationException.class) public void testEventSenderFactoryClassName3() throws F2SConfigurationException { Configuration config = new BaseConfiguration(); config.addProperty(StormSinkConfiguration.EVENT_SENDER_FACTORY_CLASS, "not-a-class"); StormSinkConfiguration.from(config); }
From source file:com.vmware.bdd.rest.RestResource.java
/** * Create a cluster//from w w w .j av a 2 s .c om * @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.linkedin.pinot.routing.RoutingTableTest.java
@Test public void testKafkaHighLevelConsumerBasedRoutingTable() throws Exception { RoutingTableBuilder routingStrategy = new KafkaHighLevelConsumerBasedRoutingTableBuilder(); final String group0 = "testResource0_REALTIME_1433316466991_0"; final String group1 = "testResource1_REALTIME_1433316490099_1"; final String group2 = "testResource2_REALTIME_1436589344583_1"; final LLCSegmentName llcSegmentName = new LLCSegmentName("testResource0", 2, 65, System.currentTimeMillis()); HelixExternalViewBasedRouting routingTable = new HelixExternalViewBasedRouting(null, NO_LLC_ROUTING, null, new BaseConfiguration()); Field realtimeRTBField = HelixExternalViewBasedRouting.class .getDeclaredField("_realtimeHLCRoutingTableBuilder"); realtimeRTBField.setAccessible(true); realtimeRTBField.set(routingTable, routingStrategy); ExternalView externalView = new ExternalView("testResource0_REALTIME"); // Toss in an llc segment in the mix. Should not affect the results externalView.setState(llcSegmentName.getSegmentName(), "dataServer_instance_0", "CONSUMING"); externalView.setState(new HLCSegmentName(group0, ALL_PARTITIONS, "0").getSegmentName(), "dataServer_instance_0", "ONLINE"); externalView.setState(new HLCSegmentName(group0, ALL_PARTITIONS, "1").getSegmentName(), "dataServer_instance_1", "ONLINE"); externalView.setState(new HLCSegmentName(group1, ALL_PARTITIONS, "2").getSegmentName(), "dataServer_instance_2", "ONLINE"); externalView.setState(new HLCSegmentName(group1, ALL_PARTITIONS, "3").getSegmentName(), "dataServer_instance_3", "ONLINE"); externalView.setState(new HLCSegmentName(group2, ALL_PARTITIONS, "4").getSegmentName(), "dataServer_instance_4", "ONLINE"); externalView.setState(new HLCSegmentName(group2, ALL_PARTITIONS, "5").getSegmentName(), "dataServer_instance_5", "ONLINE"); routingTable.markDataResourceOnline("testResource0_REALTIME", externalView, generateInstanceConfigs("dataServer_instance", 0, 5)); ExternalView externalView1 = new ExternalView("testResource1_REALTIME"); externalView1.setState(new HLCSegmentName(group0, ALL_PARTITIONS, "10").getSegmentName(), "dataServer_instance_10", "ONLINE"); externalView1.setState(new HLCSegmentName(group0, ALL_PARTITIONS, "11").getSegmentName(), "dataServer_instance_11", "ONLINE"); externalView1.setState(new HLCSegmentName(group0, ALL_PARTITIONS, "12").getSegmentName(), "dataServer_instance_12", "ONLINE"); routingTable.markDataResourceOnline("testResource1_REALTIME", externalView1, generateInstanceConfigs("dataServer_instance", 10, 12)); ExternalView externalView2 = new ExternalView("testResource2_REALTIME"); externalView2.setState(new HLCSegmentName(group0, ALL_PARTITIONS, "20").getSegmentName(), "dataServer_instance_20", "ONLINE"); externalView2.setState(new HLCSegmentName(group0, ALL_PARTITIONS, "21").getSegmentName(), "dataServer_instance_21", "ONLINE"); externalView2.setState(new HLCSegmentName(group0, ALL_PARTITIONS, "22").getSegmentName(), "dataServer_instance_22", "ONLINE"); externalView2.setState(new HLCSegmentName(group1, ALL_PARTITIONS, "23").getSegmentName(), "dataServer_instance_23", "ONLINE"); externalView2.setState(new HLCSegmentName(group1, ALL_PARTITIONS, "24").getSegmentName(), "dataServer_instance_24", "ONLINE"); externalView2.setState(new HLCSegmentName(group1, ALL_PARTITIONS, "25").getSegmentName(), "dataServer_instance_25", "ONLINE"); externalView2.setState(new HLCSegmentName(group2, ALL_PARTITIONS, "26").getSegmentName(), "dataServer_instance_26", "ONLINE"); externalView2.setState(new HLCSegmentName(group2, ALL_PARTITIONS, "27").getSegmentName(), "dataServer_instance_27", "ONLINE"); externalView2.setState(new HLCSegmentName(group2, ALL_PARTITIONS, "28").getSegmentName(), "dataServer_instance_28", "ONLINE"); routingTable.markDataResourceOnline("testResource2_REALTIME", externalView2, generateInstanceConfigs("dataServer_instance", 20, 28)); for (int numRun = 0; numRun < 100; ++numRun) { assertResourceRequest(routingTable, "testResource0_REALTIME", new String[] { "[" + new HLCSegmentName(group0, ALL_PARTITIONS, "0").getSegmentName() + ", " + new HLCSegmentName(group0, ALL_PARTITIONS, "1").getSegmentName() + "]", "[" + new HLCSegmentName(group1, ALL_PARTITIONS, "2").getSegmentName() + ", " + new HLCSegmentName(group1, ALL_PARTITIONS, "3").getSegmentName() + "]", "[" + new HLCSegmentName(group2, ALL_PARTITIONS, "4").getSegmentName() + ", " + new HLCSegmentName(group2, ALL_PARTITIONS, "5").getSegmentName() + "]" }, 2);/* www .j a va 2 s.com*/ } for (int numRun = 0; numRun < 100; ++numRun) { assertResourceRequest(routingTable, "testResource1_REALTIME", new String[] { "[" + new HLCSegmentName(group0, ALL_PARTITIONS, "10").getSegmentName() + ", " + new HLCSegmentName(group0, ALL_PARTITIONS, "11").getSegmentName() + ", " + new HLCSegmentName(group0, ALL_PARTITIONS, "12").getSegmentName() + "]" }, 3); } for (int numRun = 0; numRun < 100; ++numRun) { assertResourceRequest(routingTable, "testResource2_REALTIME", new String[] { "[" + new HLCSegmentName(group0, ALL_PARTITIONS, "20").getSegmentName() + ", " + new HLCSegmentName(group0, ALL_PARTITIONS, "21").getSegmentName() + ", " + new HLCSegmentName(group0, ALL_PARTITIONS, "22").getSegmentName() + "]", "[" + new HLCSegmentName(group1, ALL_PARTITIONS, "23").getSegmentName() + ", " + new HLCSegmentName(group1, ALL_PARTITIONS, "24").getSegmentName() + ", " + new HLCSegmentName(group1, ALL_PARTITIONS, "25").getSegmentName() + "]", "[" + new HLCSegmentName(group2, ALL_PARTITIONS, "26").getSegmentName() + ", " + new HLCSegmentName(group2, ALL_PARTITIONS, "27").getSegmentName() + ", " + new HLCSegmentName(group2, ALL_PARTITIONS, "28").getSegmentName() + "]" }, 3); } }
From source file:co.turnus.analysis.profiler.orcc.dynamic.OrccDynamicProfilerOptions.java
public static Configuration getConfiguration(ILaunchConfiguration configuration, String mode) { Configuration conf = new BaseConfiguration(); try {/*w ww.jav a 2 s.c o m*/ conf.setProperty(SIMULATOR_NAME, NAME); conf.setProperty(VERBOSE, mode.equals("debug")); String stmp = configuration.getAttribute(ORCC_PROJECT, ""); conf.setProperty(ORCC_PROJECT, stmp); stmp = configuration.getAttribute(ORCC_XDF, ""); conf.setProperty(ORCC_XDF, stmp); Boolean btmp = configuration.getAttribute(ORCC_SOURCE_USE, false); conf.setProperty(ORCC_SOURCE_USE, btmp); stmp = configuration.getAttribute(ORCC_SOURCE_FILE, ""); conf.setProperty(ORCC_SOURCE_FILE, stmp); btmp = configuration.getAttribute(CREATE_TRACE_PROJECT, false); conf.setProperty(CREATE_TRACE_PROJECT, btmp); stmp = configuration.getAttribute(TRACE_PROJECT_NAME, ""); conf.setProperty(TRACE_PROJECT_NAME, stmp); btmp = configuration.getAttribute(TRACE_COMPRESS, false); conf.setProperty(TRACE_COMPRESS, btmp); btmp = configuration.getAttribute(EXPORT_PROFILING, false); conf.setProperty(EXPORT_PROFILING, btmp); stmp = configuration.getAttribute(VERSIONER, ""); conf.setProperty(VERSIONER, stmp); stmp = configuration.getAttribute(ORCC_SCHEDULER, ""); conf.setProperty(ORCC_SCHEDULER, stmp); btmp = configuration.getAttribute(TYPE_RESIZE_NATIVEPORTS, false); conf.setProperty(TYPE_RESIZE_NATIVEPORTS, btmp); btmp = configuration.getAttribute(TYPE_RESIZE_TO32BITS, false); conf.setProperty(TYPE_RESIZE_TO32BITS, btmp); btmp = configuration.getAttribute(TYPE_RESIZE_TONBITS, false); conf.setProperty(TYPE_RESIZE_TONBITS, btmp); btmp = configuration.getAttribute(TRANSFO_CONSTANTFOLDING, false); conf.setProperty(TRANSFO_CONSTANTFOLDING, btmp); btmp = configuration.getAttribute(TRANSFO_CONSTANTPROPAGATION, false); conf.setProperty(TRANSFO_CONSTANTPROPAGATION, btmp); btmp = configuration.getAttribute(TRANSFO_DEADACTIONS, false); conf.setProperty(TRANSFO_DEADACTIONS, btmp); btmp = configuration.getAttribute(TRANSFO_EXPREVAL, false); conf.setProperty(TRANSFO_EXPREVAL, btmp); btmp = configuration.getAttribute(TRANSFO_DEADCODE, false); conf.setProperty(TRANSFO_DEADCODE, btmp); btmp = configuration.getAttribute(TRANSFO_VARINIT, false); conf.setProperty(TRANSFO_VARINIT, btmp); int itmp = Integer.parseInt(configuration.getAttribute(FIFO_DEFAULT, "512")); conf.setProperty(FIFO_DEFAULT, itmp); btmp = configuration.getAttribute(STACK_PROTECTION, true); conf.setProperty(STACK_PROTECTION, btmp); // parse the FIFO size mapping Map<String, String> tmpMap = configuration.getAttribute(ORCC_FIFO_MAPPING, new HashMap<String, String>()); Map<String, Integer> fifoMapping = new HashMap<String, Integer>(); for (Entry<String, String> entry : tmpMap.entrySet()) { fifoMapping.put(entry.getKey(), Integer.parseInt(entry.getValue())); } conf.setProperty(ORCC_FIFO_MAPPING, fifoMapping); // store the users notes stmp = configuration.getAttribute(NOTES, ""); conf.setProperty(NOTES, stmp); // set the output path stmp = configuration.getAttribute(OUTPUT_PATH_CUSTOM_USE, false) ? configuration.getAttribute(OUTPUT_PATH_CUSTOM_VALUE, "") : ""; setOutputPath(conf, stmp); // set the export gantt chart options btmp = configuration.getAttribute(EXPORT_GANTT, false); conf.setProperty(EXPORT_GANTT, btmp); if (btmp) { stmp = conf.getString(OUTPUT_PATH); stmp = new File(stmp, "ganttChart." + TurnusExtension.VCD).getAbsolutePath(); conf.setProperty(VCD_FILE, stmp); } return conf; } catch (Exception e) { throw new TurnusRuntimeException("Error parsing the launch configuration options", e); } }
From source file:com.comcast.viper.flume2storm.IntegrationTest.java
/** * Integration test with the Dynamic Location Service and the KryoNet * Connection API/*from w ww .ja va2 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:co.turnus.analysis.pipelining.SimplePipelining.java
private void initTrace() { if (!traceProject.isTraceLoaded()) { Configuration config = new BaseConfiguration(); config.setProperty(SENS_STATEVAR, true); config.setProperty(SENS_FSM, false); config.setProperty(SENS_PORT, false); config.setProperty(SENS_GUARD, false); config.setProperty(SENS_TOKENS, false); traceProject.loadTrace(config);//from ww w. j a v a2 s.co m } }
From source file:com.comcast.viper.flume2storm.sink.StormSinkConfigurationTest.java
/** * Test invalid argument for/*from w w w . j a v a 2s . c om*/ * {@link StormSinkConfiguration#seConnectionParametersFactoryClassName(String)} * * @throws F2SConfigurationException * If value is invalid */ @Test(expected = F2SConfigurationException.class) public void testConnectionParametersFactoryClassName3() throws F2SConfigurationException { Configuration config = new BaseConfiguration(); config.addProperty(StormSinkConfiguration.CONNECTION_PARAMETERS_FACTORY_CLASS, "not-a-class"); StormSinkConfiguration.from(config); }
From source file:cz.cas.lib.proarc.common.process.GenericExternalProcessTest.java
@Test public void testAddInputFile() throws Exception { final String inputName = "input.txt"; final File input = temp.newFile(inputName); final BaseConfiguration conf = new BaseConfiguration(); conf.addProperty(ExternalProcess.PROP_EXEC, "test.sh"); conf.addProperty(ExternalProcess.PROP_ARG, "-i ${input.file.name}"); conf.addProperty(ExternalProcess.PROP_ARG, "-path ${input.file}[0]"); conf.addProperty(ExternalProcess.PROP_ARG, "-o ${input.folder}"); GenericExternalProcess gp = new GenericExternalProcess(conf).addInputFile(input); assertEquals(gp.getParameters().getMap().get(GenericExternalProcess.SRC_NAME_EXT), input.getName()); assertEquals(gp.getParameters().getMap().get(GenericExternalProcess.SRC_PATH), input.getAbsolutePath()); assertEquals(gp.getParameters().getMap().get(GenericExternalProcess.SRC_PARENT), input.getParentFile().getAbsolutePath()); List<String> cmdLines = gp.buildCmdLine(conf); // System.out.println(cmdLines.toString()); }
From source file:co.turnus.analysis.bottlenecks.AlgorithmicBottlenecks.java
private void initTrace() { if (!project.isTraceLoaded()) { Configuration config = new BaseConfiguration(); config.setProperty(SENS_STATEVAR, false); config.setProperty(SENS_FSM, false); config.setProperty(SENS_PORT, false); config.setProperty(SENS_GUARD, false); config.setProperty(SENS_TOKENS, false); project.loadTrace(config);//from w w w. jav a2 s . com } }
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 ww w. ja v a 2s. 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); } }