Java Code Examples for org.apache.commons.configuration.Configuration#getInt()

The following examples show how to use org.apache.commons.configuration.Configuration#getInt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DriftAnalysis.java    From AisAbnormal with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Inject
public DriftAnalysis(Configuration configuration, AppStatisticsService statisticsService, EventEmittingTracker trackingService, EventRepository eventRepository) {
    super(eventRepository, trackingService, null);
    this.statisticsService = statisticsService;

    setTrackPredictionTimeMax(configuration.getInteger(CONFKEY_ANALYSIS_DRIFT_PREDICTIONTIME_MAX, -1));

    SPEED_HIGH_MARK = configuration.getFloat(CONFKEY_ANALYSIS_DRIFT_SOG_MAX, 5.0f);
    SPEED_LOW_MARK = configuration.getFloat(CONFKEY_ANALYSIS_DRIFT_SOG_MIN, 1.0f);
    MIN_HDG_COG_DEVIATION_DEGREES = configuration.getFloat(CONFKEY_ANALYSIS_DRIFT_COGHDG, 45f);
    OBSERVATION_PERIOD_MINUTES = configuration.getInt(CONFKEY_ANALYSIS_DRIFT_PERIOD, 10);
    OBSERVATION_DISTANCE_METERS = configuration.getFloat(CONFKEY_ANALYSIS_DRIFT_DISTANCE, 500f);
    SHIP_LENGTH_MIN = configuration.getInt(CONFKEY_ANALYSIS_DRIFT_SHIPLENGTH_MIN, 50);

    LOG.info(this.getClass().getSimpleName() + " created (" + this + ").");
}
 
Example 2
Source File: HAConfiguration.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
public static ZookeeperProperties getZookeeperProperties(Configuration configuration) {
    String zookeeperConnectString = configuration.getString("atlas.kafka." + ZOOKEEPER_PREFIX + "connect");
    if (configuration.containsKey(HA_ZOOKEEPER_CONNECT)) {
        zookeeperConnectString = configuration.getString(HA_ZOOKEEPER_CONNECT);
    }

    String zkRoot = configuration.getString(ATLAS_SERVER_HA_ZK_ROOT_KEY, ATLAS_SERVER_ZK_ROOT_DEFAULT);
    int retriesSleepTimeMillis = configuration.getInt(HA_ZOOKEEPER_RETRY_SLEEPTIME_MILLIS,
            DEFAULT_ZOOKEEPER_CONNECT_SLEEPTIME_MILLIS);

    int numRetries = configuration.getInt(HA_ZOOKEEPER_NUM_RETRIES, DEFAULT_ZOOKEEPER_CONNECT_NUM_RETRIES);

    int sessionTimeout = configuration.getInt(HA_ZOOKEEPER_SESSION_TIMEOUT_MS,
            DEFAULT_ZOOKEEPER_SESSION_TIMEOUT_MILLIS);

    String acl = configuration.getString(HA_ZOOKEEPER_ACL);
    String auth = configuration.getString(HA_ZOOKEEPER_AUTH);
    return new ZookeeperProperties(zookeeperConnectString, zkRoot, retriesSleepTimeMillis, numRetries,
            sessionTimeout, acl, auth);
}
 
Example 3
Source File: ResourceManager.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
/**
 * @param config configuration for initializing resource manager
 */
public ResourceManager(Configuration config) {
  numQueryRunnerThreads = config.getInt(QUERY_RUNNER_CONFIG_KEY, DEFAULT_QUERY_RUNNER_THREADS);
  numQueryWorkerThreads = config.getInt(QUERY_WORKER_CONFIG_KEY, DEFAULT_QUERY_WORKER_THREADS);

  LOGGER.info("Initializing with {} query runner threads and {} worker threads", numQueryRunnerThreads,
      numQueryWorkerThreads);
  // pqr -> pinot query runner (to give short names)
  ThreadFactory queryRunnerFactory =
      new ThreadFactoryBuilder().setDaemon(false).setPriority(QUERY_RUNNER_THREAD_PRIORITY).setNameFormat("pqr-%d")
          .build();
  queryRunners =
      MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(numQueryRunnerThreads, queryRunnerFactory));

  // pqw -> pinot query workers
  ThreadFactory queryWorkersFactory =
      new ThreadFactoryBuilder().setDaemon(false).setPriority(Thread.NORM_PRIORITY).setNameFormat("pqw-%d").build();
  queryWorkers =
      MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(numQueryWorkerThreads, queryWorkersFactory));
}
 
Example 4
Source File: AccumuloConnectionUtils.java    From cognition with Apache License 2.0 5 votes vote down vote up
public static AccumuloConnectionConfig extractConnectionConfiguration(Configuration conf) {
  AccumuloConnectionConfig config = new AccumuloConnectionConfig();
  config.instance = conf.getString(INSTANCE);
  config.zooServers = conf.getString(ZOO_SERVERS);
  config.user = conf.getString(USER);
  config.key = conf.getString(KEY);
  config.maxMem = conf.getLong(MAX_MEM, MAX_MEM_DEFAULT);
  config.maxLatency = conf.getLong(MAX_LATENCY, MAX_LATENCY_DEFAULT);
  config.maxWriteThreads = conf.getInt(MAX_WRITE_THREADS, MAX_WRITE_THREADS_DEFAULT);
  return config;
}
 
Example 5
Source File: SpeedOverGroundAnalysis.java    From AisAbnormal with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Inject
public SpeedOverGroundAnalysis(Configuration configuration, AppStatisticsService statisticsService, StatisticDataRepository statisticsRepository, EventEmittingTracker trackingService, EventRepository eventRepository, BehaviourManager behaviourManager) {
    super(eventRepository, statisticsRepository, trackingService, behaviourManager);
    this.statisticsService = statisticsService;

    setTrackPredictionTimeMax(configuration.getInteger(CONFKEY_ANALYSIS_SOG_PREDICTIONTIME_MAX, -1));

    TOTAL_SHIP_COUNT_THRESHOLD = configuration.getInt(CONFKEY_ANALYSIS_SOG_CELL_SHIPCOUNT_MIN, 1000);
    PD = configuration.getFloat(CONFKEY_ANALYSIS_SOG_PD, 0.001f);
    SHIP_LENGTH_MIN = configuration.getInt(CONFKEY_ANALYSIS_SOG_SHIPLENGTH_MIN, 50);
    USE_AGGREGATED_STATS = configuration.getBoolean(CONFKEY_ANALYSIS_SOG_USE_AGGREGATED_STATS, false);

    LOG.info(getAnalysisName() + " created (" + this + ").");
}
 
Example 6
Source File: AtlasTopicCreator.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
protected void createTopic(Configuration atlasProperties, String topicName, ZkUtils zkUtils) {
    int numPartitions = atlasProperties.getInt("atlas.notification.hook.numthreads", 1);
    int numReplicas = atlasProperties.getInt("atlas.notification.replicas", 1);
    AdminUtils.createTopic(zkUtils, topicName,  numPartitions, numReplicas,
            new Properties(), RackAwareMode.Enforced$.MODULE$);
    LOG.warn("Created topic {} with partitions {} and replicas {}", topicName, numPartitions, numReplicas);
}
 
Example 7
Source File: FreeFlowAnalysis.java    From AisAbnormal with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Inject
public FreeFlowAnalysis(Configuration configuration, AppStatisticsService statisticsService, EventEmittingTracker trackingService, EventRepository eventRepository) {
    super(eventRepository, trackingService, null);
    this.statisticsService = statisticsService;

    this.xL = configuration.getInt(CONFKEY_ANALYSIS_FREEFLOW_XL, 8);
    this.xB = configuration.getInt(CONFKEY_ANALYSIS_FREEFLOW_XB, 8);
    this.dCog = configuration.getFloat(CONFKEY_ANALYSIS_FREEFLOW_DCOG, 15f);
    this.minReportingIntervalMillis = configuration.getInt(CONFKEY_ANALYSIS_FREEFLOW_MIN_REPORTING_PERIOD_MINUTES, 60) * 60 * 1000;

    String csvFileNameTmp = configuration.getString(CONFKEY_ANALYSIS_FREEFLOW_CSVFILE, null);
    if (csvFileNameTmp == null || isBlank(csvFileNameTmp)) {
        this.csvFileName = null;
        LOG.warn("Writing of free flow events to CSV file is disabled");
    } else {
        this.csvFileName = csvFileNameTmp.trim();
        LOG.info("Free flow events are appended to CSV file: " + this.csvFileName);
    }

    List<Object> bboxConfig = configuration.getList(CONFKEY_ANALYSIS_FREEFLOW_BBOX);
    if (bboxConfig != null) {
        final double n = Double.valueOf(bboxConfig.get(0).toString());
        final double e = Double.valueOf(bboxConfig.get(1).toString());
        final double s = Double.valueOf(bboxConfig.get(2).toString());
        final double w = Double.valueOf(bboxConfig.get(3).toString());
        this.areaToBeAnalysed = BoundingBox.create(Position.create(n, e), Position.create(s, w), CoordinateSystem.CARTESIAN);
    }

    setTrackPredictionTimeMax(configuration.getInteger(CONFKEY_ANALYSIS_FREEFLOW_PREDICTIONTIME_MAX, -1));
    setAnalysisPeriodMillis(configuration.getInt(CONFKEY_ANALYSIS_FREEFLOW_RUN_PERIOD, 30000) * 1000);

    LOG.info(this.getClass().getSimpleName() + " created (" + this + ").");
}
 
Example 8
Source File: AbnormalAnalyzerAppModule.java    From AisAbnormal with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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;
}
 
Example 9
Source File: EsIndexBolt.java    From cognition with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(Configuration conf) {
  conf.getKeys().forEachRemaining(
      key -> {
        String keyString = key.toString();
        if (keyString.startsWith("es")) {
          String cleanedKey = keyString.replaceAll("\\.\\.", ".");
          boltConfig.put(cleanedKey, conf.getString(keyString));
        }
      });

  manualFlushFreqSecs = conf.getInt(MANUAL_FLUSH_FREQ_SECS);
}
 
Example 10
Source File: Parallelized.java    From es6draft with MIT License 5 votes vote down vote up
protected int numberOfThreads(Class<?> klass) {
    Concurrency concurrency = klass.getAnnotation(Concurrency.class);
    int threads;
    int maxThreads;
    float factor;
    if (concurrency != null) {
        threads = concurrency.threads();
        maxThreads = concurrency.maxThreads();
        factor = concurrency.factor();
    } else {
        threads = getDefaultValue(Concurrency.class, "threads", Integer.class);
        maxThreads = getDefaultValue(Concurrency.class, "maxThreads", Integer.class);
        factor = getDefaultValue(Concurrency.class, "factor", Float.class);
    }

    TestConfiguration testConfiguration = klass.getAnnotation(TestConfiguration.class);
    if (testConfiguration != null) {
        Configuration configuration = Resources.loadConfiguration(testConfiguration);
        int configThreads = configuration.getInt("concurrency.threads", -1);
        if (configThreads > 0) {
            threads = configThreads;
        }
        int configMaxThreads = configuration.getInt("concurrency.maxThreads", -1);
        if (configMaxThreads > 0) {
            factor = configMaxThreads;
        }
        float configFactor = configuration.getFloat("concurrency.factor", -1f);
        if (configFactor > 0) {
            factor = configFactor;
        }
    }

    threads = threads > 0 ? threads : Runtime.getRuntime().availableProcessors();
    maxThreads = Math.max(maxThreads, 1);
    factor = Math.max(factor, 0);
    return Math.min(Math.max((int) Math.round(threads * factor), 1), maxThreads);
}
 
Example 11
Source File: TraceCollector.java    From steady with Apache License 2.0 5 votes vote down vote up
private TraceCollector() {
	final Configuration cfg = VulasConfiguration.getGlobal().getConfiguration();

	this.loaderHierarchy = new LoaderHierarchy();

	// Create thread pool for JAR analysis
	this.poolSize = cfg.getInt("jarAnalysis.poolSize", 4);

	// JAR blacklist (evaluated during addTrace)
	this.jarBlacklist.addAll(cfg.getStringArray(CoreConfiguration.MONI_BLACKLIST_JARS));
}
 
Example 12
Source File: TinkerGraph.java    From tinkergraph-gremlin with Apache License 2.0 5 votes vote down vote up
private TinkerGraph(final Configuration configuration, boolean usesSpecializedElements,
                    Map<String, SpecializedElementFactory.ForVertex> specializedVertexFactoryByLabel,
                    Map<String, SpecializedElementFactory.ForEdge> specializedEdgeFactoryByLabel) {
    this.configuration = configuration;
    this.usesSpecializedElements = usesSpecializedElements;
    this.specializedVertexFactoryByLabel = specializedVertexFactoryByLabel;
    this.specializedEdgeFactoryByLabel = specializedEdgeFactoryByLabel;
    vertexIdManager = selectIdManager(configuration, GREMLIN_TINKERGRAPH_VERTEX_ID_MANAGER, Vertex.class);
    edgeIdManager = selectIdManager(configuration, GREMLIN_TINKERGRAPH_EDGE_ID_MANAGER, Edge.class);
    vertexPropertyIdManager = selectIdManager(configuration, GREMLIN_TINKERGRAPH_VERTEX_PROPERTY_ID_MANAGER, VertexProperty.class);
    defaultVertexPropertyCardinality = VertexProperty.Cardinality.valueOf(
      configuration.getString(GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY, VertexProperty.Cardinality.single.name()));

    graphLocation = configuration.getString(GREMLIN_TINKERGRAPH_GRAPH_LOCATION, null);
    ondiskOverflowEnabled = configuration.getBoolean(GREMLIN_TINKERGRAPH_ONDISK_OVERFLOW_ENABLED, true);
    if (ondiskOverflowEnabled) {
        graphFormat = GRAPH_FORMAT_MVSTORE;
        referenceManager = new ReferenceManagerImpl(configuration.getInt(GREMLIN_TINKERGRAPH_OVERFLOW_HEAP_PERCENTAGE_THRESHOLD));
        VertexDeserializer vertexDeserializer = new VertexDeserializer(this, specializedVertexFactoryByLabel);
        EdgeDeserializer edgeDeserializer = new EdgeDeserializer(this, specializedEdgeFactoryByLabel);
        if (graphLocation == null) {
            ondiskOverflow = OndiskOverflow.createWithTempFile(vertexDeserializer, edgeDeserializer);
            initEmptyElementCollections();
        } else {
            ondiskOverflow = OndiskOverflow.createWithSpecificLocation(vertexDeserializer, edgeDeserializer, new File(graphLocation));
            initElementCollections(ondiskOverflow);
        }
    } else {
        graphFormat = configuration.getString(GREMLIN_TINKERGRAPH_GRAPH_FORMAT, null);
        if ((graphLocation != null && null == graphFormat) || (null == graphLocation && graphFormat != null))
            throw new IllegalStateException(String.format("The %s and %s must both be specified if either is present",
                GREMLIN_TINKERGRAPH_GRAPH_LOCATION, GREMLIN_TINKERGRAPH_GRAPH_FORMAT));
        initEmptyElementCollections();
        referenceManager = new NoOpReferenceManager();
        if (graphLocation != null) loadGraph();
    }
}
 
Example 13
Source File: ConfigurableIngestTopologyTest.java    From cognition with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetStormParallelismConfig(@Injectable Configuration conf) throws Exception {
  int parallelismHint = 1;
  new Expectations() {{
    conf.getInt(PARALLELISM_HINT, PARALLELISM_HINT_DEFAULT);
    result = parallelismHint;
    conf.getInt(NUM_TASKS, parallelismHint);
    result = parallelismHint;
  }};

  StormParallelismConfig parallelismConfig = topology.getStormParallelismConfig(conf);

  assertThat(parallelismConfig.getParallelismHint(), is(parallelismHint));
  assertThat(parallelismConfig.getNumTasks(), is(parallelismHint));
}
 
Example 14
Source File: AtlasTopicCreator.java    From atlas with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
protected void createTopic(Configuration atlasProperties, String topicName, ZkUtils zkUtils) {
    int numPartitions = atlasProperties.getInt("atlas.notification.hook.numthreads", 1);
    int numReplicas = atlasProperties.getInt("atlas.notification.replicas", 1);
    AdminUtils.createTopic(zkUtils, topicName,  numPartitions, numReplicas,
            new Properties(), RackAwareMode.Enforced$.MODULE$);
    LOG.warn("Created topic {} with partitions {} and replicas {}", topicName, numPartitions, numReplicas);
}
 
Example 15
Source File: KafkaBridge.java    From atlas with Apache License 2.0 5 votes vote down vote up
public KafkaBridge(Configuration atlasConf, AtlasClientV2 atlasClientV2) throws Exception {
    String   zookeeperConnect    = getZKConnection(atlasConf);
    int      sessionTimeOutMs    = atlasConf.getInt(ZOOKEEPER_SESSION_TIMEOUT_MS, DEFAULT_ZOOKEEPER_SESSION_TIMEOUT_MS) ;
    int      connectionTimeOutMs = atlasConf.getInt(ZOOKEEPER_CONNECTION_TIMEOUT_MS, DEFAULT_ZOOKEEPER_CONNECTION_TIMEOUT_MS);
    ZkClient zkClient            = new ZkClient(zookeeperConnect, sessionTimeOutMs, connectionTimeOutMs, ZKStringSerializer$.MODULE$);

    this.atlasClientV2     = atlasClientV2;
    this.metadataNamespace = getMetadataNamespace(atlasConf);
    this.zkUtils           = new ZkUtils(zkClient, new ZkConnection(zookeeperConnect), JaasUtils.isZkSecurityEnabled());
    this.availableTopics   = scala.collection.JavaConversions.seqAsJavaList(zkUtils.getAllTopics());
}
 
Example 16
Source File: DiscoveryREST.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Inject
public DiscoveryREST(AtlasTypeRegistry typeRegistry, AtlasDiscoveryService discoveryService, Configuration configuration) {
    this.typeRegistry           = typeRegistry;
    this.discoveryService       = discoveryService;
    this.maxFullTextQueryLength = configuration.getInt(Constants.MAX_FULLTEXT_QUERY_STR_LENGTH, 4096);
    this.maxDslQueryLength      = configuration.getInt(Constants.MAX_DSL_QUERY_STR_LENGTH, 4096);
}
 
Example 17
Source File: SuddenSpeedChangeAnalysis.java    From AisAbnormal with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Inject
public SuddenSpeedChangeAnalysis(Configuration configuration, AppStatisticsService statisticsService, EventEmittingTracker trackingService, EventRepository eventRepository) {
    super(eventRepository, trackingService, null);
    this.statisticsService = statisticsService;

    setTrackPredictionTimeMax(configuration.getInteger(CONFKEY_ANALYSIS_SUDDENSPEEDCHANGE_PREDICTIONTIME_MAX, -1));

    SPEED_HIGH_MARK = configuration.getFloat(CONFKEY_ANALYSIS_SUDDENSPEEDCHANGE_SOG_HIGHMARK, 7f);
    SPEED_LOW_MARK = configuration.getFloat(CONFKEY_ANALYSIS_SUDDENSPEEDCHANGE_SOG_LOWMARK, 1f);
    SPEED_DECAY_SECS = configuration.getInt(CONFKEY_ANALYSIS_SUDDENSPEEDCHANGE_DROP_DECAY, 30);
    SPEED_SUSTAIN_SECS = configuration.getInt(CONFKEY_ANALYSIS_SUDDENSPEEDCHANGE_DROP_SUSTAIN, 60);
    SHIP_LENGTH_MIN = configuration.getInt(CONFKEY_ANALYSIS_SUDDENSPEEDCHANGE_SHIPLENGTH_MIN, 50);

    LOG.info(getAnalysisName() + " created (" + this + ").");
}
 
Example 18
Source File: CuratorFrameworkBuilder.java    From chassis with Apache License 2.0 4 votes vote down vote up
private RetryPolicy buildZookeeperRetryPolicy(Configuration configuration) {
    return new ExponentialBackoffRetry(
            configuration.getInt(ZOOKEEPER_INITIAL_SLEEP_MILLIS.getPropertyName()),
            configuration.getInt(ZOOKEEPER_MAX_RETRIES.getPropertyName()),
            configuration.getInt(ZOOKEEPER_RETRIES_MAX_MILLIS.getPropertyName()));
}
 
Example 19
Source File: RanNnep.java    From KEEL with GNU General Public License v3.0 3 votes vote down vote up
/**
    * <p>
    * Configuration settings for Randnnep random generator are:
    * 
    * <ul>
    * <li>
    * <code>a (int, default = 12345)</code>
    * </li><li>
    * <code>b (int, default = 67890</code>
    * </li>
    * </ul>
    * </p>
    * @param settings Configuration object to read the properties of
    */
public void configure(Configuration settings) 
{
	a=100001;
	b=1;
	// Get seed
	int seed = settings.getInt("seed", 7897);
	// Initialize
	for(int i=0; i<seed%999; i++)
		raw();
}
 
Example 20
Source File: BigdataGraphConfiguration.java    From database with GNU General Public License v2.0 2 votes vote down vote up
protected BigdataGraph configure(final GraphConfigurationContext context)
        throws Exception {
    
    final Configuration config = context.getProperties();
    
    if (!config.containsKey(Options.TYPE)) {
        throw new GraphConfigurationException("missing required parameter: " + Options.TYPE);
    }
    
    final String type = config.getString(Options.TYPE).toLowerCase();
    
    if (Options.TYPE_EMBEDDED.equals(type)) {
        
        if (config.containsKey(Options.FILE)) {
        
            final String journal = config.getString(Options.FILE);
        
            return BigdataGraphFactory.open(journal, true);
            
        } else {
            
            return BigdataGraphFactory.create();
            
        }
        
    } else if (Options.TYPE_REMOTE.equals(type)) {

        if (config.containsKey(Options.SPARQL_ENDPOINT_URL)) {
            
            final String sparqlEndpointURL = config.getString(Options.SPARQL_ENDPOINT_URL);

            return BigdataGraphFactory.connect(sparqlEndpointURL);

        }
        
        if (!config.containsKey(Options.HOST)) {
            throw new GraphConfigurationException("missing required parameter: " + Options.HOST);
        }
        
        if (!config.containsKey(Options.PORT)) {
            throw new GraphConfigurationException("missing required parameter: " + Options.PORT);
        }
        
        final String host = config.getString(Options.HOST);

        final int port = config.getInt(Options.PORT);
        
        return BigdataGraphFactory.connect(host, port);
        
    } else {
        
        throw new GraphConfigurationException("unrecognized value for "
                + Options.TYPE + ": " + type);
        
    }
    
}