List of usage examples for org.apache.commons.configuration Configuration setProperty
void setProperty(String key, Object value);
From source file:co.turnus.analysis.partitioning.CommunicationCostPartitioningCli.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. j ava2s . 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("p")) { s.append("The number of partitions is not specified. "); } else { String[] sp = cmd.getOptionValues("p"); if (sp.length == 1) { int value = Integer.parseInt(sp[0]); config.addProperty(PARTITION_UNITS_MIN, value); config.addProperty(PARTITION_UNITS_MAX, value); config.addProperty(PARTITION_UNITS_POINTS, 1); } else if (sp.length == 2) { int min = Integer.parseInt(sp[0]); int max = Integer.parseInt(sp[1]); config.addProperty(PARTITION_UNITS_MIN, min); config.addProperty(PARTITION_UNITS_MAX, max); config.addProperty(PARTITION_UNITS_POINTS, max - min + 1); } else { int min = Integer.parseInt(sp[0]); int max = Integer.parseInt(sp[1]); int points = Integer.parseInt(sp[2]); config.addProperty(PARTITION_UNITS_MIN, min); config.addProperty(PARTITION_UNITS_MAX, max); config.addProperty(PARTITION_UNITS_POINTS, points); } } 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("xcf")) { String fileName = cmd.getOptionValue("xcf", ""); if (fileName == null || fileName.isEmpty()) { s.append("XCF file name is not correct. "); } else { config.setProperty(XCF, fileName); } } String error = s.toString(); if (!error.isEmpty()) { throw new ParseException(error); } return config; }
From source file:com.netflix.config.util.ConfigurationUtils.java
public static void loadProperties(Properties props, Configuration config) { for (Entry<Object, Object> entry : props.entrySet()) { config.setProperty((String) entry.getKey(), entry.getValue()); }//from w w w. j av a 2 s . co m }
From source file:co.turnus.analysis.buffers.BoundedBufferSchedulingCliLauncher.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 {/*from w w w . j a v a2 s . com*/ 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); } } 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); 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); } } String error = s.toString(); if (!error.isEmpty()) { throw new ParseException(error); } return config; }
From source file:com.amazon.janusgraph.TestGraphUtil.java
private static void configureStore(final String dataModelName, final int tps, final Configuration config, final boolean unlimitedIops, final String prefix) { final String prefixPeriod = prefix + "."; config.setProperty(prefixPeriod + Constants.STORES_DATA_MODEL.getName(), dataModelName); config.setProperty(prefixPeriod + Constants.STORES_SCAN_LIMIT.getName(), 10000); config.setProperty(prefixPeriod + Constants.STORES_INITIAL_CAPACITY_READ.getName(), tps); config.setProperty(prefixPeriod + Constants.STORES_READ_RATE_LIMIT.getName(), unlimitedIops ? Integer.MAX_VALUE : tps); config.setProperty(prefixPeriod + Constants.STORES_INITIAL_CAPACITY_WRITE.getName(), tps); config.setProperty(prefixPeriod + Constants.STORES_WRITE_RATE_LIMIT.getName(), unlimitedIops ? Integer.MAX_VALUE : tps); }
From source file:co.turnus.analysis.bottlenecks.AlgorithmicBottlenecksCliLauncher.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 {/*from w w w .j a 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("w")) { s.append("Profiling weights file not specified. "); } else { String fileName = cmd.getOptionValue("w", ""); File file = new File(fileName); if (file == null || !file.exists()) { s.append("Profiling weights file does not exists. "); } else { config.setProperty(PROFILING_WEIGHTS, 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("i")) { config.setProperty(IMPACT_ANALYSIS_RUN, true); String[] values = cmd.getOptionValues("i"); if (values.length < 3) { s.append("No enought parameters for the impact analysis. "); } else { try { int intValue = Integer.parseInt(values[0]); config.setProperty(IMPACT_ANALYSIS_ACTIONS, intValue); } catch (Exception e) { s.append("The number of actions for the impact analysis should be an integer value. "); } try { int intValue = Integer.parseInt(values[1]); config.setProperty(IMPACT_ANALYSIS_POINTS, intValue); } catch (Exception e) { s.append("The number of points for the impact analysis should be an integer value. "); } String value = values[2]; if (value.equals("a")) { config.setProperty(IMPACT_ANALYSIS_ACTORLEVEL, true); } else if (value.equals("c")) { config.setProperty(IMPACT_ANALYSIS_ACTORLEVEL, false); } else { s.append("The impact analysis granularity is not correct. "); } } } else { config.setProperty(IMPACT_ANALYSIS_RUN, false); } String error = s.toString(); if (!error.isEmpty()) { throw new ParseException(error); } return config; }
From source file:com.intel.cosbench.config.common.KVConfigParser.java
private static void addConfigEntry(String entry, Configuration config) { int pos = StringUtils.indexOf(entry, '='); if (pos < 0) logger.warn("cannot parse config entry {}", entry); String key = StringUtils.trim(StringUtils.left(entry, pos)); String value = StringUtils.trim(StringUtils.right(entry, entry.length() - pos - 1)); logger.debug("key=" + key + ";value=" + value); config.setProperty(key, value); }
From source file:com.twitter.distributedlog.util.ConfUtils.java
/** * Load configurations with prefixed <i>section</i> from source configuration <i>srcConf</i> into * target configuration <i>targetConf</i>. * * @param targetConf/*from w w w . j a v a 2 s . c om*/ * Target Configuration * @param srcConf * Source Configuration * @param section * Section Key */ public static void loadConfiguration(Configuration targetConf, Configuration srcConf, String section) { Iterator confKeys = srcConf.getKeys(); while (confKeys.hasNext()) { Object keyObject = confKeys.next(); if (!(keyObject instanceof String)) { continue; } String key = (String) keyObject; if (key.startsWith(section)) { targetConf.setProperty(key.substring(section.length()), srcConf.getProperty(key)); } } }
From source file:io.fluo.api.config.FluoConfiguration.java
/** * Sets all Fluo properties to their default in the given * configuration. NOTE - some properties do not have defaults * and will not be set. // w w w . jav a2 s . c om */ public static void setDefaultConfiguration(Configuration config) { config.setProperty(CLIENT_ZOOKEEPER_CONNECT_PROP, CLIENT_ZOOKEEPER_CONNECT_DEFAULT); config.setProperty(CLIENT_ZOOKEEPER_ROOT_PROP, CLIENT_ZOOKEEPER_ROOT_DEFAULT); config.setProperty(CLIENT_ZOOKEEPER_TIMEOUT_PROP, CLIENT_ZOOKEEPER_TIMEOUT_DEFAULT); config.setProperty(CLIENT_CLASS_PROP, CLIENT_CLASS_DEFAULT); config.setProperty(ADMIN_ALLOW_REINITIALIZE_PROP, ADMIN_ALLOW_REINITIALIZE_DEFAULT); config.setProperty(ADMIN_CLASS_PROP, ADMIN_CLASS_DEFAULT); config.setProperty(WORKER_NUM_THREADS_PROP, WORKER_NUM_THREADS_DEFAULT); config.setProperty(WORKER_INSTANCES_PROP, WORKER_INSTANCES_DEFAULT); config.setProperty(WORKER_MAX_MEMORY_MB_PROP, WORKER_MAX_MEMORY_MB_DEFAULT); config.setProperty(TRANSACTION_ROLLBACK_TIME_PROP, TRANSACTION_ROLLBACK_TIME_DEFAULT); config.setProperty(LOADER_NUM_THREADS_PROP, LOADER_NUM_THREADS_DEFAULT); config.setProperty(LOADER_QUEUE_SIZE_PROP, LOADER_QUEUE_SIZE_DEFAULT); config.setProperty(ORACLE_PORT_PROP, ORACLE_PORT_DEFAULT); config.setProperty(ORACLE_MAX_MEMORY_MB_PROP, ORACLE_MAX_MEMORY_MB_DEFAULT); config.setProperty(MINI_CLASS_PROP, MINI_CLASS_DEFAULT); }
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 {/*from ww w . j a v a 2 s. c om*/ 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.vmware.qe.framework.datadriven.config.DDConfig.java
/** * Overrides the properties that exist in original configuration with the properties specified * in new configuration, if they already exist. Otherwise, they are added. * //from ww w .j ava 2 s . co m * @param orgConfig original configuration * @param newConfig new configuration */ private static Configuration overrideConfigProperties(Configuration orgConfig, Configuration newConfig) { if (newConfig == null) { return orgConfig; } if (orgConfig == null) { return newConfig; } Iterator<String> itr = newConfig.getKeys(); while (itr.hasNext()) { String key = itr.next(); orgConfig.setProperty(key, newConfig.getProperty(key)); } return orgConfig; }