List of usage examples for org.apache.commons.configuration PropertiesConfiguration PropertiesConfiguration
public PropertiesConfiguration()
From source file:main.java.workload.twitter.TwitterWorkload.java
public void readConfig() { BufferedReader config_file = null; AbstractFileConfiguration parameters = null; int i, j = 0; try {//from w ww . j av a 2 s .c o m config_file = new BufferedReader( new InputStreamReader(getClass().getResourceAsStream(this.getFile_name()))); //Load configuration parameters parameters = new PropertiesConfiguration(); parameters.load(config_file); //Read Twitter scale //WorkloadConstants.SCALE_FACTOR = parameters.getDouble("twitter.scale"); WorkloadConstants.SCALE_FACTOR = Global.scaleFactor; Global.LOGGER.info("Twitter scale (as the number of users): " + WorkloadConstants.SCALE_FACTOR); //Read Twitter table types i = 1; for (Object param : parameters.getList("twitter.tbl.type")) { tbl_types.put(i, Integer.parseInt((String) param)); ++i; } Global.LOGGER.info("Twitter tables types: " + tbl_types); //Read Twitter schema i = j = 0; ArrayList<Integer> temp = null; for (Object param : parameters.getList("twitter.schema")) { if (j >= tbl_types.size() || j == 0) { ++i; j = 0; temp = new ArrayList<Integer>(); schema.put(i, temp); } schema.get(i).add(Integer.parseInt((String) param)); ++j; } Global.LOGGER.info("Twitter table-level schema: " + schema); //Read Twitter transaction proportion i = 0; //new this.trTypes = new int[tr_types]; this.trProbabilities = new double[tr_types]; for (Object param : parameters.getList("twitter.trs.proportions")) { ++i; tr_proportions.put(i, Double.parseDouble((String) param)); this.trTypes[i - 1] = i; this.trProbabilities[i - 1] = Double.parseDouble((String) param); } Global.LOGGER.info("Twitter transaction proportions: " + tr_proportions); } catch (ConfigurationException e) { e.printStackTrace(); } finally { if (config_file != null) { try { config_file.close(); } catch (IOException e) { e.printStackTrace(); } } } }
From source file:cross.io.PropertyFileGenerator.java
/** * Creates a property object for the given class, containing those fields, * which are annotated by {//from w w w . j a v a2 s . c o m * * @return * @Configurable}. * @param c */ public static PropertiesConfiguration createProperties(Class<?> c) { Collection<String> keys = AnnotationInspector.getRequiredConfigKeys(c); if (!keys.isEmpty()) { PropertiesConfiguration pc = new PropertiesConfiguration(); for (String key : keys) { pc.addProperty(key, AnnotationInspector.getDefaultValueFor(c, key)); } return pc; } else { LoggerFactory.getLogger(PropertyFileGenerator.class) .info("Could not find annotated configuration keys for class {}!", c.getName()); } return new PropertiesConfiguration(); }
From source file:io.s4.example.twittertopiccount.Module.java
private void loadProperties(Binder binder) { try {/* w w w . java 2s. c o m*/ InputStream is = this.getClass().getResourceAsStream("/s4-example-twittertopiccount.properties"); config = new PropertiesConfiguration(); config.load(is); System.out.println(ConfigurationUtils.toString(config)); // TODO - validate properties. /* Make all properties injectable. Do we need this? */ Names.bindProperties(binder, ConfigurationConverter.getProperties(config)); } catch (ConfigurationException e) { binder.addError(e); e.printStackTrace(); } }
From source file:com.vmware.bdd.rest.advice.DefaultExceptionHandler.java
@PostConstruct private void init() { PropertiesConfiguration config = null; try {//from w w w. ja v a 2 s . co m config = new PropertiesConfiguration(); config.setListDelimiter('\0'); config.load(ERR_CODE_FILE); } catch (ConfigurationException ex) { // error out if the configuration file is not there String message = "Cannot load Serengeti error message file."; logger.fatal(message, ex); throw BddException.APP_INIT_ERROR(ex, message); } httpStatusCodes = config; }
From source file:io.fluo.quickstart.MiniHelper.java
public MiniHelper(File dir, List<ObserverConfiguration> observers) throws Exception { this.dir = dir; // lets tone down the noise from logging Logger.getLogger("org.apache.zookeeper").setLevel(Level.ERROR); Logger.getLogger("org.apache.curator").setLevel(Level.WARN); Logger.getLogger("io.fluo").setLevel(Level.WARN); MiniAccumuloConfig cfg = new MiniAccumuloConfig(dir, new String("secret")); cluster = new MiniAccumuloCluster(cfg); cluster.start();//from ww w . ja v a 2 s . c om FluoConfiguration fluoConfig = new FluoConfiguration(); fluoConfig.setAccumuloInstance(cluster.getInstanceName()); fluoConfig.setAccumuloUser("root"); fluoConfig.setAccumuloPassword("secret"); fluoConfig.setZookeeperRoot("/fluo"); fluoConfig.setZookeepers(cluster.getZooKeepers()); connectionProps = new PropertiesConfiguration(); connectionProps.copy(fluoConfig); fluoConfig.setAccumuloTable("data"); fluoConfig.setObservers(observers); FluoFactory.newAdmin(fluoConfig).initialize(); miniFluo = FluoFactory.newMiniFluo(fluoConfig); miniFluo.start(); }
From source file:com.pinterest.pinlater.backends.mysql.PinLaterMySQLBackendTest.java
@BeforeClass public static void beforeClass() throws Exception { QUEUE_NAME = "pinlater_mysql_backend_test"; // If there is no local MySQL, skip this test. boolean isLocalMySQLRunning = LocalMySQLChecker.isRunning(); Assume.assumeTrue(isLocalMySQLRunning); PropertiesConfiguration configuration = new PropertiesConfiguration(); try {//from www . j av a 2 s . c om configuration.load(ClassLoader.getSystemResourceAsStream("pinlater.test.properties")); } catch (ConfigurationException e) { throw new RuntimeException(e); } System.setProperty("backend_config", "mysql.local.json"); backend = new PinLaterMySQLBackend(configuration, "localhost", System.currentTimeMillis()); }
From source file:com.aurel.track.DBScriptTest.java
/***************************** HELPERS *****************************/ public PropertiesConfiguration getRealPropertyObj(String dbTypePrefix) { try {/*from ww w . j a v a 2s .co m*/ String propFilePath = System.getProperty("user.dir") + "/src/test/resources/schema/DBScriptTester.properties"; FileInputStream input = new FileInputStream(propFilePath); Properties prop = new Properties(); prop.load(input); PropertiesConfiguration props = new PropertiesConfiguration(); props.addProperty("torque.dsfactory.track.connection.user", prop.get(dbTypePrefix + "user")); props.addProperty("torque.dsfactory.track.connection.password", prop.get(dbTypePrefix + "password")); props.addProperty("torque.database.track.adapter", prop.get(dbTypePrefix + "adapter")); props.addProperty("torque.dsfactory.track.connection.driver", prop.get(dbTypePrefix + "driver")); props.addProperty("torque.dsfactory.track.connection.url", prop.get(dbTypePrefix + "url")); props.addProperty("torque.dsfactory.track.factory", "org.apache.torque.dsfactory.SharedPoolDataSourceFactory"); props.addProperty("torque.dsfactory.track.pool.maxActive", "30"); props.addProperty("torque.dsfactory.track.pool.testOnBorrow", "true"); props.addProperty("torque.dsfactory.track.pool.validationQuery", "SELECT PKEY FROM TSTATE"); return props; } catch (Exception ex) { ex.printStackTrace(); } return null; }
From source file:main.java.workload.tpcc.TpccWorkload.java
public void readConfig() { BufferedReader config_file = null; AbstractFileConfiguration parameters = null; int i, j = 0; try {/*from w ww . j a va 2 s .c o m*/ config_file = new BufferedReader( new InputStreamReader(getClass().getResourceAsStream(this.getFile_name()))); //Load configuration parameters parameters = new PropertiesConfiguration(); parameters.load(config_file); //Read TPCC scale //WorkloadConstants.SCALE_FACTOR = parameters.getDouble("tpcc.scale"); WorkloadConstants.SCALE_FACTOR = Global.scaleFactor; Global.LOGGER.info("TPCC scale: " + WorkloadConstants.SCALE_FACTOR); //Read TPCC warehouses TpccConstants.NUM_WAREHOUSES = parameters.getInt("tpcc.warehouses"); Global.LOGGER.info("TPCC warehouses: " + TpccConstants.NUM_WAREHOUSES); //Read TPCC table types i = 1; for (Object param : parameters.getList("tpcc.tbl.type")) { tbl_types.put(i, Integer.parseInt((String) param)); ++i; } Global.LOGGER.info("TPCC tables types: " + tbl_types); //Read TPCC schema i = j = 0; ArrayList<Integer> temp = null; for (Object param : parameters.getList("tpcc.schema")) { if (j >= 9 || j == 0) { ++i; j = 0; temp = new ArrayList<Integer>(); schema.put(i, temp); } schema.get(i).add(Integer.parseInt((String) param)); ++j; } Global.LOGGER.info("TPCC table-level schema: " + schema); //Read TPCC transaction proportion i = 0; //new this.trTypes = new int[tr_types]; this.trProbabilities = new double[tr_types]; for (Object param : parameters.getList("tpcc.trs.proportions")) { ++i; tr_proportions.put(i, Double.parseDouble((String) param)); // new this.trTypes[i - 1] = i; this.trProbabilities[i - 1] = Double.parseDouble((String) param); } Global.LOGGER.info("TPCC transaction proportions: " + tr_proportions); //Read TPCC transactions i = j = 0; temp = null; for (Object param : parameters.getList("tpcc.trs.tbl_data")) { if (j >= 9 || j == 0) { ++i; j = 0; temp = new ArrayList<Integer>(); tr_tuple_distributions.put(i, temp); } tr_tuple_distributions.get(i).add(Integer.parseInt((String) param)); ++j; } Global.LOGGER.info("TPCC transaction table-level data distributions: " + tr_tuple_distributions); //Read TPCC transactional changes i = j = 0; temp = null; for (Object param : parameters.getList("tpcc.trs.tbl_changes")) { if (j >= 9 || j == 0) { ++i; j = 0; temp = new ArrayList<Integer>(); tr_changes.put(i, temp); } tr_changes.get(i).add(Integer.parseInt((String) param)); ++j; } Global.LOGGER.info("TPCC table-level transactional changes: " + tr_changes); } catch (ConfigurationException e) { e.printStackTrace(); } finally { if (config_file != null) { try { config_file.close(); } catch (IOException e) { e.printStackTrace(); } } } }
From source file:com.linkedin.pinot.core.query.scheduler.resources.ResourceManagerTest.java
private Configuration getConfig(int runners, int workers) { Configuration config = new PropertiesConfiguration(); config.setProperty(ResourceManager.QUERY_RUNNER_CONFIG_KEY, runners); config.setProperty(ResourceManager.QUERY_WORKER_CONFIG_KEY, workers); return config; }
From source file:com.obidea.semantika.app.Environment.java
/** * Creates a new blank system properties *//*from w w w . j av a2 s. c o m*/ public static PropertiesConfiguration getProperties() { return new PropertiesConfiguration(); }