List of usage examples for org.apache.commons.configuration BaseConfiguration BaseConfiguration
BaseConfiguration
From source file:com.comcast.viper.flume2storm.IntegrationTest.java
/** * Integration test with the test implementation of the Location Service and * the Connection API//from w ww.j ava2 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.linkedin.pinot.broker.routing.builder.KafkaLowLevelConsumerRoutingTableBuilderTest.java
@Test public void testMultipleConsumingSegments() { final int SEGMENT_COUNT = 10; final int ONLINE_SEGMENT_COUNT = 8; final int CONSUMING_SEGMENT_COUNT = SEGMENT_COUNT - ONLINE_SEGMENT_COUNT; KafkaLowLevelConsumerRoutingTableBuilder routingTableBuilder = new KafkaLowLevelConsumerRoutingTableBuilder(); routingTableBuilder.init(new BaseConfiguration(), null, null); List<SegmentName> segmentNames = new ArrayList<SegmentName>(); for (int i = 0; i < SEGMENT_COUNT; ++i) { segmentNames.add(new LLCSegmentName("table", 0, i, System.currentTimeMillis())); }/* w w w . j a v a 2 s. c om*/ List<InstanceConfig> instanceConfigs = new ArrayList<InstanceConfig>(); InstanceConfig instanceConfig = new InstanceConfig("Server_localhost_1234"); instanceConfigs.add(instanceConfig); instanceConfig.getRecord().setSimpleField(CommonConstants.Helix.IS_SHUTDOWN_IN_PROGRESS, "false"); // Generate an external view for a single server with some consuming segments ExternalView externalView = new ExternalView("table_REALTIME"); for (int i = 0; i < ONLINE_SEGMENT_COUNT; i++) { externalView.setState(segmentNames.get(i).getSegmentName(), "Server_localhost_1234", "ONLINE"); } for (int i = ONLINE_SEGMENT_COUNT; i < SEGMENT_COUNT; ++i) { externalView.setState(segmentNames.get(i).getSegmentName(), "Server_localhost_1234", "CONSUMING"); } routingTableBuilder.computeRoutingTableFromExternalView("table", externalView, instanceConfigs); List<Map<String, List<String>>> routingTables = routingTableBuilder.getRoutingTables(); for (Map<String, List<String>> routingTable : routingTables) { for (List<String> segmentsForServer : routingTable.values()) { assertEquals(segmentsForServer.size(), ONLINE_SEGMENT_COUNT + 1); // Should only contain the first consuming segment, not the second assertTrue(segmentsForServer.contains(segmentNames.get(ONLINE_SEGMENT_COUNT).getSegmentName()), "Segment set does not contain the first segment in consuming state"); for (int i = ONLINE_SEGMENT_COUNT + 1; i < SEGMENT_COUNT; i++) { assertFalse(segmentsForServer.contains(segmentNames.get(i).getSegmentName()), "Segment set contains a segment in consuming state that should not be there"); } } } }
From source file:com.linkedin.pinot.routing.builder.KafkaLowLevelConsumerRoutingTableBuilderTest.java
@Test public void testMultipleConsumingSegments() { final int SEGMENT_COUNT = 10; final int ONLINE_SEGMENT_COUNT = 8; final int CONSUMING_SEGMENT_COUNT = SEGMENT_COUNT - ONLINE_SEGMENT_COUNT; KafkaLowLevelConsumerRoutingTableBuilder routingTableBuilder = new KafkaLowLevelConsumerRoutingTableBuilder(); routingTableBuilder.init(new BaseConfiguration()); List<SegmentName> segmentNames = new ArrayList<SegmentName>(); for (int i = 0; i < SEGMENT_COUNT; ++i) { segmentNames.add(new LLCSegmentName("table", 0, i, System.currentTimeMillis())); }/*from w w w.j av a 2s.c o m*/ List<InstanceConfig> instanceConfigs = new ArrayList<InstanceConfig>(); InstanceConfig instanceConfig = new InstanceConfig("Server_localhost_1234"); instanceConfigs.add(instanceConfig); instanceConfig.getRecord().setSimpleField(CommonConstants.Helix.IS_SHUTDOWN_IN_PROGRESS, "false"); // Generate an external view for a single server with some consuming segments ExternalView externalView = new ExternalView("table_REALTIME"); for (int i = 0; i < ONLINE_SEGMENT_COUNT; i++) { externalView.setState(segmentNames.get(i).getSegmentName(), "Server_localhost_1234", "ONLINE"); } for (int i = ONLINE_SEGMENT_COUNT; i < SEGMENT_COUNT; ++i) { externalView.setState(segmentNames.get(i).getSegmentName(), "Server_localhost_1234", "CONSUMING"); } List<ServerToSegmentSetMap> routingTables = routingTableBuilder.computeRoutingTableFromExternalView("table", externalView, instanceConfigs); for (ServerToSegmentSetMap routingTable : routingTables) { for (String server : routingTable.getServerSet()) { Set<String> segmentSet = routingTable.getSegmentSet(server); assertEquals(segmentSet.size(), ONLINE_SEGMENT_COUNT + 1, ""); // Should only contain the first consuming segment, not the second assertTrue(segmentSet.contains(segmentNames.get(ONLINE_SEGMENT_COUNT).getSegmentName()), "Segment set does not contain the first segment in consuming state"); for (int i = ONLINE_SEGMENT_COUNT + 1; i < SEGMENT_COUNT; i++) { assertFalse(segmentSet.contains(segmentNames.get(i).getSegmentName()), "Segment set contains a segment in consuming state that should not be there"); } } } }
From source file:com.datastax.openflights.OpenflightsBulkLoaderVertexProgram.java
@Override public void loadState(final Graph graph, final Configuration config) { configuration = new BaseConfiguration(); if (config != null) { ConfigurationUtils.copy(config, configuration); }//from w w w . j a v a 2 s . c om intermediateBatchSize = configuration.getLong(INTERMEDIATE_BATCH_SIZE_CFG_KEY, 0L); elementComputeKeys .add(configuration.getString(BULK_LOADER_VERTEX_ID_CFG_KEY, DEFAULT_BULK_LOADER_VERTEX_ID)); bulkLoader = createBulkLoader(); }
From source file:co.turnus.analysis.buffers.MpcBoundedSchedulingCliLauncher.java
private static Configuration parseCommandLine(CommandLine cmd) throws ParseException { Configuration config = new BaseConfiguration(); StringBuffer s = new StringBuffer(); config.setProperty(VERBOSE, cmd.hasOption("v")); if (!cmd.hasOption("t")) { s.append("Trace project directory not specified. "); } else {// w w w . ja v a 2 s . c o m String fileName = cmd.getOptionValue("t", ""); File file = new File(fileName); if (file == null || !file.exists()) { s.append("Trace project does not exists. "); } else { config.setProperty(TRACE_PROJECT, fileName); } } if (!cmd.hasOption("o")) { s.append("Output directory not specified. "); } else { String fileName = cmd.getOptionValue("o", ""); File file = new File(fileName); if (file == null || !file.exists()) { s.append("Output directory does not exists. "); } else { config.setProperty(OUTPUT_PATH, fileName); } } if (cmd.hasOption("xls")) { String fileName = cmd.getOptionValue("xls", ""); if (fileName == null || fileName.isEmpty()) { s.append("XLS file name is not correct. "); } else { config.setProperty(XLS, fileName); } } if (cmd.hasOption("bxdf")) { String fileName = cmd.getOptionValue("bxdf", ""); if (fileName == null || fileName.isEmpty()) { s.append("BXDF file name is not correct. "); } else { config.setProperty(BXDF, fileName); } } if (!cmd.hasOption("s") && !cmd.hasOption("d")) { s.append("please choose at least one option for the trace cut (max steps or max degree) "); } if (cmd.hasOption("s")) { String[] sArray = cmd.getOptionValues("s"); if (sArray.length == 1) { int value = Integer.parseInt(sArray[0]); config.addProperty(TRACE_CUT_STEPS_MIN, value); config.addProperty(TRACE_CUT_STEPS_MAX, value); config.addProperty(TRACE_CUT_STEPS_NUM, 1); } else if (sArray.length == 2) { int min = Integer.parseInt(sArray[0]); int max = Integer.parseInt(sArray[1]); config.addProperty(TRACE_CUT_STEPS_MIN, min); config.addProperty(TRACE_CUT_STEPS_MAX, max); config.addProperty(TRACE_CUT_STEPS_NUM, max - min + 1); } else { int min = Integer.parseInt(sArray[0]); int points = Integer.parseInt(sArray[1]); int max = Integer.parseInt(sArray[2]); config.addProperty(TRACE_CUT_STEPS_MIN, min); config.addProperty(TRACE_CUT_STEPS_NUM, points); config.addProperty(TRACE_CUT_STEPS_MAX, max); } } if (cmd.hasOption("d")) { String[] sArray = cmd.getOptionValues("d"); if (sArray.length == 1) { int value = Integer.parseInt(sArray[0]); config.addProperty(TRACE_CUT_DEGREE_MIN, value); config.addProperty(TRACE_CUT_DEGREE_MAX, value); config.addProperty(TRACE_CUT_DEGREE_NUM, 1); } else if (sArray.length == 2) { int min = Integer.parseInt(sArray[0]); int max = Integer.parseInt(sArray[1]); config.addProperty(TRACE_CUT_DEGREE_MIN, min); config.addProperty(TRACE_CUT_DEGREE_MAX, max); config.addProperty(TRACE_CUT_DEGREE_NUM, max - min + 1); } else { int min = Integer.parseInt(sArray[0]); int points = Integer.parseInt(sArray[1]); int max = Integer.parseInt(sArray[2]); config.addProperty(TRACE_CUT_DEGREE_MIN, min); config.addProperty(TRACE_CUT_DEGREE_NUM, points); config.addProperty(TRACE_CUT_DEGREE_MAX, max); } } if (cmd.hasOption("c")) { String[] sArray = cmd.getOptionValues("c"); if (sArray.length == 1) { int value = Integer.parseInt(sArray[0]); config.addProperty(HC_MIN, value); config.addProperty(HC_MAX, value); config.addProperty(HC_NUM, 1); } else if (sArray.length == 2) { int min = Integer.parseInt(sArray[0]); int max = Integer.parseInt(sArray[1]); config.addProperty(HC_MIN, min); config.addProperty(HC_MAX, max); config.addProperty(HC_NUM, max - min + 1); } else { int min = Integer.parseInt(sArray[0]); int points = Integer.parseInt(sArray[1]); int max = Integer.parseInt(sArray[2]); config.addProperty(HC_MIN, min); config.addProperty(HC_NUM, points); config.addProperty(HC_MAX, max); } } else { s.append("the control horizon has not been choosed"); } boolean recovery = cmd.hasOption("r"); config.setProperty(RECOVERY, recovery); boolean bitAccurate = cmd.hasOption("b"); config.setProperty(BIT_ACCURATE, bitAccurate); boolean zeroStartingPoint = cmd.hasOption("z"); config.setProperty(ZERO_STARTING_POINT, zeroStartingPoint); boolean quickCut = cmd.hasOption("q"); config.setProperty(QUICK_CUT, quickCut); String error = s.toString(); if (!error.isEmpty()) { throw new ParseException(error); } return config; }
From source file:com.comcast.viper.flume2storm.sink.StormSinkConfigurationTest.java
/** * Test invalid argument for//w w w . ja v a2s. c o m * {@link StormSinkConfiguration#setServiceProviderSerializationClassName(String)} * * @throws F2SConfigurationException * If value is invalid */ @Test(expected = F2SConfigurationException.class) public void testServiceProviderSerializationClassName3() throws F2SConfigurationException { Configuration config = new BaseConfiguration(); config.addProperty(StormSinkConfiguration.SERVICE_PROVIDER_SERIALIZATION_CLASS, "not-a-class"); StormSinkConfiguration.from(config); }
From source file:co.turnus.analysis.buffers.BoundedBufferScheduling.java
public BoundedBufferScheduling(TraceProject traceProject) { // unload trace if loaded and not sensitive to token dependencies if (traceProject.isTraceLoaded()) { if (!traceProject.getTrace().isSensitive(Kind.TOKENS)) { traceProject.unloadTrace();/*from w ww.java 2 s. c om*/ } } if (!traceProject.isTraceLoaded()) { Configuration config = new BaseConfiguration(); config.setProperty(SENS_FSM, false); config.setProperty(SENS_GUARD, false); config.setProperty(SENS_PORT, false); config.setProperty(SENS_STATEVAR, false); config.setProperty(SENS_TOKENS, true); traceProject.loadTrace(config); } this.traceProject = traceProject; }
From source file:com.netflix.config.ConcurrentMapConfigurationTest.java
@Test public void testPerformance() { MyListener listener = new MyListener(); BaseConfiguration baseConfig = new BaseConfiguration(); baseConfig.addConfigurationListener(listener); HierarchicalConfiguration hConfig = new HierarchicalConfiguration(); hConfig.addConfigurationListener(listener); ConcurrentMapConfiguration conf = new ConcurrentMapConfiguration(); conf.addConfigurationListener(listener); testConfigurationSet(baseConfig);/* www . j av a 2s .c o m*/ testConfigurationSet(hConfig); testConfigurationSet(conf); testConfigurationAdd(baseConfig); testConfigurationAdd(hConfig); testConfigurationAdd(conf); testConfigurationGet(baseConfig); testConfigurationGet(hConfig); testConfigurationGet(conf); }
From source file:com.linkedin.pinot.broker.routing.RoutingTableTest.java
@Test(enabled = false) 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, 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(generateTableConfig("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(generateTableConfig("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(generateTableConfig("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);// w w w . j ava 2 s .c o m } 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:fresto.datastore.titan.TitanEventWriter.java
public TitanGraph openTitanGraph() { //OGraphDatabase oGraph = new OGraphDatabase(DB_URL); LOGGER.info("Setting up Titan"); Configuration config = new BaseConfiguration(); config.setProperty("storage.backend", STORAGE_BACKEND); config.setProperty("storage.hostname", STORAGE_HOSTNAME); config.setProperty("storage.connection-pool-size", 8); g = TitanFactory.open(config);/*from w w w.ja v a2 s. c o m*/ return g; }