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:com.baifendian.swordfish.execserver.runner.flow.FlowRunnerManager.java

public FlowRunnerManager(Configuration conf) {
    this.flowDao = DaoFactory.getDaoInstance(FlowDao.class);

    int flowThreads = conf.getInt(Constants.EXECUTOR_FLOWRUNNER_THREADS, Constants.defaultFlowRunnerThreadNum);
    ThreadFactory flowThreadFactory = new ThreadFactoryBuilder().setNameFormat("Exec-Worker-FlowRunner")
            .build();//from   w ww.  j ava2s.com
    flowExecutorService = Executors.newFixedThreadPool(flowThreads, flowThreadFactory);

    int nodeThreads = conf.getInt(Constants.EXECUTOR_NODERUNNER_THREADS, Constants.defaultNodeRunnerThreadNum);
    ThreadFactory nodeThreadFactory = new ThreadFactoryBuilder().setNameFormat("Exec-Worker-NodeRunner")
            .build();
    nodeExecutorService = Executors.newFixedThreadPool(nodeThreads, nodeThreadFactory);

    // ?? runningFlows ??
    Thread cleanThread = new Thread(() -> {
        while (true) {
            try {
                cleanFinishedFlows();
            } catch (Exception e) {
                logger.error("clean thread error ", e);
            } finally {
                try {
                    Thread.sleep(Constants.defaultCleanFinishFlowInterval);
                } catch (InterruptedException e) {
                }
            }
        }
    });

    cleanThread.setDaemon(true);
    cleanThread.setName("finishedFlowClean");
    cleanThread.start();
}

From source file:com.appeligo.search.util.SMSSender.java

public SMSSender() throws MalformedURLException {
    Configuration config = ConfigUtils.getSystemConfig();
    mailHost = config.getString("smtpServer", "localhost");
    password = config.getString("smtpSenderPassword");
    smtpUser = config.getString("smtpUser", "alerts@flip.tv");
    port = config.getInt("smtpPort", 25);
    epg = DefaultEpg.getInstance();/*from   ww w .  jav a2  s . c o  m*/
}

From source file:dk.itst.oiosaml.sp.service.SPFilter.java

private void restartCRLChecker(Configuration conf) {
    crlChecker.stopChecker();/*  ww w  .j a va  2s  . c om*/
    int period = conf.getInt(Constants.PROP_CRL_CHECK_PERIOD, 600);
    if (period > 0) {
        crlChecker.startChecker(period, IdpMetadata.getInstance(), conf);
    }
}

From source file:com.dcsquare.hivemq.plugin.fileauthentication.authentication.FileAuthenticator.java

/**
 * The configuration and {@link PasswordComparator} is injected, using Guice.
 *
 * @param configurations     object, which holds all properties read from the specified configuration files in {@link com.dcsquare.hivemq.plugin.fileauthentication.FileAuthenticationModule}
 * @param passwordComparator instance of the class {@link PasswordComparator}
 *//* w  w  w  .j ava  2 s .c  o m*/
@Inject
public FileAuthenticator(Configuration configurations, PasswordComparator passwordComparator) {

    this.configurations = configurations;
    this.passwordComparator = passwordComparator;

    isHashed = configurations.getBoolean("passwordHashing.enabled", true);
    iterations = configurations.getInt("passwordHashing.iterations", 1000000);
    algorithm = configurations.getString("passwordHashing.algorithm", "SHA-512");
    separationChar = configurations.getString("passwordHashingSalt.separationChar", "$");
    isSalted = configurations.getBoolean("passwordHashingSalt.enabled", true);
    isFirst = configurations.getBoolean("passwordHashingSalt.isFirst", true);
}

From source file:edu.berkeley.sparrow.examples.SimpleFrontend.java

public void run(String[] args) {
    try {/*www  . j ava  2s . c  om*/
        OptionParser parser = new OptionParser();
        parser.accepts("c", "configuration file").withRequiredArg().ofType(String.class);
        parser.accepts("help", "print help statement");
        OptionSet options = parser.parse(args);

        if (options.has("help")) {
            parser.printHelpOn(System.out);
            System.exit(-1);
        }

        // Logger configuration: log to the console
        BasicConfigurator.configure();
        LOG.setLevel(Level.DEBUG);

        Configuration conf = new PropertiesConfiguration();

        if (options.has("c")) {
            String configFile = (String) options.valueOf("c");
            conf = new PropertiesConfiguration(configFile);
        }

        int arrivalPeriodMillis = conf.getInt(JOB_ARRIVAL_PERIOD_MILLIS, DEFAULT_JOB_ARRIVAL_PERIOD_MILLIS);
        int experimentDurationS = conf.getInt(EXPERIMENT_S, DEFAULT_EXPERIMENT_S);
        LOG.debug("Using arrival period of " + arrivalPeriodMillis + " milliseconds and running experiment for "
                + experimentDurationS + " seconds.");
        int tasksPerJob = conf.getInt(TASKS_PER_JOB, DEFAULT_TASKS_PER_JOB);
        int taskDurationMillis = conf.getInt(TASK_DURATION_MILLIS, DEFAULT_TASK_DURATION_MILLIS);

        int schedulerPort = conf.getInt(SCHEDULER_PORT, SchedulerThrift.DEFAULT_SCHEDULER_THRIFT_PORT);
        String schedulerHost = conf.getString(SCHEDULER_HOST, DEFAULT_SCHEDULER_HOST);
        client = new SparrowFrontendClient();
        client.initialize(new InetSocketAddress(schedulerHost, schedulerPort), APPLICATION_ID, this);

        JobLaunchRunnable runnable = new JobLaunchRunnable(tasksPerJob, taskDurationMillis);
        ScheduledThreadPoolExecutor taskLauncher = new ScheduledThreadPoolExecutor(1);
        taskLauncher.scheduleAtFixedRate(runnable, 0, arrivalPeriodMillis, TimeUnit.MILLISECONDS);

        long startTime = System.currentTimeMillis();
        LOG.debug("sleeping");
        while (System.currentTimeMillis() < startTime + experimentDurationS * 1000) {
            Thread.sleep(100);
        }
        taskLauncher.shutdown();
    } catch (Exception e) {
        LOG.error("Fatal exception", e);
    }
}

From source file:edu.kit.dama.staging.adalapi.protocol.SimpleHttp.java

@Override
public final void configure(Configuration pConfiguration) {
    //allow to set socket timeout for connection (default: 30s)
    useCompression = pConfiguration.getBoolean("compression", Boolean.FALSE);
    bufferSize = pConfiguration.getInt("bufferSize", READ_BUFFER_SIZE);
    if (useCompression) {
        LOGGER.debug("Using compression");
    }//from w w w .  java 2s .  co m
    LOGGER.debug("Special WebDav protocol features:: Compression enabled: {}, Buffer size: {}",
            new Object[] { useCompression, bufferSize });
}

From source file:edu.berkeley.sparrow.daemon.nodemonitor.NodeMonitorThrift.java

/**
 * Initialize this thrift service.//from  w  w  w.ja v  a  2  s.c  o m
 *
 * This spawns 2 multi-threaded thrift servers, one exposing the app-facing
 * agent service and the other exposing the internal-facing agent service,
 * and listens for requests to both servers. We require explicit specification of the
 * ports for these respective interfaces, since they cannot always be determined from
 * within this class under certain configurations (e.g. a config file specifies
 * multiple NodeMonitors).
 */
public void initialize(Configuration conf, int nmPort, int internalPort) throws IOException {
    nodeMonitor.initialize(conf, internalPort);

    // Setup application-facing agent service.
    NodeMonitorService.Processor<NodeMonitorService.Iface> processor = new NodeMonitorService.Processor<NodeMonitorService.Iface>(
            this);

    int threads = conf.getInt(SparrowConf.NM_THRIFT_THREADS, DEFAULT_NM_THRIFT_THREADS);
    TServers.launchThreadedThriftServer(nmPort, threads, processor);

    // Setup internal-facing agent service.
    InternalService.Processor<InternalService.Iface> internalProcessor = new InternalService.Processor<InternalService.Iface>(
            this);
    int internalThreads = conf.getInt(SparrowConf.INTERNAL_THRIFT_THREADS, DEFAULT_INTERNAL_THRIFT_THREADS);
    TServers.launchThreadedThriftServer(internalPort, internalThreads, internalProcessor);

    internalAddr = new InetSocketAddress(InetAddress.getLocalHost(), internalPort);
}

From source file:ch.epfl.eagle.daemon.nodemonitor.NodeMonitorThrift.java

/**
 * Initialize this thrift service./*  w w w  . ja va2  s .c  om*/
 *
 * This spawns 2 multi-threaded thrift servers, one exposing the app-facing
 * agent service and the other exposing the internal-facing agent service,
 * and listens for requests to both servers. We require explicit specification of the
 * ports for these respective interfaces, since they cannot always be determined from
 * within this class under certain configurations (e.g. a config file specifies
 * multiple NodeMonitors).
 */
public void initialize(Configuration conf, int nmPort, int internalPort) throws IOException {
    nodeMonitor.initialize(conf, internalPort);

    // Setup application-facing agent service.
    NodeMonitorService.Processor<NodeMonitorService.Iface> processor = new NodeMonitorService.Processor<NodeMonitorService.Iface>(
            this);

    int threads = conf.getInt(EagleConf.NM_THRIFT_THREADS, DEFAULT_NM_THRIFT_THREADS);
    TServers.launchThreadedThriftServer(nmPort, threads, processor);

    // Setup internal-facing agent service.
    InternalService.Processor<InternalService.Iface> internalProcessor = new InternalService.Processor<InternalService.Iface>(
            this);
    int internalThreads = conf.getInt(EagleConf.INTERNAL_THRIFT_THREADS, DEFAULT_INTERNAL_THRIFT_THREADS);
    TServers.launchThreadedThriftServer(internalPort, internalThreads, internalProcessor);

    internalAddr = new InetSocketAddress(InetAddress.getLocalHost(), internalPort);
}

From source file:com.appeligo.alerts.PendingAlertThread.java

public PendingAlertThread(Configuration config) {
    super("PendingAlertThread");
    isActive = true;//  ww w .j a va  2s  . c o m
    alertManager = AlertManager.getInstance();
    maxConsecutiveExceptions = config.getInt("maxConsecutiveExceptions", 10);
    url = config.getString("url", "http://localhost:8080");
}

From source file:com.knowbout.cc2nlp.server.CCEventServiceImpl.java

/**
 * All of this class' config params are ints, to made a convenience method for it.
 * @param name//w  w  w .j  av a  2  s. co m
 * @param defaultValue
 * @return
 */
private int getConfigInt(String name, int defaultValue) {
    Configuration config = Config.getConfiguration();
    return config.getInt(name, defaultValue);
}