List of usage examples for org.apache.commons.configuration Configuration getInt
int getInt(String key);
From source file:es.udc.gii.common.eaf.algorithm.mga.AbstractMGAAlgorithm.java
/** * Configures the algorithm./*from ww w . jav a2 s. c om*/ */ @Override public void configure(Configuration conf) { try { super.configure(conf); if (conf.containsKey("Elitism")) { this.setElitism(conf.getInt("Elitism")); } else { this.setElitism(1); (new ConfWarning("AbstractMGAAlgorithm.Elitism", 1)).warn(); } if (conf.containsKey("NominalConvergence.Class")) { this.setNominalConvergence( (StopTest) Class.forName(conf.getString("NominalConvergence.Class")).newInstance()); } else { (new ConfWarning("AbstractMGAAlgorithm.NominalConvergence", "MicroGenerationsConvergence")).warn(); this.setNominalConvergence(new MicroGenerationsConvergence(3)); } this.getNominalConvergence().configure(conf.subset("NominalConvergence")); } catch (Exception ex) { throw new ConfigurationException(this.getClass(), ex); } }
From source file:ai.grakn.graql.internal.analytics.MedianVertexProgram.java
@Override public void loadState(final Graph graph, final Configuration configuration) { super.loadState(graph, configuration); configuration.subset(RESOURCE_TYPE).getKeys().forEachRemaining( key -> statisticsResourceTypeIds.add(TypeId.of(configuration.getInt(RESOURCE_TYPE + "." + key)))); degreePropertyKey = (String) this.persistentProperties.get(DegreeVertexProgram.DEGREE); labelKey = (String) this.persistentProperties.get(LABEL); }
From source file:es.udc.gii.common.eaf.algorithm.operator.replace.mmga.PopulationMemoryReplaceOperator.java
@Override public void configure(Configuration conf) { /* Defaults */ int hypDiv = 25; int repCycle = 4; double repPart = 0.666; if (conf.containsKey("HypercubeDivisions")) { hypDiv = conf.getInt("HypercubeDivisions"); } else {/* w ww . j a v a 2s . c o m*/ (new ConfWarning("PopulationMemoryReplaceOperator.Hypercube" + "Divisions", hypDiv)).warn(); } if (conf.containsKey("ReplacementCycle")) { repCycle = conf.getInt("ReplacementCycle"); } else { (new ConfWarning("PopulationMemoryReplaceOperator.Replacement" + "Cycle", repCycle)).warn(); } if (conf.containsKey("ReplaceablePart")) { repPart = conf.getDouble("ReplaceablePart"); } else { (new ConfWarning("PopulationMemoryReplaceOperator.Replaceable" + "Part", repPart)).warn(); } setHypercubeDivisions(hypDiv); setReplacementCycle(repCycle); setReplaceablePartSize((int) ((double) popMemSize * repPart)); }
From source file:com.boozallen.cognition.ingest.storm.bolt.enrich.EsIndexBolt.java
@Override public void configure(Configuration conf) { conf.getKeys().forEachRemaining(key -> { String keyString = key.toString(); if (keyString.startsWith("es")) { String cleanedKey = keyString.replaceAll("\\.\\.", "."); boltConfig.put(cleanedKey, conf.getString(keyString)); }//from w w w. j a v a 2s.c o m }); manualFlushFreqSecs = conf.getInt(MANUAL_FLUSH_FREQ_SECS); }
From source file:edu.lternet.pasta.client.LoginClient.java
/** * Create an new LoginService object with the user's credentials and, if the * user's authentication is successful, place the user's authentication token * into the "tokenstore" for future use. * //from w w w. j a v a2 s . co m * @param uid * The user identifier. * @param password * The user password. * * @throws PastaAuthenticationException */ public LoginClient(String uid, String password) throws PastaAuthenticationException { Configuration options = ConfigurationListener.getOptions(); this.pastaHost = options.getString("pasta.hostname"); this.pastaProtocol = options.getString("pasta.protocol"); this.pastaPort = options.getInt("pasta.port"); String pastaUrl = PastaClient.composePastaUrl(this.pastaProtocol, this.pastaHost, this.pastaPort); this.LOGIN_URL = pastaUrl + "/package/"; String token = this.login(uid, password); if (token == null) { String gripe = "User '" + uid + "' did not successfully authenticate."; throw new PastaAuthenticationException(gripe); } else { TokenManager tokenManager = new TokenManager(); try { tokenManager.setToken(uid, token); } catch (SQLException e) { logger.error(e); e.printStackTrace(); } catch (ClassNotFoundException e) { logger.error(e); e.printStackTrace(); } } }
From source file:es.udc.gii.common.eaf.factory.XMLSimpleFactory.java
@Override public Population createPopulation(FitnessComparator<Individual> comparator) { Configuration conf = EAFConfiguration.getInstance().subset("Population"); int size = conf.getInt("Size"); Individual ind = createIndividual(comparator); List<Individual> listInd = new ArrayList<Individual>(); for (int i = 0; i < size; i++) { listInd.add((Individual) ind.clone()); }//from ww w . j a v a2 s . c o m Population pop = new Population(); pop.setIndividuals(listInd); return pop; }
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)); }// w w w . ja va2s . 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:es.udc.gii.common.eaf.algorithm.parallel.topology.migration.GridMigrationTopology.java
@Override protected void doConfigure(Configuration conf) { List listDimensions = conf.getList("Dimension[@count]"); this.nodesPerDimension = new int[listDimensions.size()]; this.dimIsPeriodic = new boolean[listDimensions.size()]; for (int i = 0; i < listDimensions.size(); i++) { nodesPerDimension[i] = conf.getInt("Dimension(" + i + ")[@count]"); dimIsPeriodic[i] = conf.getBoolean("Dimension(" + i + ")[@periodic]", false); }/* w w w . j a v a 2 s. c o m*/ }
From source file:de.nec.nle.siafu.output.CSVPrinter.java
/** * Builds a <code>CVSPrinter</code> object. If history is to be kept, this * already initializes the output file.//ww w. j ava 2s. c o m * * @param world * the world to print about * @param config * the simulation configuration file */ public CSVPrinter(final World world, final Configuration config) { this.world = world; this.outputPath = config.getString("output.csv.path"); this.keepHistory = config.getBoolean("output.csv.keephistory"); this.intervalInMillis = SECOND_TO_MS_FACTOR * config.getInt("output.csv.interval"); this.header = createHeader(); if (keepHistory) { initializeFile(outputPath); } }
From source file:com.evolveum.midpoint.init.ConfigurationLoadTest.java
@Test(enabled = false) public void t01simpleConfigTest() { LOGGER.info("---------------- simpleConfigTest -----------------"); System.clearProperty("midpoint.home"); LOGGER.info("midpoint.home => " + System.getProperty("midpoint.home")); assertNull(System.getProperty("midpoint.home"), "midpoint.home"); StartupConfiguration sc = new StartupConfiguration(); assertNotNull(sc);// www .j av a 2 s .c om sc.init(); Configuration c = sc.getConfiguration("midpoint.repository"); assertEquals(c.getString("repositoryServiceFactoryClass"), "com.evolveum.midpoint.repo.xml.XmlRepositoryServiceFactory"); LOGGER.info(sc.toString()); @SuppressWarnings("unchecked") Iterator<String> i = c.getKeys(); while (i.hasNext()) { String key = i.next(); LOGGER.info(" " + key + " = " + c.getString(key)); } assertEquals(c.getInt("port"), 1984); assertEquals(c.getString("serverPath"), ""); }