List of usage examples for org.apache.commons.configuration Configuration getLong
long getLong(String key);
From source file:com.manydesigns.elements.configuration.CommonsConfigurationFunctions.java
public static long getLong(Configuration configuration, String key) { return configuration.getLong(key); }
From source file:eu.planetdata.srbench.oracle.Utility.java
public static TimestampedRelation importRelation(String filename, Logger logger) { try {/*from w ww.j a v a2 s .c o m*/ TimestampedRelation ret; Configuration relationImporter = new PropertiesConfiguration(filename); ret = new TimestampedRelation(); ret.setComputationTimestamp(relationImporter.getLong("timestamp")); for (String s : relationImporter.getStringArray("sensor")) { TimestampedRelationElement tre = new TimestampedRelationElement(); tre.add("sensor", new URIImpl(s)); //FIXME: should import the element timestamp! tre.setTimestamp(relationImporter.getLong("timestamp")); ret.addElement(tre); } return ret; } catch (ConfigurationException e) { logger.error("Error while reading the configuration file", e); fail(); } return null; }
From source file:es.udc.gii.common.eaf.stoptest.WallTimeStopTest.java
@Override public void configure(Configuration conf) { this.maxWallTime = conf.getLong("MaxWallTime"); if (this.maxWallTime < 0) { throw new AssertionError("Maximum wall time must greather than cero."); }//www.j a v a 2 s . com }
From source file:fr.mby.portal.coreimpl.configuration.PropertiesConfigurationManagerTest.java
/** * test 1.//from w w w . j av a 2s .c om * * @throws Exception */ @Test public void test1() throws Exception { final Configuration config1 = this.configManager.initConfiguration(PropertiesConfigurationManagerTest.KEY1, PropertiesConfigurationManagerTest.TYPE1, PropertiesConfigurationManagerTest.TAG1); Assert.assertNotNull("Config not initialized !", config1); config1.addProperty("key1", 42L); final Configuration config2 = this.configManager.getConfiguration(PropertiesConfigurationManagerTest.KEY1); Assert.assertNotNull("Config cannot be retrieved !", config2); Assert.assertEquals("Bad property value in config !", 42L, config2.getLong("key1")); Assert.assertNotNull("Tags cannot be retrieved !", this.configManager.getConfigurationTags()); Assert.assertEquals("Tags count bad !", 1, this.configManager.getConfigurationTags().size()); final String configKey = this.configManager.getConfigurationTags().iterator().next(); Assert.assertEquals("Tag name bad !", PropertiesConfigurationManagerTest.KEY1, configKey); Assert.assertNotNull("Empty collection not returned !", this.configManager.getConfigurationKeys("unknownTag")); }
From source file:com.linkedin.pinot.transport.config.ConnectionPoolConfig.java
public void init(Configuration cfg) { if (cfg.containsKey(THREAD_POOL_KEY)) { _threadPool.init(cfg.subset(THREAD_POOL_KEY)); }// www .j a v a2 s. c o m if (cfg.containsKey(IDLE_TIMEOUT_MS_KEY)) { _idleTimeoutMs = cfg.getLong(IDLE_TIMEOUT_MS_KEY); } if (cfg.containsKey(MIN_CONNECTIONS_PER_SERVER_KEY)) { _minConnectionsPerServer = cfg.getInt(MIN_CONNECTIONS_PER_SERVER_KEY); } if (cfg.containsKey(MAX_CONNECTIONS_PER_SERVER_KEY)) { _maxConnectionsPerServer = cfg.getInt(MAX_CONNECTIONS_PER_SERVER_KEY); } if (cfg.containsKey(MAX_BACKLOG_PER_SERVER_KEY)) { _maxBacklogPerServer = cfg.getInt(MAX_BACKLOG_PER_SERVER_KEY); } if (_minConnectionsPerServer > _maxConnectionsPerServer || _maxConnectionsPerServer <= 0 || _minConnectionsPerServer < 1) { LOGGER.warn( "Invalid values for " + MIN_CONNECTIONS_PER_SERVER_KEY + "({}) and " + MAX_CONNECTIONS_PER_SERVER_KEY + "({}). Resetting to defaults:", _minConnectionsPerServer, _maxConnectionsPerServer); _minConnectionsPerServer = DEFAULT_MIN_CONNECTIONS_PER_SERVER; _maxConnectionsPerServer = DEFAULT_MAX_CONNECTIONS_PER_SERVER; } if (_idleTimeoutMs < 0) { LOGGER.warn("Invalid value for " + IDLE_TIMEOUT_MS_KEY + "({}). Resetting to default."); _idleTimeoutMs = DEFAULT_IDLE_TIMEOUT_MS; } if (_maxBacklogPerServer < 0) { LOGGER.warn("Invalid value for " + MAX_BACKLOG_PER_SERVER_KEY + "({}). Resetting to default."); _maxBacklogPerServer = DEFAULT_MAX_BACKLOG_PER_SERVER; } LOGGER.info(toString()); }
From source file:com.linkedin.pinot.transport.config.ThreadPoolConfig.java
public void init(Configuration cfg) { if (cfg.containsKey(CORE_POOL_SIZE_KEY)) { _corePoolSize = cfg.getInt(CORE_POOL_SIZE_KEY); }//from www . ja v a 2 s.c o m if (cfg.containsKey(MAX_POOL_SIZE_KEY)) { _maxPoolSize = cfg.getInt(MAX_POOL_SIZE_KEY); } if (cfg.containsKey(IDLE_TIMEOUT_MS_KEY)) { _idleTimeoutMs = cfg.getLong(IDLE_TIMEOUT_MS_KEY); } }
From source file:edu.lternet.pasta.portal.HarvestReportServlet.java
/** * Initialization of the servlet. <br> * //from www. java 2s .c o m * @throws ServletException * if an error occurs */ public void init() throws ServletException { Configuration options = ConfigurationListener.getOptions(); harvesterPath = options.getString("harvester.path"); /* * Purge old harvest reports */ /* * Use default TTL value if the property was not specified or is 0 or * less */ try { harvesterReportDaysToLive = options.getLong("harvester.report.daysToLive"); if (harvesterReportDaysToLive <= 0) { harvesterReportDaysToLive = harvesterReportDaysToLiveDefault; } } catch (java.util.NoSuchElementException e) { harvesterReportDaysToLive = harvesterReportDaysToLiveDefault; } harvesterReportTTL = daysToMilliseconds(harvesterReportDaysToLive); executeHarvesterReportManager(); }
From source file:at.salzburgresearch.kmt.zkconfig.ZookeeperConfigurationTest.java
@Test public void testLong() throws Exception { Configuration config = new ZookeeperConfiguration(zkConnection, 5000, "/test"); final String key = UUID.randomUUID().toString(); final Random random = new Random(); final long val1 = random.nextLong(); final Long val2 = random.nextLong(); assertThat(config.getProperty(key), nullValue()); config.setProperty(key, val1); assertEquals(val1, config.getLong(key)); assertEquals(Long.valueOf(val1), config.getLong(key, val2)); config.setProperty(key, val2); assertEquals(val2.longValue(), config.getLong(key)); assertEquals(val2, config.getLong(key, Long.valueOf(val1))); }
From source file:com.yahoo.ads.pb.PistachiosServer.java
public boolean init() { boolean initialized = false; logger.info("Initializing profile server..........."); try {//w ww . j a v a 2s .co m // open profile store Configuration conf = ConfigurationManager.getConfiguration(); profileStore = new TLongKyotoCabinetStore(conf.getString(PROFILE_BASE_DIR), 0, 8, conf.getInt("Profile.RecordsPerServer"), conf.getLong("Profile.MemoryPerServer")); /* */ //profileStore.open(); /* hostname = InetAddress.getLocalHost().getHostName(); if(conf.getBoolean("Profile.Redesign.Firstload", false)){ String fileName = "profileMapping.json"; String refDir = "/home/y/libexec/server/refdata/"; String fullName = refDir + File.separator + fileName; FileReader fr = new FileReader(fullName); JSONParser parser = new JSONParser(); ContainerFactory containerFactory = new ContainerFactory() { public List creatArrayContainer() { return new LinkedList(); } public Map createObjectContainer() { return new LinkedHashMap(); } }; Map<String,List<String>> partition2Server = (Map<String,List<String>>) parser.parse(fr,containerFactory); Set<String> keys = partition2Server.keySet(); Set<Integer> partitions = new TreeSet<Integer>(); for(String key:keys){ if(partition2Server.get(key).contains(hostname)){ partitions.add(Integer.parseInt(key)); } } String profilePath = "/home/y/libexec/server/profile/store_"; String profileFilePrefix = "db_"; String profileFileSurfix = ".kch"; String profileWalFileSurfix = ".wal"; int index = 0; for(int partition: partitions){ File partitionDir = new File(profilePath+index); if(partitionDir.isDirectory()){ logger.info("rename from {} to {}",profilePath+index,profilePath+partition); partitionDir.renameTo( new File(profilePath+partition)); } File storeFile = new File(profilePath+partition+File.separator+profileFilePrefix+index+profileFileSurfix); if(storeFile.isFile()){ logger.info("rename from {} to {}",profilePath+partition+File.separator+profileFilePrefix+index+profileFileSurfix, profilePath+partition+File.separator+profileFilePrefix+partition+profileFileSurfix); storeFile.renameTo(new File(profilePath+partition+File.separator+profileFilePrefix+partition+profileFileSurfix)); } File storeFileWal = new File(profilePath+partition+File.separator+profileFilePrefix+index+profileFileSurfix+profileWalFileSurfix); if(storeFileWal.isFile()){ logger.info("rename from {} to {}",profilePath+partition+File.separator+profileFilePrefix+index+profileFileSurfix+profileWalFileSurfix,profilePath+partition+File.separator+profileFilePrefix+partition+profileFileSurfix+profileWalFileSurfix); storeFileWal.renameTo(new File(profilePath+partition+File.separator+profileFilePrefix+partition+profileFileSurfix+profileWalFileSurfix)); } index++; } } */ /* ModuleManager .registerMBean( ProfileServer.getInstance(), new ObjectName( "com.yahoo.ads.pb.platform.profile:name=ProfileServer")); */ // initialize performance counter /* lookupCounter = new InflightCounter(counterGroupName, "Lookup"); lookupCounter.register(); noDataCounter = new IncrementCounter(counterGroupName, "LookupNoData"); noDataCounter.register(); */ // storeCounter = new InflightCounter(counterGroupName, "Store"); // storeCounter.register(); // failedStoreCounter = new IncrementCounter(counterGroupName, // "FailedStore"); // failedStoreCounter.register(); // boolean enableStorePartition = conf.getBoolean( // Constant.PROFILE_STORING_PARTITION_ENABLE, false); // if (enableStorePartition) { logger.info("creating helix partition sepctator {} {} {}", conf.getString(ZOOKEEPER_SERVER, "EMPTY"), PistachiosConstants.CLUSTER_NAME, conf.getString(PROFILE_HELIX_INSTANCE_ID, "EMPTY")); helixPartitionSpectator = new HelixPartitionSpectator(conf.getString(ZOOKEEPER_SERVER), // zkAddr PistachiosConstants.CLUSTER_NAME, InetAddress.getLocalHost().getHostName() //conf.getString(PROFILE_HELIX_INSTANCE_ID) // instanceName ); // Partition Manager for line spending manager = new HelixPartitionManager<>(conf.getString(ZOOKEEPER_SERVER), // zkAddr PistachiosConstants.CLUSTER_NAME, InetAddress.getLocalHost().getHostName() //conf.getString(PROFILE_HELIX_INSTANCE_ID) // instanceName ); //manager.start("BootstrapOnlineOffline", new BootstrapOnlineOfflineStateModelFactory(new StorePartitionHandlerFactory())); manager.start(PistachiosConstants.PARTITION_MODEL, new BootstrapOnlineOfflineStateModelFactory(new StorePartitionHandlerFactory())); // } initialized = true; } catch (Exception e) { logger.error("Failed to initialize ProfileServerModule", e); } logger.info("Finished initializing profile server..........."); return initialized; }
From source file:com.boozallen.cognition.ingest.storm.topology.ConfigurableIngestTopology.java
protected void configureStorm(Configuration conf, Config stormConf) throws IllegalAccessException { stormConf.registerSerialization(LogRecord.class); //stormConf.registerSerialization(Entity.class); stormConf.registerMetricsConsumer(LoggingMetricsConsumer.class); for (Iterator<String> iter = conf.getKeys(); iter.hasNext();) { String key = iter.next(); String keyString = key.toString(); String cleanedKey = keyString.replaceAll("\\.\\.", "."); String schemaFieldName = cleanedKey.replaceAll("\\.", "_").toUpperCase() + "_SCHEMA"; Field field = FieldUtils.getField(Config.class, schemaFieldName); Object fieldObject = field.get(null); if (fieldObject == Boolean.class) stormConf.put(cleanedKey, conf.getBoolean(keyString)); else if (fieldObject == String.class) stormConf.put(cleanedKey, conf.getString(keyString)); else if (fieldObject == ConfigValidation.DoubleValidator) stormConf.put(cleanedKey, conf.getDouble(keyString)); else if (fieldObject == ConfigValidation.IntegerValidator) stormConf.put(cleanedKey, conf.getInt(keyString)); else if (fieldObject == ConfigValidation.PowerOf2Validator) stormConf.put(cleanedKey, conf.getLong(keyString)); else if (fieldObject == ConfigValidation.StringOrStringListValidator) stormConf.put(cleanedKey, Arrays.asList(conf.getStringArray(keyString))); else if (fieldObject == ConfigValidation.StringsValidator) stormConf.put(cleanedKey, Arrays.asList(conf.getStringArray(keyString))); else {/*from w w w . ja v a2 s .c o m*/ logger.error( "{} cannot be configured from XML. Consider configuring in navie storm configuration."); throw new UnsupportedOperationException(cleanedKey + " cannot be configured from XML"); } } }