@Override public void setCurrentConfiguration(final Configuration config, final boolean update) { this.setFieldsByConfiguration(config, update); }
@InputPort(name = AnomalyScoreVisualizationFilter.INPUT_PORT_NAME_EVENTS, eventTypes = { StorableDetectionResult.class }) public void inputNormal(final StorableDetectionResult record) { this.updateDisplays(record); }
@Override public void setCurrentConfiguration(final Configuration config, final boolean update) { if (!update || this.isPropertyUpdateable(CONFIG_PROPERTY_NAME_THRESHOLD)) { this.threshold = new AtomicReference<>(Double.parseDouble(config.getStringProperty(CONFIG_PROPERTY_NAME_THRESHOLD))); } } }
private synchronized void processInputVariableScope(final NamedDoubleTimeSeriesPoint input) { // NOPMD (AvoidSynchronizedAtMethodLevel) final long currentTime = input.getTime(); final String appname = input.getName(); final AggregationVariableSet variables = this.aggregationVariables.get(appname); final long startOfTimestampsInterval = this.computeFirstTimestampInInterval(currentTime, variables); final long endOfTimestampsInterval = this.computeLastTimestampInInterval(currentTime, variables); if (this.recentWindow.getWindowEnd() != endOfTimestampsInterval) { this.recentWindow = new AggregationWindow(startOfTimestampsInterval, endOfTimestampsInterval); super.deliver(OUTPUT_PORT_NAME_AGGREGATION_WINDOW, this.recentWindow); } // check if interval is omitted if (endOfTimestampsInterval > variables.getLastTimestampInCurrentInterval()) { if (variables.getFirstTimestampInCurrentInterval() >= 0) { // don't do this for the first record (only used for initialization of variables) this.calculateAndDeliverAggregationValue(variables); long numIntervalsElapsed = 1; // refined below numIntervalsElapsed = (endOfTimestampsInterval - variables.getLastTimestampInCurrentInterval()) / this.aggregationSpan; if (numIntervalsElapsed > 1) { for (int i = 1; i < numIntervalsElapsed; i++) { super.deliver(OUTPUT_PORT_NAME_AGGREGATED_TSPOINT, new NamedDoubleTimeSeriesPoint(variables.getLastTimestampInCurrentInterval() + (i * this.aggregationSpan), Double.NaN, // Note: Count filter should use 0.0 appname)); } } } variables.setFirstTimestampInCurrentInterval(startOfTimestampsInterval); variables.setLastTimestampInCurrentInterval(endOfTimestampsInterval); variables.getAggregationList().clear(); } variables.getAggregationList().add(input); }
final ExtractionFilter extractionFilter = new ExtractionFilter(extractionConfiguration, this.controller); aggregationConfiguration.setProperty(TimeSeriesPointAggregatorFilter.CONFIG_PROPERTY_NAME_AGGREGATION_SPAN, "2"); aggregationConfiguration.setProperty(TimeSeriesPointAggregatorFilter.CONFIG_PROPERTY_NAME_AGGREGATION_TIMEUNIT, "NANOSECONDS"); final TimeSeriesPointAggregatorFilter aggregationFilter = new TimeSeriesPointAggregatorFilter(aggregationConfiguration, this.controller); forecastConfiguration.setProperty(ForecastingFilter.CONFIG_PROPERTY_NAME_DELTA_UNIT, "MILLISECONDS"); forecastConfiguration.setProperty(ForecastingFilter.CONFIG_PROPERTY_NAME_FC_METHOD, "MEANJAVA"); final ForecastingFilter forecasting = new ForecastingFilter(forecastConfiguration, this.controller); final AnomalyScoreCalculationFilter scoreCalc = new AnomalyScoreCalculationFilter(scoreConfiguration, this.controller); final AnomalyDetectionFilter anomalyDetectionFilter = new AnomalyDetectionFilter(configAnomalyPre, this.controller);
/** * This method represents the input port for the incoming measurements. * * @param input * The next incoming measurement */ @InputPort(eventTypes = { NamedDoubleTimeSeriesPoint.class }, name = TimeSeriesPointAggregatorFilter.INPUT_PORT_NAME_TSPOINT) public void inputTSPoint(final NamedDoubleTimeSeriesPoint input) { final String name = input.getName(); this.aggregationVariables.putIfAbsent(name, new AggregationVariableSet()); if (this.aggregationTimescopeGlobal) { this.processInputGlobalScope(input); } else { this.processInputVariableScope(input); } }
/** * Represents the input port for measurements. * * @param input * Incoming measurements */ @InputPort(eventTypes = { NamedDoubleTimeSeriesPoint.class }, name = ForecastingFilter.INPUT_PORT_NAME_TSPOINT) public void inputEvent(final NamedDoubleTimeSeriesPoint input) { if (this.checkInitialization(input.getName())) { this.processInput(input, input.getTime(), input.getName()); } else { // Initialization of the forecasting variables for a new application this.applicationForecastingWindow.put(input.getName(), new TimeSeries<Double>(input.getTime(), super.recordsTimeUnitFromProjectContext, this.deltat.get(), this.timeSeriesWindowCapacity.get())); this.processInput(input, input.getTime(), input.getName()); } }
private void setFieldsByConfiguration(final Configuration config, final boolean update) { if (!update || this.isPropertyUpdateable(CONFIG_PROPERTY_NAME_DELTA_TIME)) { this.deltat = new AtomicLong(config.getLongProperty(CONFIG_PROPERTY_NAME_DELTA_TIME)); } if (!update || this.isPropertyUpdateable(CONFIG_PROPERTY_NAME_DELTA_UNIT)) { this.tunit = TimeUnit.valueOf(config.getStringProperty(CONFIG_PROPERTY_NAME_DELTA_UNIT)); } if (!update || this.isPropertyUpdateable(CONFIG_PROPERTY_NAME_FC_METHOD)) { this.forecastMethod.set(ForecastMethod.valueOf(config.getStringProperty(CONFIG_PROPERTY_NAME_FC_METHOD))); } if (!update || this.isPropertyUpdateable(CONFIG_PROPERTY_NAME_TS_WINDOW_CAPACITY)) { this.timeSeriesWindowCapacity = new AtomicInteger(config.getIntProperty(CONFIG_PROPERTY_NAME_TS_WINDOW_CAPACITY)); } if (!update || this.isPropertyUpdateable(CONFIG_PROPERTY_NAME_FC_CONFIDENCE)) { this.forecastConfidence = new AtomicInteger(config.getIntProperty(CONFIG_PROPERTY_NAME_FC_CONFIDENCE)); } }
/** * Set up for the AnomalyScoreCalculationFilterTest. * * @throws IllegalStateException * If illegal state * @throws AnalysisConfigurationException * If wrong configuration */ @Before public void setUp() throws IllegalStateException, AnalysisConfigurationException { this.controller = new AnalysisController(); // READER final Configuration readerScoreCalcConfiguration = new Configuration(); readerScoreCalcConfiguration.setProperty(ListReader.CONFIG_PROPERTY_NAME_AWAIT_TERMINATION, Boolean.TRUE.toString()); final ListReader<ForecastMeasurementPair> theReaderScoreCalc = new ListReader<>(readerScoreCalcConfiguration, this.controller); theReaderScoreCalc.addAllObjects(this.createInputEventSetScoreCalc()); final Configuration scoreConfiguration = new Configuration(); final AnomalyScoreCalculationFilter scoreCalc = new AnomalyScoreCalculationFilter(scoreConfiguration, this.controller); // SINK 1 this.sinkAnomalyScore = new ListCollectionFilter<>(new Configuration(), this.controller); // CONNECTION this.controller .connect(theReaderScoreCalc, ListReader.OUTPUT_PORT_NAME, scoreCalc, AnomalyScoreCalculationFilter.INPUT_PORT_CURRENT_FORECAST_PAIR); this.controller .connect(scoreCalc, AnomalyScoreCalculationFilter.OUTPUT_PORT_ANOMALY_SCORE, this.sinkAnomalyScore, ListCollectionFilter.INPUT_PORT_NAME); }
aggregationConfiguration.setProperty(TimeSeriesPointAggregatorFilter.CONFIG_PROPERTY_NAME_AGGREGATION_TIMEUNIT, "MILLISECONDS"); aggregationConfiguration.setProperty(TimeSeriesPointAggregatorFilter.CONFIG_PROPERTY_NAME_AGGREGATION_METHOD, "MEANJAVA"); final TimeSeriesPointAggregatorFilter aggregator = new TimeSeriesPointAggregatorFilter(aggregationConfiguration, controller);
/** * Sets up a simple test filter structure (SimpleListReader -> RecordConverter -> ListCollectionFilter) * and creates an OperationExecutionRecord that will be converterd for testing reasons. * * @throws Exception * throws exceptions that are thrown while setting up the filter structure */ @Before public void setUp() throws Exception { final OperationExecutionRecord oer; final RecordConverter recordConverter; this.analysisController = new AnalysisController(); recordConverter = new RecordConverter(new Configuration(), this.analysisController); this.simpleListReader = new ListReader<OperationExecutionRecord>(new Configuration(), this.analysisController); this.listCollectionfilter = new ListCollectionFilter<NamedDoubleRecord>(new Configuration(), this.analysisController); this.analysisController.connect(this.simpleListReader, ListReader.OUTPUT_PORT_NAME, recordConverter, RecordConverter.INPUT_PORT_NAME_OER); this.analysisController.connect(recordConverter, RecordConverter.OUTPUT_PORT_NAME_NDR, this.listCollectionfilter, ListCollectionFilter.INPUT_PORT_NAME); oer = new OperationExecutionRecord(RecordConverterTest.operationSignature, OperationExecutionRecord.NO_SESSION_ID, OperationExecutionRecord.NO_TRACE_ID, RecordConverterTest.timeIn, RecordConverterTest.timeOut, RecordConverterTest.hostAppInput, OperationExecutionRecord.NO_EOI_ESS, OperationExecutionRecord.NO_EOI_ESS); oer.setLoggingTimestamp(RecordConverterTest.loggingTimestamp); this.convertRecord(oer); }
private synchronized void processInputVariableScope(final NamedDoubleTimeSeriesPoint input) { // NOPMD (AvoidSynchronizedAtMethodLevel) final long currentTime = input.getTime(); final String appname = input.getName(); final AggregationVariableSet variables = this.aggregationVariables.get(appname); final long startOfTimestampsInterval = this.computeFirstTimestampInInterval(currentTime, variables); final long endOfTimestampsInterval = this.computeLastTimestampInInterval(currentTime, variables); if (this.recentWindow.getWindowEnd() != endOfTimestampsInterval) { this.recentWindow = new AggregationWindow(startOfTimestampsInterval, endOfTimestampsInterval); super.deliver(OUTPUT_PORT_NAME_AGGREGATION_WINDOW, this.recentWindow); } // check if interval is omitted if (endOfTimestampsInterval > variables.getLastTimestampInCurrentInterval()) { if (variables.getFirstTimestampInCurrentInterval() >= 0) { // don't do this for the first record (only used for initialization of variables) this.calculateAndDeliverAggregationValue(variables); long numIntervalsElapsed = 1; // refined below numIntervalsElapsed = (endOfTimestampsInterval - variables.getLastTimestampInCurrentInterval()) / this.aggregationSpan; if (numIntervalsElapsed > 1) { for (int i = 1; i < numIntervalsElapsed; i++) { super.deliver(OUTPUT_PORT_NAME_AGGREGATED_TSPOINT, new NamedDoubleTimeSeriesPoint(variables.getLastTimestampInCurrentInterval() + (i * this.aggregationSpan), Double.NaN, // Note: Count filter should use 0.0 appname)); } } } variables.setFirstTimestampInCurrentInterval(startOfTimestampsInterval); variables.setLastTimestampInCurrentInterval(endOfTimestampsInterval); variables.getAggregationList().clear(); } variables.getAggregationList().add(input); }
/** * This method represents the input port for the incoming measurements. * * @param input * The next incoming measurement */ @InputPort(eventTypes = { NamedDoubleTimeSeriesPoint.class }, name = TimeSeriesPointAggregatorFilter.INPUT_PORT_NAME_TSPOINT) public void inputTSPoint(final NamedDoubleTimeSeriesPoint input) { final String name = input.getName(); this.aggregationVariables.putIfAbsent(name, new AggregationVariableSet()); if (this.aggregationTimescopeGlobal) { this.processInputGlobalScope(input); } else { this.processInputVariableScope(input); } }
/** * Represents the input port for measurements. * * @param input * Incoming measurements */ @InputPort(eventTypes = { NamedDoubleTimeSeriesPoint.class }, name = ForecastingFilter.INPUT_PORT_NAME_TSPOINT) public void inputEvent(final NamedDoubleTimeSeriesPoint input) { if (this.checkInitialization(input.getName())) { this.processInput(input, input.getTime(), input.getName()); } else { // Initialization of the forecasting variables for a new application this.applicationForecastingWindow.put(input.getName(), new TimeSeries<Double>(input.getTime(), super.recordsTimeUnitFromProjectContext, this.deltat.get(), this.timeSeriesWindowCapacity.get())); this.processInput(input, input.getTime(), input.getName()); } }
@Override public void setCurrentConfiguration(final Configuration config, final boolean update) { this.setFieldsByConfiguration(config, update); }
@InputPort(name = AnomalyScoreVisualizationFilter.INPUT_PORT_NAME_EVENTS, eventTypes = { StorableDetectionResult.class }) public void inputNormal(final StorableDetectionResult record) { this.updateDisplays(record); }
@Override public void setCurrentConfiguration(final Configuration config, final boolean update) { if (!update || this.isPropertyUpdateable(CONFIG_PROPERTY_NAME_THRESHOLD)) { this.threshold = new AtomicReference<Double>(Double.parseDouble(config.getStringProperty(CONFIG_PROPERTY_NAME_THRESHOLD))); } } }
private void setFieldsByConfiguration(final Configuration config, final boolean update) { if (!update || this.isPropertyUpdateable(CONFIG_PROPERTY_NAME_DELTA_TIME)) { this.deltat = new AtomicLong(config.getLongProperty(CONFIG_PROPERTY_NAME_DELTA_TIME)); } if (!update || this.isPropertyUpdateable(CONFIG_PROPERTY_NAME_DELTA_UNIT)) { this.tunit = TimeUnit.valueOf(config.getStringProperty(CONFIG_PROPERTY_NAME_DELTA_UNIT)); } if (!update || this.isPropertyUpdateable(CONFIG_PROPERTY_NAME_FC_METHOD)) { this.forecastMethod.set(ForecastMethod.valueOf(config.getStringProperty(CONFIG_PROPERTY_NAME_FC_METHOD))); } if (!update || this.isPropertyUpdateable(CONFIG_PROPERTY_NAME_TS_WINDOW_CAPACITY)) { this.timeSeriesWindowCapacity = new AtomicInteger(config.getIntProperty(CONFIG_PROPERTY_NAME_TS_WINDOW_CAPACITY)); } if (!update || this.isPropertyUpdateable(CONFIG_PROPERTY_NAME_FC_CONFIDENCE)) { this.forecastConfidence = new AtomicInteger(config.getIntProperty(CONFIG_PROPERTY_NAME_FC_CONFIDENCE)); } }
/** * Creates a new instance of this class. * * @param configuration * Configuration of this component * @param projectContext * ProjectContext of this component */ public ForecastingFilter(final Configuration configuration, final IProjectContext projectContext) { super(configuration, projectContext); this.applicationForecastingWindow = new ConcurrentHashMap<>(); this.previousFCPair = new ConcurrentHashMap<>(); this.setFieldsByConfiguration(configuration, false); }
/** * Creates a new instance of this class. * * @param configuration * Configuration of this component * @param projectContext * ProjectContext of this component */ public ForecastingFilter(final Configuration configuration, final IProjectContext projectContext) { super(configuration, projectContext); this.applicationForecastingWindow = new ConcurrentHashMap<String, ITimeSeries<Double>>(); this.previousFCPair = new ConcurrentHashMap<String, ForecastMeasurementPair>(); this.setFieldsByConfiguration(configuration, false); }