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);

Source Link

Document

Get a int associated with the given configuration key.

Usage

From source file:uk.ac.ebi.fg.jobs.PubMedDataMinerWrapperJob.java

public void doExecute(JobExecutionContext jobExecutionContext) throws SchedulerException, InterruptedException {
    JobDataMap dataMap = jobExecutionContext.getMergedJobDataMap();

    Set<String> pubMedNewIds = (Set<String>) dataMap.get("pubMedNewIds");
    ConcurrentHashMap<String, SortedSet<PubMedId>> pubMedIdRelationMap = (ConcurrentHashMap<String, SortedSet<PubMedId>>) dataMap
            .get("pubMedIdRelationMap");
    Configuration properties = (Configuration) dataMap.get("properties");
    PubMedRetriever pubMedRetriever = (PubMedRetriever) dataMap.get("pubMedRetriever");
    IJobsController jobsController = (IJobsController) dataMap.get("jobsController");
    String jobGroup = properties.getString("quartz_job_group_name");
    int maxPubMedDist = properties.getInt("max_pubmed_distance");

    AtomicInteger pubMedCounter = new AtomicInteger();
    int i = 0;/* w  ww  .j  a  v  a2  s.  co m*/

    if (!pubMedNewIds.isEmpty() && maxPubMedDist >= 0) {
        for (String entry : pubMedNewIds) {
            ++i;

            JobDetail pubMedJobDetail = newJob(PubMedDataMinerJob.class)
                    .withIdentity("pubMedDataMinerJob" + i, jobGroup).storeDurably(true).requestRecovery(false)
                    .build();

            pubMedJobDetail.getJobDataMap().put("pubMedNewIds", pubMedNewIds);
            pubMedJobDetail.getJobDataMap().put("pubMedIdRelationMap", pubMedIdRelationMap);
            pubMedJobDetail.getJobDataMap().put("properties", properties);
            pubMedJobDetail.getJobDataMap().put("pubMedCounter", pubMedCounter);
            pubMedJobDetail.getJobDataMap().put("pubMedRetriever", pubMedRetriever);
            pubMedJobDetail.getJobDataMap().put("entry", entry);

            jobsController.addJob("pubMedDataMinerJob" + i, PubMedDataMinerJob.class, pubMedJobDetail);

            Thread.currentThread().wait(1);
        }

        // start first 3 jobs
        jobsController.executeJob("pubMedDataMinerJob" + 1, jobGroup);
        if (i > 1) {
            jobsController.executeJob("pubMedDataMinerJob" + 2, jobGroup);
            if (i > 2)
                jobsController.executeJob("pubMedDataMinerJob" + 3, jobGroup);
        }
    }
}

From source file:uk.ac.ebi.fg.jobs.PubMedSimilarityJob.java

public void doExecute(JobExecutionContext jobExecutionContext)
        throws JobExecutionException, InterruptedException {
    JobDataMap dataMap = jobExecutionContext.getMergedJobDataMap();

    Map<String, String> expToPubMedIdMap = (ConcurrentHashMap<String, String>) dataMap.get("expToPubMedIdMap");
    Map<String, SortedSet<PubMedId>> pubMedIdRelationMap = (Map<String, SortedSet<PubMedId>>) dataMap
            .get("pubMedIdRelationMap");
    ConcurrentHashMap<String, SortedSet<ExperimentId>> pubMedResults = (ConcurrentHashMap<String, SortedSet<ExperimentId>>) dataMap
            .get("pubMedResults");
    Configuration properties = (Configuration) dataMap.get("properties");

    final int maxPubMedSimilarityCount = properties.getInt("max_displayed_PubMed_similarities");
    Map<String, SortedSet<String>> pubMedIdToExpAccessionMap = reverseMap(expToPubMedIdMap);
    expToPubMedIdMap.clear();/*from   w w  w .j a v a 2s .  c o  m*/

    logger.info("PubMedSimilarityJob started");

    for (Map.Entry<String, SortedSet<String>> pubMedIdToExpAccession : pubMedIdToExpAccessionMap.entrySet()) {
        SortedSet<ExperimentId> result = new TreeSet<ExperimentId>();

        if (pubMedIdRelationMap.containsKey(pubMedIdToExpAccession.getKey())) { // false - failed to get similar PubMed ids
            for (PubMedId publication : pubMedIdRelationMap.get(pubMedIdToExpAccession.getKey())) {
                result.addAll(getExperiments(pubMedIdToExpAccessionMap, publication));
            }

            for (String expAccession : pubMedIdToExpAccession.getValue()) {
                pubMedResults.putIfAbsent(expAccession,
                        limitPubMedExperimentCount(result, maxPubMedSimilarityCount, expAccession));
            }
        }

        Thread.currentThread().wait(1);
    }

    pubMedIdToExpAccessionMap.clear();
    pubMedIdRelationMap.clear();
    logger.info("PubMedSimilarityJob finished");
}

From source file:uk.ac.ebi.fg.jobs.TermToURIMappingWrapperJob.java

public void doExecute(JobExecutionContext jobExecutionContext) throws InterruptedException, SchedulerException {
    JobDataMap dataMap = jobExecutionContext.getJobDetail().getJobDataMap();

    IJobsController jobsController = (IJobsController) dataMap.get("jobsController");
    Map<ExperimentId, SortedSet<EfoTerm>> expToURIMap = (ConcurrentHashMap<ExperimentId, SortedSet<EfoTerm>>) dataMap
            .get("expToURIMap");
    Map<String, String> expToPubMedIdMap = (ConcurrentHashMap<String, String>) dataMap.get("expToPubMedIdMap");
    List experiments = (List) dataMap.get("experiments");
    XPath xp = (XPath) dataMap.get("experimentXPath");
    Configuration properties = (Configuration) dataMap.get("properties");
    String jobGroup = properties.getString("quartz_job_group_name");
    int threadLimit = (properties.getInt("concurrent_job_limit") > 1)
            ? properties.getInt("concurrent_job_limit")
            : 1;//from   w  ww .j  a  va  2  s .c o  m

    List smallExperimentList = new LinkedList();
    int counter = 0;
    int separateAt = experiments.size() / threadLimit + experiments.size() % threadLimit;

    logger.info("Term to URI mapping jobs started");
    for (Object node : experiments) {
        smallExperimentList.add(node);
        ++counter;

        if (counter % separateAt == 0 || counter == experiments.size()) {
            JobDetail termToURIMappingJobDetail = newJob(TermToURIMappingJob.class)
                    .withIdentity("termToURIMappingJob" + counter, jobGroup).storeDurably(false)
                    .requestRecovery(false).build();

            termToURIMappingJobDetail.getJobDataMap().put("experiments", new LinkedList(smallExperimentList));
            termToURIMappingJobDetail.getJobDataMap().put("expToURIMap", expToURIMap);
            termToURIMappingJobDetail.getJobDataMap().put("expToPubMedIdMap", expToPubMedIdMap);
            termToURIMappingJobDetail.getJobDataMap().put("experimentXPath", xp);
            termToURIMappingJobDetail.getJobDataMap().put("counter", new Integer(counter));
            termToURIMappingJobDetail.getJobDataMap().put("separateAt", separateAt); // for jobListener use

            jobsController.addJob("termToURIMappingJob" + counter, TermToURIMappingJob.class,
                    termToURIMappingJobDetail);
            jobsController.executeJob("termToURIMappingJob" + counter, jobGroup);

            // clear list
            smallExperimentList.clear();
            Thread.currentThread().wait(1);
        }
    }
}

From source file:uk.co.gidley.jmxmonitor.RegistryManager.java

public void stop() throws InitialisationException, IOException {
    Configuration config = readConfiguration(configurationFile);
    String stopKey = config.getString(ThreadManager.JMXMONITOR_STOPKEY);
    int stopPort = config.getInt(ThreadManager.JMXMONITOR_STOPPORT);

    Socket socket = new Socket("localhost", stopPort);
    PrintWriter printWriter = new PrintWriter(socket.getOutputStream(), true);
    printWriter.write(stopKey);/*from  ww  w . j a  va2  s .  c  o  m*/
    printWriter.flush();

}

From source file:uk.co.gidley.jmxmonitor.services.InternalJmx.java

private void startRmiRegistry(Configuration configuration) throws InitialisationException {
    try {/*from w  w w  . ja  v a 2 s .c o  m*/
        int port = configuration.getInt(PROPERTY_PREFIX + LOCAL_RMI_PORT);
        logger.debug("Creating RMI Registry on {}", port);
        registry = LocateRegistry.createRegistry(port);
    } catch (RemoteException e) {
        logger.error("{}", e);
        throw new InitialisationException(e);
    }
}

From source file:uk.trainwatch.nrod.feed.NetworkRailConnection.java

@PostConstruct
public void start() {
    Configuration config = configurationService.getPrivateConfiguration("networkrail");

    activemq = new RemoteActiveMQConnection(config.getString("server"), config.getInt("port"),
            config.getString("clientid"), config.getString("username"), config.getString("password"));

    activemq.start();/*from w ww . j  a v  a  2s  .c o  m*/
}

From source file:util.AbstractReadSystemConfigurations.java

private static int readAnonymizationAfterMonths() {

    int months = 3; // Default, if in the configuration file a not valid value was specified

    try {//from   w  ww.j  a va2 s.c o m
        final Configuration config = new PropertiesConfiguration(PATH);
        months = config.getInt("anonymization.after.months");

    } catch (final ConfigurationException e) {
        LOG.error(e.toString());
    }

    return months;
}

From source file:util.AbstractReadSystemConfigurations.java

private static int maxResultsDisplay() {

    int maxResults = 0;

    try {//from w  ww  .  j  a v a 2s .c om
        final Configuration config = new PropertiesConfiguration(PATH);
        maxResults = config.getInt("maxResults.display");

    } catch (final ConfigurationException e) {
        LOG.error(e.toString());
    }

    return maxResults;
}

From source file:xcmailrstarter.StarterConf.java

public StarterConf(String[] args) throws Exception {
    // get the server file-location
    XCM_HOME = System.getProperty("xcmailr.xcmstarter.home");

    // get the config file-location
    String confFile = System.getProperty("ninja.external.configuration");
    PropertiesConfiguration cfg = new PropertiesConfiguration();
    cfg.setEncoding("utf-8");
    cfg.setDelimiterParsingDisabled(true);
    String confPath = XCM_HOME + "/" + confFile;

    // try to load the config
    cfg.load(confPath);/*from   w  w  w  .  j a  v a 2 s  .com*/
    final Configuration conf = (Configuration) cfg;
    XCM_DB_URL = conf.getString("ebean.datasource.databaseUrl");
    XCM_DB_USER = conf.getString("ebean.datasource.username");
    XCM_DB_PASS = conf.getString("ebean.datasource.password");
    XCM_DB_DRIVER = conf.getString("ebean.datasource.databaseDriver");
    XCM_PORT = conf.getInt("application.port");
    XCM_CONTEXT_PATH = conf.getString("application.basedir");
    XCM_HOST = conf.getString("application.host", "localhost");

}