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.appeligo.search.messenger.Messenger.java

public Messenger() {
    Configuration config = ConfigUtils.getMessageConfig();
    mailHost = config.getString("smtpServer", "localhost");
    password = config.getString("smtpSenderPassword", null);
    smtpUser = config.getString("smtpUser", null);
    debug = config.getBoolean("debugMailSender", true);
    port = config.getInt("smtpPort", 25);
    maxAttempts = config.getInt("maxMessageAttempts", 2);
    deleteMessagesOlderThanDays = config.getInt("deleteMessagesOlderThanDays", 7);
}

From source file:cross.datastructures.fragments.CachedList.java

@Override
public void configure(final Configuration cfg) {
    this.prefetchOnMiss = cfg.getBoolean(this.getClass().getName() + ".prefetchOnMiss", false);
    this.cacheSize = cfg.getInt(this.getClass().getName() + ".cacheSize", 1024);
}

From source file:com.appeligo.epg.DefaultEpg.java

private DefaultEpg() {
    Configuration config = ConfigUtils.getSystemConfig();
    try {/*from  w ww .j a  v  a  2  s  . c  o  m*/
        HessianProxyFactory factory = new HessianProxyFactory();
        String epgURL = config.getString("epgEndpoint");
        defaultEpgProvider = (EPGProvider) factory.create(EPGProvider.class, epgURL);
    } catch (Exception e) {
        log.fatal("Can't connect to EPG.", e);
    }
    minCachedPrograms = config.getInt("minCachedPrograms", 1000);
    maxCachedPrograms = config.getInt("maxCachedPrograms", 1500);
    log.debug("minCachedPrograms=" + minCachedPrograms + ", maxCachedPrograms=" + maxCachedPrograms);
    programCache = Collections
            .synchronizedMap(new ActiveCache<String, Program>(minCachedPrograms, maxCachedPrograms));
}

From source file:com.feedzai.fos.api.config.FosConfig.java

/**
 * Creates a new instance of the {@link FosConfig} class.
 *
 * @param configuration The base configuration to use.
 *///from  w  ww  . j  a  va2  s  .  c  o  m
public FosConfig(Configuration configuration) {
    checkNotNull(configuration, "Configuration cannot be null.");
    checkArgument(configuration.containsKey(FACTORY_NAME),
            "The configuration parameter " + FACTORY_NAME + " should be defined.");
    this.config = configuration;
    this.embeddedRegistry = configuration.getBoolean(EMBEDDED_REGISTRY, false);
    this.registryPort = configuration.getInt(REGISTRY_PORT, Registry.REGISTRY_PORT);
    this.factoryName = configuration.getString(FACTORY_NAME);
    this.headerLocation = configuration.getString(HEADER_LOCATION, "models");
    this.threadPoolSize = configuration.getInt(THREADPOOL_SIZE, 20);
    this.scoringPort = configuration.getInt(SCORING_PORT, DEFAULT_SCORING_PORT);
}

From source file:com.boozallen.cognition.ingest.accumulo.storm.AccumuloEventStorageBoltTest.java

@Test
public void testConfigureAccumuloBolt(@Injectable Configuration conf) {
    new Expectations() {
        {/*from   w ww  .j  a  v  a2 s. c  o m*/
            conf.getString(EVENT_TABLE);
            result = "eventTable";
            conf.getString(UUID_PREFIX, UUID_PREFIX_DEFAULT);
            result = UUID_PREFIX_DEFAULT;
            conf.getInt(SPLITS, SPLITS_DEFAULT);
            result = SPLITS_DEFAULT;
            conf.getString(VISIBILITY);
            result = "";
            conf.getString(VISIBILITY_BY_FIELD);
            result = "";
        }
    };

    bolt.configureAccumuloBolt(conf);
}

From source file:cross.Factory.java

private void configureThreadPool(final Configuration cfg) {
    this.maxthreads = cfg.getInt("cross.Factory.maxthreads", 1);
    final int numProcessors = Runtime.getRuntime().availableProcessors();
    this.log.debug("{} processors available to current runtime", numProcessors);
    if (this.maxthreads < 1) {
        this.log.debug("Automatically selecting {} threads according to number of available processors!",
                this.maxthreads);
        this.maxthreads = numProcessors;
    }/*from  ww  w .  java 2 s.  c om*/
    this.maxthreads = (this.maxthreads < numProcessors) ? this.maxthreads : numProcessors;
    cfg.setProperty("cross.Factory.maxthreads", this.maxthreads);
    cfg.setProperty("maltcms.pipelinethreads", this.maxthreads);
    this.log.debug("Starting with Thread-Pool of size: " + this.maxthreads);
    initThreadPools();
}

From source file:edu.cwru.sepia.environment.Environment.java

public Environment(Agent[] connectedagents, Model model, TurnTracker turnTracker, Configuration configuration) {
    this.connectedagents = connectedagents;
    agentIntermediaries = new ThreadIntermediary[connectedagents.length];
    for (int ag = 0; ag < connectedagents.length; ag++) {
        agentIntermediaries[ag] = new ThreadIntermediary(connectedagents[ag]);
        new Thread(agentIntermediaries[ag]).start();
    }/*from   ww w .j  a va 2 s.c  o m*/
    this.model = model;

    DELAY_MS = configuration.getInt("InterruptTime", -1);
    this.turnTracker = turnTracker;
    Integer[] players = model.getState().getView(Agent.OBSERVER_ID).getPlayerNumbers();
    for (Integer player : players) {
        turnTracker.addPlayer(player);
    }
    turnTracker.newEpisodeAndStep();
    model.setTurnTracker(turnTracker);
}

From source file:eu.socialsensor.main.BenchmarkConfiguration.java

public BenchmarkConfiguration(Configuration appconfig) {
    if (appconfig == null) {
        throw new IllegalArgumentException("appconfig may not be null");
    }/*w w  w . j  ava  2  s .co m*/

    Configuration eu = appconfig.subset("eu");
    Configuration socialsensor = eu.subset("socialsensor");

    //metrics
    final Configuration metrics = socialsensor.subset(GraphDatabaseConfiguration.METRICS_NS.getName());

    final Configuration graphite = metrics.subset(GRAPHITE);
    this.graphiteHostname = graphite.getString(GRAPHITE_HOSTNAME, null);
    this.graphiteReportingInterval = graphite.getLong(GraphDatabaseConfiguration.GRAPHITE_INTERVAL.getName(),
            1000 /*default 1sec*/);

    final Configuration csv = metrics.subset(CSV);
    this.csvReportingInterval = metrics.getLong(CSV_INTERVAL, 1000 /*ms*/);
    this.csvDir = csv.containsKey(CSV_DIR)
            ? new File(csv.getString(CSV_DIR, System.getProperty("user.dir") /*default*/))
            : null;

    Configuration dynamodb = socialsensor.subset("dynamodb");
    this.dynamodbWorkerThreads = dynamodb.getInt("workers", 25);
    Configuration credentials = dynamodb.subset(CREDENTIALS);
    this.dynamodbPrecreateTables = dynamodb.getBoolean("precreate-tables", Boolean.FALSE);
    this.dynamodbTps = Math.max(1, dynamodb.getLong(TPS, 750 /*default*/));
    this.dynamodbConsistentRead = dynamodb.containsKey(CONSISTENT_READ) ? dynamodb.getBoolean(CONSISTENT_READ)
            : false;
    this.dynamodbDataModel = dynamodb.containsKey("data-model")
            ? BackendDataModel.valueOf(dynamodb.getString("data-model"))
            : null;
    this.dynamodbCredentialsFqClassName = credentials.containsKey(CLASS_NAME)
            ? credentials.getString(CLASS_NAME)
            : null;
    this.dynamodbCredentialsCtorArguments = credentials.containsKey(CONSTRUCTOR_ARGS)
            ? credentials.getString(CONSTRUCTOR_ARGS)
            : null;
    this.dynamodbEndpoint = dynamodb.containsKey(ENDPOINT) ? dynamodb.getString(ENDPOINT) : null;
    this.dynamodbTablePrefix = dynamodb.containsKey(TABLE_PREFIX) ? dynamodb.getString(TABLE_PREFIX)
            : Constants.DYNAMODB_TABLE_PREFIX.getDefaultValue();

    Configuration orient = socialsensor.subset("orient");
    orientLightweightEdges = orient.containsKey(LIGHTWEIGHT_EDGES) ? orient.getBoolean(LIGHTWEIGHT_EDGES)
            : null;

    Configuration sparksee = socialsensor.subset("sparksee");
    sparkseeLicenseKey = sparksee.containsKey(LICENSE_KEY) ? sparksee.getString(LICENSE_KEY) : null;

    Configuration titan = socialsensor.subset(TITAN); //TODO(amcp) move dynamodb ns into titan
    bufferSize = titan.getInt(BUFFER_SIZE, GraphDatabaseConfiguration.BUFFER_SIZE.getDefaultValue());
    blocksize = titan.getInt(IDS_BLOCKSIZE, GraphDatabaseConfiguration.IDS_BLOCK_SIZE.getDefaultValue());
    pageSize = titan.getInt(PAGE_SIZE, GraphDatabaseConfiguration.PAGE_SIZE.getDefaultValue());

    // database storage directory
    if (!socialsensor.containsKey(DATABASE_STORAGE_DIRECTORY)) {
        throw new IllegalArgumentException("configuration must specify database-storage-directory");
    }
    dbStorageDirectory = new File(socialsensor.getString(DATABASE_STORAGE_DIRECTORY));
    dataset = validateReadableFile(socialsensor.getString(DATASET), DATASET);

    // load the dataset
    DatasetFactory.getInstance().getDataset(dataset);

    if (!socialsensor.containsKey(PERMUTE_BENCHMARKS)) {
        throw new IllegalArgumentException("configuration must set permute-benchmarks to true or false");
    }
    permuteBenchmarks = socialsensor.getBoolean(PERMUTE_BENCHMARKS);

    List<?> benchmarkList = socialsensor.getList("benchmarks");
    benchmarkTypes = new ArrayList<BenchmarkType>();
    for (Object str : benchmarkList) {
        benchmarkTypes.add(BenchmarkType.valueOf(str.toString()));
    }

    selectedDatabases = new TreeSet<GraphDatabaseType>();
    for (Object database : socialsensor.getList("databases")) {
        if (!GraphDatabaseType.STRING_REP_MAP.keySet().contains(database.toString())) {
            throw new IllegalArgumentException(
                    String.format("selected database %s not supported", database.toString()));
        }
        selectedDatabases.add(GraphDatabaseType.STRING_REP_MAP.get(database));
    }
    scenarios = permuteBenchmarks ? Ints.checkedCast(CombinatoricsUtils.factorial(selectedDatabases.size()))
            : 1;

    resultsPath = new File(System.getProperty("user.dir"), socialsensor.getString("results-path"));
    if (!resultsPath.exists() && !resultsPath.mkdirs()) {
        throw new IllegalArgumentException("unable to create results directory");
    }
    if (!resultsPath.canWrite()) {
        throw new IllegalArgumentException("unable to write to results directory");
    }

    randomNodes = socialsensor.getInteger(RANDOM_NODES, new Integer(100));

    if (this.benchmarkTypes.contains(BenchmarkType.CLUSTERING)) {
        if (!socialsensor.containsKey(NODES_COUNT)) {
            throw new IllegalArgumentException("the CW benchmark requires nodes-count integer in config");
        }
        nodesCount = socialsensor.getInt(NODES_COUNT);

        if (!socialsensor.containsKey(RANDOMIZE_CLUSTERING)) {
            throw new IllegalArgumentException("the CW benchmark requires randomize-clustering bool in config");
        }
        randomizedClustering = socialsensor.getBoolean(RANDOMIZE_CLUSTERING);

        if (!socialsensor.containsKey(ACTUAL_COMMUNITIES)) {
            throw new IllegalArgumentException("the CW benchmark requires a file with actual communities");
        }
        actualCommunities = validateReadableFile(socialsensor.getString(ACTUAL_COMMUNITIES),
                ACTUAL_COMMUNITIES);

        final boolean notGenerating = socialsensor.containsKey(CACHE_VALUES);
        if (notGenerating) {
            List<?> objects = socialsensor.getList(CACHE_VALUES);
            cacheValues = new ArrayList<Integer>(objects.size());
            cacheValuesCount = null;
            cacheIncrementFactor = null;
            for (Object o : objects) {
                cacheValues.add(Integer.valueOf(o.toString()));
            }
        } else if (socialsensor.containsKey(CACHE_VALUES_COUNT)
                && socialsensor.containsKey(CACHE_INCREMENT_FACTOR)) {
            cacheValues = null;
            // generate the cache values with parameters
            if (!socialsensor.containsKey(CACHE_VALUES_COUNT)) {
                throw new IllegalArgumentException(
                        "the CW benchmark requires cache-values-count int in config when cache-values not specified");
            }
            cacheValuesCount = socialsensor.getInt(CACHE_VALUES_COUNT);

            if (!socialsensor.containsKey(CACHE_INCREMENT_FACTOR)) {
                throw new IllegalArgumentException(
                        "the CW benchmark requires cache-increment-factor int in config when cache-values not specified");
            }
            cacheIncrementFactor = socialsensor.getDouble(CACHE_INCREMENT_FACTOR);
        } else {
            throw new IllegalArgumentException(
                    "when doing CW benchmark, must provide cache-values or parameters to generate them");
        }
    } else {
        randomizedClustering = null;
        nodesCount = null;
        cacheValuesCount = null;
        cacheIncrementFactor = null;
        cacheValues = null;
        actualCommunities = null;
    }
}

From source file:dk.dma.ais.abnormal.analyzer.AbnormalAnalyzerAppModule.java

@Provides
ReplayDownSampleFilter provideReplayDownSampleFilter() {
    Configuration configuration = getConfiguration();
    int downsampling = configuration.getInt(CONFKEY_AIS_DATASOURCE_DOWNSAMPLING, 0);
    ReplayDownSampleFilter filter = new ReplayDownSampleFilter(downsampling);
    LOG.info("Created ReplayDownSampleFilter with down sampling period of " + downsampling + " secs.");
    return filter;
}

From source file:com.linkedin.pinot.server.starter.helix.SegmentFetcherAndLoader.java

public SegmentFetcherAndLoader(DataManager dataManager, SegmentMetadataLoader metadataLoader,
        ZkHelixPropertyStore<ZNRecord> propertyStore, Configuration pinotHelixProperties, String instanceId) {
    _propertyStore = propertyStore;/*from ww  w.j a va 2s . c  o  m*/
    _dataManager = dataManager;
    _metadataLoader = metadataLoader;
    _instanceId = instanceId;
    int maxRetries = Integer.parseInt(CommonConstants.Server.DEFAULT_SEGMENT_LOAD_MAX_RETRY_COUNT);
    try {
        maxRetries = pinotHelixProperties.getInt(CommonConstants.Server.CONFIG_OF_SEGMENT_LOAD_MAX_RETRY_COUNT,
                maxRetries);
    } catch (Exception e) {
        // Keep the default value
    }
    _segmentLoadMaxRetryCount = maxRetries;

    long minRetryDelayMillis = Long
            .parseLong(CommonConstants.Server.DEFAULT_SEGMENT_LOAD_MIN_RETRY_DELAY_MILLIS);
    try {
        minRetryDelayMillis = pinotHelixProperties.getLong(
                CommonConstants.Server.CONFIG_OF_SEGMENT_LOAD_MIN_RETRY_DELAY_MILLIS, minRetryDelayMillis);
    } catch (Exception e) {
        // Keep the default value
    }
    _segmentLoadMinRetryDelayMs = minRetryDelayMillis;

    SegmentFetcherFactory.initSegmentFetcherFactory(pinotHelixProperties);
}