List of usage examples for org.apache.commons.configuration Configuration getInt
int getInt(String key);
From source file:org.lockss.servlet.LockssOiosamlSpFilter.java
private void setRuntimeConfiguration(Configuration conf) { restartCRLChecker(conf);//from w w w.j a va 2 s . co m setFilterInitialized(true); setConfiguration(conf); if (!IdpMetadata.getInstance().enableDiscovery()) { log.info("Discovery profile disabled, only one metadata file found"); } else { if (conf.getString(Constants.DISCOVERY_LOCATION) == null) { throw new IllegalStateException( "Discovery location cannot be null when discovery profile is active"); } } setHostname(); sessionHandlerFactory = SessionHandlerFactory.Factory.newInstance(conf); sessionHandlerFactory.getHandler() .resetReplayProtection(conf.getInt(Constants.PROP_NUM_TRACKED_ASSERTIONIDS)); log.info("Home url: " + conf.getString(Constants.PROP_HOME)); log.info("Assurance level: " + conf.getInt(Constants.PROP_ASSURANCE_LEVEL)); log.info("SP entity ID: " + SPMetadata.getInstance().getEntityID()); log.info("Base hostname: " + hostname); }
From source file:org.loggo.server.Server.java
private void registerInZookeeper(Configuration config) throws IOException, KeeperException, InterruptedException { String zookeepers = config.getString("zookeepers"); if (zookeepers != null) { final CountDownLatch latch = new CountDownLatch(1); ZooKeeper zookeeper = new ZooKeeper(zookeepers, 30 * 1000, new Watcher() { @Override/* www . j ava 2 s.co m*/ public void process(WatchedEvent event) { latch.countDown(); } }); try { latch.await(); try { zookeeper.create("/udp", new byte[] {}, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); } catch (KeeperException.NodeExistsException ex) { // expected } String host = config.getString("host"); int port = config.getInt("udp.port"); zookeeper.create("/udp/logger-", (host + ":" + port).getBytes(UTF_8), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL); try { zookeeper.create("/tcp", new byte[] {}, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); } catch (KeeperException.NodeExistsException ex) { // expected } port = config.getInt("tcp.port"); zookeeper.create("/tcp/logger-", (host + ":" + port).getBytes(UTF_8), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL); } finally { zookeeper.close(); } } }
From source file:org.matsim.contrib.taxi.optimizer.assignment.AssignmentTaxiOptimizerParams.java
public AssignmentTaxiOptimizerParams(Configuration optimizerConfig) { super(optimizerConfig, true, true); mode = Mode.valueOf(optimizerConfig.getString(MODE)); // when the cost is measured in time units (seconds), // 48 * 36000 s (2 days) seem big enough to prevent such assignments nullPathCost = optimizerConfig.getDouble(NULL_PATH_COST, 48 * 3600); vehPlanningHorizonOversupply = optimizerConfig.getInt(VEH_PLANNING_HORIZON_OVERSUPPLY); vehPlanningHorizonUndersupply = optimizerConfig.getInt(VEH_PLANNING_HORIZON_UNDERSUPPLY); nearestRequestsLimit = optimizerConfig.getInt(NEAREST_REQUESTS_LIMIT); nearestVehiclesLimit = optimizerConfig.getInt(NEAREST_VEHICLES_LIMIT); }
From source file:org.matsim.contrib.taxi.optimizer.rules.RuleBasedTaxiOptimizerParams.java
public RuleBasedTaxiOptimizerParams(Configuration optimizerConfig) { super(optimizerConfig, false, false); goal = Goal.valueOf(optimizerConfig.getString(GOAL)); nearestRequestsLimit = optimizerConfig.getInt(NEAREST_REQUESTS_LIMIT); nearestVehiclesLimit = optimizerConfig.getInt(NEAREST_VEHICLES_LIMIT); cellSize = optimizerConfig.getDouble(CELL_SIZE);// 1000 m tested for Berlin }
From source file:org.mobicents.servlet.restcomm.sms.smpp.SmppService.java
private void initializeSmppConnections() { Configuration smppConfiguration = this.configuration.subset("smpp"); List<Object> smppConnections = smppConfiguration.getList("connections.connection.name"); int smppConnecsSize = smppConnections.size(); if (smppConnecsSize == 0) { logger.warning("No SMPP Connections defined!"); return;/* w w w.j av a 2s . co m*/ } for (int count = 0; count < smppConnecsSize; count++) { String name = smppConfiguration.getString("connections.connection(" + count + ").name"); String systemId = smppConfiguration.getString("connections.connection(" + count + ").systemid"); String peerIp = smppConfiguration.getString("connections.connection(" + count + ").peerip"); int peerPort = smppConfiguration.getInt("connections.connection(" + count + ").peerport"); SmppBindType bindtype = SmppBindType .valueOf(smppConfiguration.getString("connections.connection(" + count + ").bindtype")); if (bindtype == null) { logger.warning("Bindtype for SMPP name=" + name + " is not specified. Using default TRANSCEIVER"); } String password = smppConfiguration.getString("connections.connection(" + count + ").password"); String systemType = smppConfiguration.getString("connections.connection(" + count + ").systemtype"); byte interfaceVersion = smppConfiguration .getByte("connections.connection(" + count + ").interfaceversion"); byte ton = smppConfiguration.getByte("connections.connection(" + count + ").ton"); byte npi = smppConfiguration.getByte("connections.connection(" + count + ").npi"); String range = smppConfiguration.getString("connections.connection(" + count + ").range"); Address address = null; if (ton != -1 && npi != -1 && range != null) { address = new Address(ton, npi, range); } int windowSize = smppConfiguration.getInt("connections.connection(" + count + ").windowsize"); long windowWaitTimeout = smppConfiguration .getLong("connections.connection(" + count + ").windowwaittimeout"); long connectTimeout = smppConfiguration.getLong("connections.connection(" + count + ").connecttimeout"); long requestExpiryTimeout = smppConfiguration .getLong("connections.connection(" + count + ").requestexpirytimeout"); long windowMonitorInterval = smppConfiguration .getLong("connections.connection(" + count + ").windowmonitorinterval"); boolean logBytes = smppConfiguration.getBoolean("connections.connection(" + count + ").logbytes"); boolean countersEnabled = smppConfiguration .getBoolean("connections.connection(" + count + ").countersenabled"); long enquireLinkDelay = smppConfiguration .getLong("connections.connection(" + count + ").enquirelinkdelay"); Smpp smpp = new Smpp(name, systemId, peerIp, peerPort, bindtype, password, systemType, interfaceVersion, address, connectTimeout, windowSize, windowWaitTimeout, requestExpiryTimeout, windowMonitorInterval, countersEnabled, logBytes, enquireLinkDelay); this.smppList.add(smpp); if (logger.isInfoEnabled()) { logger.info("creating new SMPP connection " + smpp); } } // for monitoring thread use, it's preferable to create your own // instance of an executor and cast it to a ThreadPoolExecutor from // Executors.newCachedThreadPool() this permits exposing thinks like // executor.getActiveCount() via JMX possible no point renaming the // threads in a factory since underlying Netty framework does not easily // allow you to customize your thread names this.executor = (ThreadPoolExecutor) Executors.newCachedThreadPool(); // to enable automatic expiration of requests, a second scheduled // executor is required which is what a monitor task will be executed // with - this is probably a thread pool that can be shared with between // all client bootstraps this.monitorExecutor = (ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(1, new ThreadFactory() { private AtomicInteger sequence = new AtomicInteger(0); @Override public Thread newThread(Runnable r) { Thread t = new Thread(r); t.setName("SmppServer-SessionWindowMonitorPool-" + sequence.getAndIncrement()); return t; } }); // a single instance of a client bootstrap can technically be shared // between any sessions that are created (a session can go to any // different number of SMSCs) - each session created under a client // bootstrap will use the executor and monitorExecutor set in its // constructor - just be *very* careful with the "expectedSessions" // value to make sure it matches the actual number of total concurrent // open sessions you plan on handling - the underlying netty library // used for NIO sockets essentially uses this value as the max number of // threads it will ever use, despite the "max pool size", etc. set on // the executor passed in here // Setting expected session to be 25. May be this should be // configurable? this.clientBootstrap = new DefaultSmppClient(this.executor, 25, monitorExecutor); this.smppClientOpsThread = new SmppClientOpsThread(this.clientBootstrap, outboundInterface("udp").getPort(), smppMessageHandler); (new Thread(this.smppClientOpsThread)).start(); for (Smpp smpp : this.smppList) { this.smppClientOpsThread.scheduleConnect(smpp); } if (logger.isInfoEnabled()) { logger.info("SMPP Service started"); } }
From source file:org.mot.core.MyOpenTraderCore.java
/** * This method creates the actual JMS message listener for all stock prices. * //from ww w .j a va2 s. c o m * @param symbol - which symbol to listen for * @param type - type of the symbol (FX, STK etc) * @param currency - which currency is in use * @param genericProperties - generic properties */ private void startTickMessageListener(String symbol, String type, String currency, Configuration genericProperties) { AverageCalculationDAO acd = new AverageCalculationDAO(); ActiveMQFactory amf = new ActiveMQFactory(); logger.debug("Creating new tick message listener ..."); TickMessageListener tml = new TickMessageListener(); Destination ticks = amf.createDestination("tickPriceChannel"); /* * The following section would automatically create a moving average algo with the best known combination */ if (genericProperties.getBoolean("engine.startup.autoCreateBestCombination")) { Iterator<Entry<Integer, Integer>> lm = acd .getBestAverageCombination(symbol, "TICK", genericProperties.getInt("engine.startup.autoCreateBestCombineation.top")) .entrySet().iterator(); if (lm.hasNext()) { Map.Entry<Integer, Integer> lm2 = lm.next(); String name = symbol + lm2.getKey() * 10 + "-" + lm2.getValue() * 10 + "-mvg"; //loadAlgorithm(genericProperties.getString("engine.startup.autoCreateBestCombineation.class"), name, symbol, lm2.getKey()*10, lm2.getValue()*10, 10, true); } } if (type.equals("FX")) { // If type is FX also provide the currency amf.createMessageConsumer(ticks, tml, symbol, currency); } else { amf.createMessageConsumer(ticks, tml, symbol); } }
From source file:org.mot.core.simulation.SimulationRunner.java
private void startThreads(Configuration genericProperties) { int threadCount = genericProperties.getInt("engine.core.simulation.threads"); Thread[] threads = new Thread[threadCount]; //Thread[] threads = new Thread[1]; for (int i = 0; i < threadCount; i++) { threads[i] = new Thread() { public void run() { ActiveMQFactory amc = new ActiveMQFactory(); logger.debug("Creating new simulation message listener ..."); SimulationMessageListener sml = new SimulationMessageListener(); Destination simulations = amc.createDestination("simulationChannel?consumer.prefetchSize=1"); amc.createMessageConsumer(simulations, sml); }// www . j a va 2s . com }; threads[i].setName("SimulationListener"); threads[i].start(); //i++; //Thread.sleep(1000); } }
From source file:org.mot.feeder.iab.MyOpenTraderFeederIAB.java
/** * This is the main start method. Both, the servlet, as well as the main class will call this function. * /*from w w w.ja va 2s.com*/ * @param PathToConfigDir - provide a configuration directory * @param name - name of the executor */ protected void startWorkers(String PathToConfigDir, String name) { try { // First make sure to set the config directory // Make sure to init the propertiesfactory! pf.setConfigDir(PathToConfigDir); PropertyConfigurator.configure(pf.getConfigDir() + "/log4j.properties"); // Get the client instance EClientSocket ecs = IABConnector.getInstance(); // Generate a new client ID int clientID = Integer.valueOf(new IDGenerator().getUniqueIntID()); // Read out the TraderWorkstation & generic properties Configuration twsProperties = new PropertiesConfiguration(PathToConfigDir + "/tws.properties"); Configuration genericProperties = new PropertiesConfiguration(PathToConfigDir + "/config.properties"); ecs.eConnect(twsProperties.getString("iab.tws.host"), twsProperties.getInt("iab.tws.port"), clientID); logger.info("Connected: " + ecs.isConnected()); // If connected ... if (ecs.isConnected()) { // If no executor name is specified, use ALL as wildcard if (name == null) { // Get the engine name name = genericProperties.getString("engine.core.name", "ALL"); } // Check which objects from the watchlist should run within this executor WatchListDAO wfw = new WatchListDAO(); WatchList[] wl = wfw.getWatchlistByExecutorAsObject(name); // Start the market data feeds individually for (int i = 0; i < wl.length; i++) { String symbol = wl[i].getSymbol(); Integer ID = Integer.valueOf(wl[i].getID()); String currency = wl[i].getCurrency(); // By default, assume the currency is USD, if not specified otherwise if (currency == null) { currency = "USD"; } logger.info("*** Starting new MarketDataFeeder for " + symbol + " ..."); new MarketDataReader(ecs, ID, symbol, currency); } // Request for news updates from the API logger.info("Subscribing to News Bulletins ..."); ecs.reqNewsBulletins(true); // Make sure to listen to outgoing orders from the core engine ActiveMQFactory amf = ActiveMQFactory.getInstance(); logger.debug("Creating new order message listener ..."); OrderMessageListener tml = new OrderMessageListener(); Destination orders = amf.createDestination("orderChannel"); new ActiveMQFactory().createMessageConsumer(orders, tml); } else { logger.error("Can not connect to local ECClient - check your configuration ... will exit"); System.exit(0); } } catch (Exception e) { // TODO Auto-generated catch block logger.error(e.getLocalizedMessage()); e.printStackTrace(); } }
From source file:org.restcomm.connect.commons.configuration.sets.impl.MgAsrConfigurationSet.java
public MgAsrConfigurationSet(ConfigurationSource source, Configuration config) { super(source); drivers = Collections.unmodifiableList(config.getList("runtime-settings.mg-asr-drivers.driver")); defaultDriver = config.getString("runtime-settings.mg-asr-drivers[@default]"); languages = Collections.unmodifiableList(config.getList("runtime-settings.asr-languages.language")); defaultLanguage = config.getString("runtime-settings.asr-languages[@default]"); asrMRT = config.containsKey("runtime-settings.asr-mrt-timeout") ? config.getInt("runtime-settings.asr-mrt-timeout") : 60;/*from ww w .ja v a2 s . c o m*/ defaultGatheringTimeout = config.containsKey("runtime-settings.default-gathering-timeout") ? config.getInt("runtime-settings.default-gathering-timeout") : 5; }
From source file:org.restcomm.sbc.ConfigurationCache.java
private ConfigurationCache(SipFactory factory, Configuration configuration) { sipFactory = factory;/*from w w w .ja v a 2 s . c om*/ mzIface = configuration.getString("runtime-settings.militarized-zone.iface-name"); mzIPAddress = configuration.getString("runtime-settings.militarized-zone.ip-address"); mzTransport = configuration.getString("runtime-settings.militarized-zone.transport"); mzPort = configuration.getInt("runtime-settings.militarized-zone.port"); dmzIface = configuration.getString("runtime-settings.de-militarized-zone.iface-name"); dmzIPAddress = configuration.getString("runtime-settings.de-militarized-zone.ip-address"); dmzTransport = configuration.getString("runtime-settings.de-militarized-zone.transport"); dmzPort = configuration.getInt("runtime-settings.de-militarized-zone.port"); routeMZIPAddress = configuration .getString("runtime-settings.routing-policy.militarized-zone-target.ip-address"); routeMZTransport = configuration .getString("runtime-settings.routing-policy.militarized-zone-target.transport"); routeMZPort = configuration.getInt("runtime-settings.routing-policy.militarized-zone-target.port"); regThrottleEnabled = configuration.getBoolean("registrar-throttle.enable"); regThrottleMinRegistartTTL = configuration.getInt("registrar-throttle.min-registrar-expiration"); regThrottleMaxUATTL = configuration.getInt("registrar-throttle.max-ua-expiration"); }