List of usage examples for org.apache.commons.configuration Configuration getInt
int getInt(String key);
From source file:com.springrts.springls.nat.NatHelpServer.java
@Override public void run() { Configuration conf = getContext().getService(Configuration.class); int port = conf.getInt(ServerConfiguration.NAT_PORT); try {//from w ww. j a va 2s. com socket = new DatagramSocket(port); } catch (Exception ex) { LOG.warn("Unable to start UDP server on port " + port + ". Ignoring ...", ex); return; } LOG.info("Listening for connections on UDP port {} ...", port); byte[] buffer = new byte[RECEIVE_BUFFER_SIZE]; while (true) { try { if (myThread.isInterrupted()) { break; } // receive packet DatagramPacket packet = new DatagramPacket(buffer, RECEIVE_BUFFER_SIZE); socket.receive(packet); msgList.add(packet); } catch (InterruptedIOException e) { break; } catch (IOException ex) { if (!ex.getMessage().equalsIgnoreCase("socket closed")) { LOG.error("Error in UDP server", ex); } } } socket.close(); LOG.info("UDP NAT server closed."); }
From source file:com.microrisc.simply.network.SimpleNetworkConnectionStorageFactory.java
/** Creates and returns UDP configuration settings. */ private UDPConnectionInfo getUDPConnectionInfo(Configuration networkConfig) throws UnknownHostException { String hostStr = networkConfig.getString("host"); InetAddress ipAddress = InetAddress.getByName(hostStr); int port = networkConfig.getInt("port"); return new BaseUDPConnectionInfo(ipAddress, port); }
From source file:es.udc.gii.common.eaf.algorithm.parallel.topology.Topology.java
/** Configures the topology. */ @Override/*from w w w . j a v a2 s . c om*/ public void configure(Configuration conf) { if (!isInitialized()) { if (conf.containsKey("Races")) { this.races = conf.getInt("Races"); } else if (!MPI.Initialized()) { throw new ConfigurationException("Topology: " + "Parallel environment not initialized!"); } else { this.races = MPI.COMM_WORLD.Size(); ConfWarning w = new ConfWarning(this.getClass().getSimpleName() + ".Races", this.races); w.warn(); } doConfigure(conf); initialize(); } }
From source file:es.udc.gii.common.eaf.algorithm.operator.reproduction.crossover.SBXCrossOver.java
@Override public void configure(Configuration conf) { super.configure(conf); if (conf.containsKey("CrossOverIndex")) { this.crossOverIndex = conf.getInt("CrossOverIndex"); } else {/*ww w . j a v a 2s . c om*/ ConfWarning w = new ConfWarning("CrossOverIndex", crossOverIndex); w.warn(); } }
From source file:com.cisco.oss.foundation.monitoring.RegistryFinder.java
private Registry internalProcessStart(final Configuration configuration, final int port, final String command) throws IOException, RemoteException, AccessException { String maxHeapArg = "-J-Xmx" + configuration.getInt(FoundationMonitoringConstants.RMIREGISTRY_MAXHEAPSIZE) + "m"; // start rmiregistry process if (System.getProperty("os.name").toLowerCase(Locale.getDefault()).contains("windows")) { String[] commandArgsArr = new String[] { command, maxHeapArg, String.valueOf(port) }; List<String> commandArgs = Arrays.asList(commandArgsArr); LOGGER.info("running command: " + commandArgs); new ProcessBuilder(commandArgsArr).start(); } else {/* w w w . jav a 2s . com*/ // support background process to prevent zombies String[] commandArgsArr = new String[] { "/bin/sh", "-c", command + maxHeapArg + " " + port + "&" }; List<String> commandArgs = Arrays.asList(commandArgsArr); LOGGER.info("running command: " + commandArgs); new ProcessBuilder(commandArgsArr).start(); } try { // wait for the process to start properly Thread.sleep(1000); } catch (InterruptedException e) { LOGGER.warn("The sleep for rmi registry to end has been interrupted: " + e.toString()); } // get registry final Registry registry = LocateRegistry.getRegistry(port); // test registry registry.list(); LOGGER.info("New RMI Registry created using port: " + port); return registry; }
From source file:es.udc.gii.common.eaf.algorithm.operator.replace.mmga.ParetoFrontReplaceOperator.java
@Override public void configure(Configuration conf) { /* Default values */ int maxPFS = 100; int hypDiv = 25; if (conf.containsKey("MaximumParetoFrontSize")) { maxPFS = conf.getInt("MaximumParetoFrontSize"); } else {// w w w . j a va 2 s. c o m (new ConfWarning("ParetoFrontReplaceOperator.MaximumPareto" + "FrontSize", maxPFS)).warn(); } if (conf.containsKey("HypercubeDivisions")) { hypDiv = conf.getInt("HypercubeDivisions"); } else { (new ConfWarning("ParetoFrontReplaceOperator.HypercubeDivisions", hypDiv)).warn(); } setMaximumParetoFrontSize(maxPFS); setHypercubeDivisions(hypDiv); }
From source file:fr.dudie.acrachilisync.utils.ConfigurationManager.java
/** * Constructor. Load the configuration elements. *//*from w w w. ja v a 2 s . co m*/ private ConfigurationManager(final Configuration pConf) { CHILIPROJECT_HOST = getURL(pConf.getString("chiliproject.host")); CHILIPROJECT_API_KEY = pConf.getString("chiliproject.api.key"); CHILIPROJECT_PROJECT_ID = pConf.getInt("chiliproject.project.id"); CHILIPROJECT_TRACKER_ID = pConf.getInt("chiliproject.tracker.id"); CHILIPROJECT_STACKTRACE_MD5_CF_ID = pConf.getInt("chiliproject.stacktraceMD5CustomField.id"); CHILIPROJECT_STATUS_CLOSED_ID = pConf.getInt("chiliproject.issue.status.closed.id"); CHILIPROJECT_RELATION_DUPLICATE_NAME = pConf.getString("chiliproject.issue.relation.duplicate.name"); final String documentKey = pConf.getString("google.spreadsheet.document.key"); final String worksheetId = pConf.getString("google.spreadsheet.worksheet.id"); final String url = String.format(AcraToChiliprojectSyncer.WORKSHEET_URL_FORMAT, documentKey, worksheetId); SPREADSHEET_FEED_URL = getURL(url); GOOGLE_LOGIN = pConf.getString("google.account.username"); GOOGLE_PASSWORD = pConf.getString("google.account.password"); }
From source file:com.nesscomputing.config.AbstractTestConfig.java
@Test public void loadIntValues() { Assert.assertThat(cfg, is(notNullValue())); final Configuration config = cfg.getConfiguration(); Assert.assertThat(config, is(notNullValue())); final Integer s_cfg1 = config.getInteger("int-null-value", null); Assert.assertThat(s_cfg1, is(nullValue())); final int s_cfg2 = config.getInt("int-value"); Assert.assertThat(s_cfg2, is(12345)); }
From source file:com.nesscomputing.config.AbstractTestConfig.java
@Test public void loadIntValues2() { Assert.assertThat(cfg2, is(notNullValue())); final Configuration config = cfg2.getConfiguration(); Assert.assertThat(config, is(notNullValue())); final Integer s_cfg1 = config.getInteger("int-null-value", null); Assert.assertThat(s_cfg1, is(nullValue())); final int s_cfg2 = config.getInt("int-value"); Assert.assertThat(s_cfg2, is(12345)); }
From source file:com.kixeye.chassis.bootstrap.configuration.zookeeper.CuratorFrameworkBuilder.java
private CuratorFramework buildCuratorWithZookeeperDirectly(Configuration configuration) { LOGGER.debug("configuring direct zookeeper connection."); CuratorFramework curator = CuratorFrameworkFactory.newClient(this.zookeeperConnectionString, configuration.getInt(ZOOKEEPER_SESSION_TIMEOUT_MILLIS.getPropertyName()), configuration.getInt(ZOOKEEPER_CONNECTION_TIMEOUT_MILLIS.getPropertyName()), buildZookeeperRetryPolicy(configuration)); curator.getConnectionStateListenable().addListener(new ConnectionStateListener() { public void stateChanged(CuratorFramework client, ConnectionState newState) { LOGGER.debug("Connection state to ZooKeeper changed: " + newState); }/*from ww w . j a v a 2 s . c om*/ }); return curator; }