Example usage for org.apache.commons.configuration Configuration getInt

List of usage examples for org.apache.commons.configuration Configuration getInt

Introduction

In this page you can find the example usage for org.apache.commons.configuration Configuration getInt.

Prototype

int getInt(String key, int defaultValue);

Source Link

Document

Get a int associated with the given configuration key.

Usage

From source file:org.janusgraph.olap.PageRankVertexProgram.java

@Override
public void loadState(final Graph graph, final Configuration configuration) {
    dampingFactor = configuration.getDouble(DAMPING_FACTOR, 0.85D);
    maxIterations = configuration.getInt(MAX_ITERATIONS, 10);
    vertexCount = configuration.getLong(VERTEX_COUNT, 1L);
}

From source file:org.lockss.servlet.LockssOiosamlSpFilter.java

private void restartCRLChecker(Configuration conf) {
    final String DEBUG_HEADER = "restartCRLChecker(): ";
    crlChecker.stopChecker();/* w ww  .  j  a v  a 2  s.  co  m*/
    int period = conf.getInt(Constants.PROP_CRL_CHECK_PERIOD, 600);
    if (log.isDebug3())
        log.debug3(DEBUG_HEADER + "period = " + period);

    if (period > 0) {
        crlChecker.startChecker(period, IdpMetadata.getInstance(), conf);
    }
}

From source file:org.loggo.server.Server.java

protected void createTopic(String zookeepers, Configuration kafkaSection) {
    ZkClient zk = new ZkClient(zookeepers);
    try {//  ww w  . j  a  v a2  s. c  o m
        String topic = kafkaSection.getString("topic", Defaults.TOPIC);
        if (AdminUtils.topicExists(zk, topic)) {
            return;
        }
        int partitions = kafkaSection.getInt("topic.partitions", Defaults.PARTITIONS);
        int replication = kafkaSection.getInt("topic.replication", Defaults.REPLICATIONS);
        Properties properties = new Properties();
        String propString = kafkaSection.getString("topic.properties", "");
        for (String keyValue : propString.split(",")) {
            String parts[] = keyValue.split("=");
            if (parts.length == 2) {
                properties.setProperty(parts[0], parts[1]);
            }
        }
        AdminUtils.createTopic(zk, topic, partitions, replication, properties);
    } finally {
        zk.close();
    }
}

From source file:org.matsim.contrib.taxi.optimizer.DefaultTaxiOptimizerParams.java

public DefaultTaxiOptimizerParams(Configuration optimizerConfig, boolean doUnscheduleAwaitingRequests,
        boolean doUpdateTimelines) {
    this.doUnscheduleAwaitingRequests = doUnscheduleAwaitingRequests;
    this.doUpdateTimelines = doUnscheduleAwaitingRequests;

    reoptimizationTimeStep = optimizerConfig.getInt(REOPTIMIZATION_TIME_STEP, 1);
}

From source file:org.mobicents.servlet.restcomm.telephony.CallManager.java

public CallManager(final Configuration configuration, final ServletContext context, final ActorSystem system,
        final MediaServerControllerFactory msControllerFactory, final ActorRef conferences,
        final ActorRef bridges, final ActorRef sms, final SipFactory factory, final DaoManager storage) {
    super();/*from  w  w  w. j  a  v  a  2  s.  c o m*/
    this.system = system;
    this.configuration = configuration;
    this.context = context;
    this.msControllerFactory = msControllerFactory;
    this.conferences = conferences;
    this.bridges = bridges;
    this.sms = sms;
    this.sipFactory = factory;
    this.storage = storage;
    final Configuration runtime = configuration.subset("runtime-settings");
    final Configuration outboundProxyConfig = runtime.subset("outbound-proxy");
    SipURI outboundIntf = outboundInterface("udp");
    if (outboundIntf != null) {
        myHostIp = ((SipURI) outboundIntf).getHost().toString();
    } else {
        String errMsg = "SipURI outboundIntf is null";
        sendNotification(errMsg, 14001, "error", false);

        if (context == null)
            errMsg = "SipServlet context is null";
        sendNotification(errMsg, 14002, "error", false);
    }
    Configuration mediaConf = configuration.subset("media-server-manager");
    mediaExternalIp = mediaConf.getString("mgcp-server.external-address");
    proxyIp = runtime.subset("telestax-proxy").getString("uri").replaceAll("http://", "").replaceAll(":2080",
            "");

    if (mediaExternalIp == null || mediaExternalIp.isEmpty())
        mediaExternalIp = myHostIp;

    if (proxyIp == null || proxyIp.isEmpty())
        proxyIp = myHostIp;

    this.useTo = runtime.getBoolean("use-to");
    this.authenticateUsers = runtime.getBoolean("authenticate");

    this.primaryProxyUri = outboundProxyConfig.getString("outbound-proxy-uri");
    this.primaryProxyUsername = outboundProxyConfig.getString("outbound-proxy-user");
    this.primaryProxyPassword = outboundProxyConfig.getString("outbound-proxy-password");

    this.fallBackProxyUri = outboundProxyConfig.getString("fallback-outbound-proxy-uri");
    this.fallBackProxyUsername = outboundProxyConfig.getString("fallback-outbound-proxy-user");
    this.fallBackProxyPassword = outboundProxyConfig.getString("fallback-outbound-proxy-password");

    this.activeProxy = primaryProxyUri;
    this.activeProxyUsername = primaryProxyUsername;
    this.activeProxyPassword = primaryProxyPassword;

    numberOfFailedCalls = new AtomicInteger();
    numberOfFailedCalls.set(0);
    useFallbackProxy = new AtomicBoolean();
    useFallbackProxy.set(false);

    allowFallback = outboundProxyConfig.getBoolean("allow-fallback", false);

    maxNumberOfFailedCalls = outboundProxyConfig.getInt("max-failed-calls", 20);

    allowFallbackToPrimary = outboundProxyConfig.getBoolean("allow-fallback-to-primary", false);

    patchForNatB2BUASessions = runtime.getBoolean("patch-for-nat-b2bua-sessions", true);

    //Monitoring Service
    this.monitoring = (ActorRef) context.getAttribute(MonitoringService.class.getName());
}

From source file:org.mobicents.servlet.restcomm.telephony.ua.UserAgentManager.java

public UserAgentManager(final Configuration configuration, final SipFactory factory, final DaoManager storage,
        final ServletContext servletContext) {
    super();/* w w  w. j  a  v  a 2  s .  c  o  m*/
    // this.configuration = configuration;
    this.servletContext = servletContext;
    monitoringService = (ActorRef) servletContext.getAttribute(MonitoringService.class.getName());
    final Configuration runtime = configuration.subset("runtime-settings");
    this.authenticateUsers = runtime.getBoolean("authenticate");
    this.factory = factory;
    this.storage = storage;
    pingInterval = runtime.getInt("ping-interval", 60);
    getContext().setReceiveTimeout(Duration.create(pingInterval, TimeUnit.SECONDS));
    logger.info("About to run firstTimeCleanup()");
    firstTimeCleanup();
}

From source file:org.mobicents.servlet.restcomm.tts.AttSpeechSynthesizer.java

public AttSpeechSynthesizer(final Configuration configuration) {
    super();/*  www. j a  v  a2  s  .  co  m*/
    men = new ConcurrentHashMap<String, String>();
    women = new ConcurrentHashMap<String, String>();
    load(configuration);
    rootDir = configuration.getString("tts-client-directory");
    player = new ClientPlayer(rootDir, configuration.getString("host"), configuration.getInt("port", 7000));
    player.Verbose = configuration.getBoolean("verbose-output", false);
}

From source file:org.mot.core.scheduler.BackTestSimulator.java

private void init() {

    PropertiesFactory pf = PropertiesFactory.getInstance();

    Configuration simulationProperties;
    try {/*from www .j a va  2s  . c  om*/
        simulationProperties = new PropertiesConfiguration(pf.getConfigDir() + "/simulation.properties");

        frequency = simulationProperties.getString("simulation.default.frequency", "TICK");
        quantity = simulationProperties.getInt("simulation.default.quantity", 10);
        minProfit = simulationProperties.getDouble("simulation.default.minProfit", 2.0);
        className = simulationProperties.getString("simulation.default.class",
                "org.mot.client.sg.mvgAvg.SimpleMvgAvgComparison");
        txnpct = simulationProperties.getDouble("simulation.order.txncost.pct", 0.0024);

    } catch (ConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    Map<Integer, String> instruments = new Hashtable<Integer, String>();

    WatchListDAO wld = new WatchListDAO();
    instruments = wld.getWatchlistAsTable("STK");

    Iterator<Entry<Integer, String>> it = instruments.entrySet().iterator();

    while (it.hasNext()) {
        final Map.Entry<Integer, String> entry = it.next();
        String symbol = entry.getValue();

        this.triggerYesterdaysReplay(symbol);
        this.triggerLastWeekReplay(symbol);
        //this.triggerLastMonthReplay(symbol);

    }
}

From source file:org.mot.core.simulation.SimulationLoader.java

public static void main(String[] args) {

    Options options = new Options();
    options.addOption("c", true, "Config directory");
    options.addOption("n", true, "Provide the name of the simulation class");
    options.addOption("l", true, "List of instruments - separated by comma (no spaces!).");
    options.addOption("t", true, "Transaction costs - normally 0.0024 bps");
    options.addOption("s", true, "Start date in the format of 2014-07-01");
    options.addOption("e", true, "End date in the format of 2014-07-31");
    options.addOption("w", true, "Week of Year to process - this will ignore -s / -e flag");

    if (args.length == 0) {
        System.out.println("*** Missing arguments: ***");
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("runSimulationLoader.sh|.bat", options);
        System.exit(0);//from ww  w. j ava  2 s  .  c o  m
    }

    long t1 = System.currentTimeMillis();

    try {
        CommandLineParser parser = new BasicParser();
        CommandLine cmd = parser.parse(options, args);

        PropertiesFactory pf = PropertiesFactory.getInstance();

        if (cmd.getOptionValue("c") != null) {
            // First make sure to set the config directory
            pf.setConfigDir(cmd.getOptionValue("c"));
        }

        System.setProperty("PathToConfigDir", pf.getConfigDir());

        logger.debug("Starting a new Simulation ...");

        // Read in properties from file
        Configuration simulationProperties;

        simulationProperties = new PropertiesConfiguration(pf.getConfigDir() + "/simulation.properties");

        final String frequency = simulationProperties.getString("simulation.default.frequency", "TICK");
        final int quantity = simulationProperties.getInt("simulation.default.quantity", 10);
        final Double minProfit = simulationProperties.getDouble("simulation.default.minProfit", 2.0);
        String className = simulationProperties.getString("simulation.default.class",
                "org.mot.client.sg.mvgAvg.SimpleMvgAvgComparison");

        Double txnpct;
        // Get the transaction percentage
        if (cmd.getOptionValue("t") != null) {
            txnpct = Double.valueOf(cmd.getOptionValue("t"));
        } else {
            txnpct = simulationProperties.getDouble("simulation.order.txncost.pct", 0.0024);
        }

        // Make sure to overwrite the className if provided in the command line
        if (cmd.getOptionValue("n") != null) {
            className = cmd.getOptionValue("n");
        }

        String[] symbols;
        // Array for the list of instruments
        if (cmd.getOptionValues("l") != null) {
            symbols = cmd.getOptionValues("l");

        } else {
            symbols = simulationProperties.getStringArray("simulation.default.instruments");
        }

        String startDate = null;
        String endDate = null;

        if (cmd.getOptionValue("w") != null) {

            DateBuilder db = new DateBuilder();
            String pattern = "yyyy-MM-dd";
            startDate = db.getDateForWeekOfYear(Integer.valueOf(cmd.getOptionValue("w")), pattern);
            endDate = db.addDaysToDate(startDate, pattern, 5);

        } else {

            // Get the start date
            if (cmd.getOptionValue("s") != null) {
                startDate = cmd.getOptionValue("s");
            } else {
                startDate = simulationProperties.getString("simulation.default.date.start", "2014-07-01");
            }

            // get the End date
            if (cmd.getOptionValue("e") != null) {
                endDate = cmd.getOptionValue("e");
            } else {
                endDate = simulationProperties.getString("simulation.default.date.end", "2014-07-31");
            }
        }

        System.out.println("*** Loading new values to simulation pipeline: *** ");
        System.out.println("* Using configuration from: " + pf.getConfigDir());
        System.out.println("* for Symbol: " + symbols.toString());
        System.out.println("* Start date: " + startDate);
        System.out.println("* End date: " + endDate);
        System.out.println("* Transaction costs: " + txnpct);
        System.out.println("* Using class file: " + className);
        System.out.println("************************************************** ");

        PropertyConfigurator.configure(pf.getConfigDir() + "/log4j.properties");

        Map<Integer, String> instruments = new Hashtable<Integer, String>();
        if (symbols[0].equals("ALL")) {
            WatchListDAO wld = new WatchListDAO();
            instruments = wld.getWatchlistAsTable("STK");

        } else {
            for (int p = 0; p < symbols.length; p++) {
                instruments.put(p, symbols[p].trim());
            }
        }

        Iterator<Entry<Integer, String>> it = instruments.entrySet().iterator();

        while (it.hasNext()) {
            final Map.Entry<Integer, String> entry = it.next();

            SimulationLoader msa = new SimulationLoader();
            //msa.loadSimulationRequests(entry.getValue(), className, frequency, quantity,  rangemin, rangemax, maxIncrement, startDate, endDate, txnpct);

            // (String symbol, String className, String frequency, int quantity, String startDate, String endDate, Double txnPct, Double minProfit ) {
            msa.loadSimulationRequests(entry.getValue(), className, frequency, quantity, startDate, endDate,
                    txnpct, minProfit);

        }

        System.out.println("*** FINISHED *** ");

    } catch (ConfigurationException e1) {
        // TODO Auto-generated catch block

        e1.printStackTrace();

        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("runSimulationLoader.sh|.bat", options);

    } catch (Exception e) {
        // TODO Auto-generated catch block

        e.printStackTrace();

        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("runSimulationLoader.sh|.bat", options);

    }

    long totalTime = (System.currentTimeMillis() - t1);

    logger.debug("End... Run took: " + totalTime + " msecs");
    System.exit(0);

}

From source file:org.mot.core.simulation.SimulationRunner.java

public static void main(String[] args) {

    // Run with -w 1-42 -l TSLA -1 581 -2 730 -d

    Options options = new Options();
    options.addOption("c", true, "Config directory");
    options.addOption("l", true, "Single instrument/symbol.");
    options.addOption("1", true, "Moving Average 1");
    options.addOption("2", true, "Moving Average 2");
    options.addOption("w", true, "Week of Year to process");
    options.addOption("d", false, "Write results to DB (default: false)");

    if (args.length == 0) {
        System.out.println("*** Missing arguments: ***");
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("runSimulator.sh|.bat", options);
        System.exit(0);/* www. j  a  v a 2  s. com*/
    }

    try {
        // Setting command line options
        CommandLineParser parser = new BasicParser();
        CommandLine cmd = parser.parse(options, args);

        PropertiesFactory pf = PropertiesFactory.getInstance();

        if (cmd.hasOption("c")) {
            // First make sure to set the config directory
            pf.setConfigDir(cmd.getOptionValue("c"));
        } else {
            // Default the configuration directory to <ROOT>/conf
            pf.setConfigDir("conf");
        }

        System.setProperty("PathToConfigDir", pf.getConfigDir());

        // Read in properties from file
        Configuration simulationProperties;

        simulationProperties = new PropertiesConfiguration(pf.getConfigDir() + "/simulation.properties");
        final String className = simulationProperties.getString("simulation.default.class",
                "org.mot.core.esper.AdvancedMvgAvgComparisonListenerG4");

        Double txnpct;
        // Get the transaction percentage
        if (cmd.getOptionValue("t") != null) {
            txnpct = Double.valueOf(cmd.getOptionValue("t"));
        } else {
            txnpct = simulationProperties.getDouble("simulation.order.txncost.pct", 0.0024);
        }

        String symbol = null;
        // Array for the list of instruments
        if (cmd.getOptionValue("l") != null) {
            symbol = cmd.getOptionValue("l");
        }

        Configuration genericProperties = new PropertiesConfiguration(pf.getConfigDir() + "/config.properties");
        PropertyConfigurator.configure(pf.getConfigDir() + "/log4j.properties");
        final int quantity = simulationProperties.getInt("simulation.default.quantity", 10);

        SimulationRunner rmas = new SimulationRunner();

        if (cmd.getOptionValue("w") != null) {

            String week = cmd.getOptionValue("w");
            Boolean writeToDB = false;

            if (cmd.hasOption("d")) {
                writeToDB = true;
            }

            int m1 = Integer.valueOf(cmd.getOptionValue("1"));
            int m2 = Integer.valueOf(cmd.getOptionValue("2"));

            if (week.contains("-")) {

                String[] weekList = week.split("-");
                int start = Integer.valueOf(weekList[0]);
                int end = Integer.valueOf(weekList[1]);

                for (int u = start; u < end; u++) {
                    rmas.processSingleRequestByWeek(m1, m2, txnpct, symbol, quantity, u, writeToDB, className);
                }

            } else {
                rmas.processSingleRequestByWeek(m1, m2, txnpct, symbol, quantity, Integer.valueOf(week),
                        writeToDB, className);
            }

            System.exit(0);

        } else {
            rmas.startThreads(genericProperties);

            while (true) {
                Thread.sleep(1000);
            }
        }

    } catch (ParseException e1) {
        // TODO Auto-generated catch block
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("runMovingAverageSimulator.sh|.bat", options);

    } catch (ConfigurationException e) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("runMovingAverageSimulator.sh|.bat", options);// TODO Auto-generated catch block

    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}