List of usage examples for org.apache.commons.configuration Configuration getFloat
Float getFloat(String key, Float defaultValue);
From source file:com.germinus.easyconf.ComponentProperties.java
protected static Object getTypedPropertyWithDefault(String key, Class theClass, Configuration properties, Object defaultValue) {/*from ww w .j a v a 2s . c o m*/ if (theClass.equals(Float.class)) { return properties.getFloat(key, (Float) defaultValue); } else if (theClass.equals(Integer.class)) { return properties.getInteger(key, (Integer) defaultValue); } else if (theClass.equals(String.class)) { return properties.getString(key, (String) defaultValue); } else if (theClass.equals(Double.class)) { return properties.getDouble(key, (Double) defaultValue); } else if (theClass.equals(Long.class)) { return properties.getLong(key, (Long) defaultValue); } else if (theClass.equals(Boolean.class)) { return properties.getBoolean(key, (Boolean) defaultValue); } else if (theClass.equals(List.class)) { return properties.getList(key, (List) defaultValue); } else if (theClass.equals(BigInteger.class)) { return properties.getBigInteger(key, (BigInteger) defaultValue); } else if (theClass.equals(BigDecimal.class)) { return properties.getBigDecimal(key, (BigDecimal) defaultValue); } else if (theClass.equals(Byte.class)) { return properties.getByte(key, (Byte) defaultValue); } else if (theClass.equals(Short.class)) { return properties.getShort(key, (Short) defaultValue); } throw new IllegalArgumentException("Class " + theClass + " is not" + "supported for properties"); }
From source file:dk.dma.ais.abnormal.analyzer.analysis.CloseEncounterAnalysis.java
@Inject public CloseEncounterAnalysis(Configuration configuration, AppStatisticsService statisticsService, EventEmittingTracker trackingService, EventRepository eventRepository) { super(eventRepository, trackingService, null); this.statisticsService = statisticsService; this.sogMin = configuration.getFloat(CONFKEY_ANALYSIS_CLOSEENCOUNTER_SOG_MIN, 5.0f); setTrackPredictionTimeMax(configuration.getInteger(CONFKEY_ANALYSIS_CLOSEENCOUNTER_PREDICTIONTIME_MAX, -1)); setAnalysisPeriodMillis(configuration.getInt(CONFKEY_ANALYSIS_CLOSEENCOUNTER_RUN_PERIOD, 30000) * 1000); LOG.info(this.getClass().getSimpleName() + " created (" + this + ")."); }
From source file:dk.dma.ais.abnormal.analyzer.AbnormalAnalyzerAppModule.java
@Provides LocationFilter provideLocationFilter() { Configuration configuration = getConfiguration(); Float north = configuration.getFloat(CONFKEY_FILTER_LOCATION_BBOX_NORTH, null); Float south = configuration.getFloat(CONFKEY_FILTER_LOCATION_BBOX_SOUTH, null); Float east = configuration.getFloat(CONFKEY_FILTER_LOCATION_BBOX_EAST, null); Float west = configuration.getFloat(CONFKEY_FILTER_LOCATION_BBOX_WEST, null); BoundingBox tmpBbox = null;/*ww w . j a v a2 s .co m*/ if (north != null && south != null && east != null && west != null) { tmpBbox = BoundingBox.create(Position.create(north, west), Position.create(south, east), CoordinateSystem.CARTESIAN); LOG.info("Area: " + tmpBbox); } else { LOG.warn("No location-based pre-filtering of messages."); } LocationFilter filter = new LocationFilter(); if (tmpBbox == null) { filter.addFilterGeometry(e -> true); } else { final BoundingBox bbox = tmpBbox; filter.addFilterGeometry(position -> { if (position == null) { return false; } return bbox.contains(position); }); } return filter; }
From source file:dk.dma.ais.abnormal.analyzer.analysis.DriftAnalysis.java
@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 + ")."); }
From source file:dk.dma.ais.abnormal.analyzer.analysis.SuddenSpeedChangeAnalysis.java
@Inject public SuddenSpeedChangeAnalysis(Configuration configuration, AppStatisticsService statisticsService, EventEmittingTracker trackingService, EventRepository eventRepository) { super(eventRepository, trackingService, null); this.statisticsService = statisticsService; setTrackPredictionTimeMax(//from w ww.j av a 2 s.c o m 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 + ")."); }
From source file:dk.dma.ais.abnormal.analyzer.analysis.ShipTypeAndSizeAnalysis.java
@Inject public ShipTypeAndSizeAnalysis(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_TYPESIZE_PREDICTIONTIME_MAX, -1)); TOTAL_SHIP_COUNT_THRESHOLD = configuration.getInt(CONFKEY_ANALYSIS_TYPESIZE_CELL_SHIPCOUNT_MIN, 1000); PD = configuration.getFloat(CONFKEY_ANALYSIS_TYPESIZE_PD, 0.001f); SHIP_LENGTH_MIN = configuration.getInt(CONFKEY_ANALYSIS_TYPESIZE_SHIPLENGTH_MIN, 50); LOG.info(getAnalysisName() + " created (" + this + ")."); }
From source file:dk.dma.ais.abnormal.analyzer.analysis.SpeedOverGroundAnalysis.java
@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 + ")."); }
From source file:dk.dma.ais.abnormal.analyzer.analysis.CourseOverGroundAnalysis.java
@Inject public CourseOverGroundAnalysis(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_COG_PREDICTIONTIME_MAX, -1)); TOTAL_SHIP_COUNT_THRESHOLD = configuration.getInt(CONFKEY_ANALYSIS_COG_CELL_SHIPCOUNT_MIN, 1000); PD = configuration.getFloat(CONFKEY_ANALYSIS_COG_PD, 0.001f); SHIP_LENGTH_MIN = configuration.getInt(CONFKEY_ANALYSIS_COG_SHIPLENGTH_MIN, 50); USE_AGGREGATED_STATS = configuration.getBoolean(CONFKEY_ANALYSIS_COG_USE_AGGREGATED_STATS, false); LOG.info(getAnalysisName() + " created (" + this + ")."); }
From source file:dk.dma.ais.abnormal.analyzer.analysis.FreeFlowAnalysis.java
@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 {//from w w w. ja v a2s.c om 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 + ")."); }
From source file:com.wizecommerce.hecuba.astyanax.AstyanaxBasedHecubaClientManager.java
public void initialize(String clusterName, String locationUrls, String port, String keyspaceName) { astyanaxConfigurationImpl = new AstyanaxConfigurationImpl(); final Configuration configuration = ConfigUtils.getInstance().getConfiguration(); astyanaxConfigurationImpl.setDiscoveryType(NodeDiscoveryType .valueOf(configuration.getString(HecubaConstants.ASTYANAX_NODE_DISCOVERY_TYPE, "RING_DESCRIBE"))); astyanaxConfigurationImpl.setConnectionPoolType(ConnectionPoolType .valueOf(configuration.getString(HecubaConstants.ASTYANAX_CONNECTION_POOL_TYPE, "TOKEN_AWARE"))); connectionPoolConfigurationImpl = new ConnectionPoolConfigurationImpl("MyConnectionPool") .setPort(Integer.parseInt(port)).setSeeds(getListOfNodesAndPorts(locationUrls, port)) .setMaxConnsPerHost(configuration.getInteger(HecubaConstants.ASTYANAX_MAX_CONNS_PER_HOST, 3)); // Will resort hosts per token partition every 10 seconds SmaLatencyScoreStrategyImpl smaLatencyScoreStrategyImpl = new SmaLatencyScoreStrategyImpl( configuration.getInteger(HecubaConstants.ASTYANAX_LATENCY_AWARE_UPDATE_INTERVAL, 10000), configuration.getInteger(HecubaConstants.ASTYANAX_LATENCY_AWARE_RESET_INTERVAL, 10000), configuration.getInteger(HecubaConstants.ASTYANAX_LATENCY_AWARE_WINDOW_SIZE, 100), configuration.getFloat(HecubaConstants.ASTYANAX_LATENCY_AWARE_BADNESS_INTERVAL, 0.5f)); // Enabled SMA. Omit this to use round robin with a token range. connectionPoolConfigurationImpl.setLatencyScoreStrategy(smaLatencyScoreStrategyImpl); if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) { SimpleAuthenticationCredentials simpleAuth = new SimpleAuthenticationCredentials(username, password); connectionPoolConfigurationImpl.setAuthenticationCredentials(simpleAuth); }// w w w . j av a2 s . c o m connectionPoolMonitor = new CountingConnectionPoolMonitor(); context = new AstyanaxContext.Builder().forCluster(clusterName).forKeyspace(keyspaceName) .withAstyanaxConfiguration(astyanaxConfigurationImpl) .withConnectionPoolConfiguration(connectionPoolConfigurationImpl) .withConnectionPoolMonitor(connectionPoolMonitor).buildKeyspace(ThriftFamilyFactory.getInstance()); context.start(); keyspace = context.getEntity(); if (clusterContext == null) { initiateClusterContext(clusterName); } }