private void addNewTsPoint(final Map<Long, List<NamedDoubleTimeSeriesPoint>> orderedTsPoints, final NamedDoubleTimeSeriesPoint newTsPoint) { final long newTsPointTimestamp = newTsPoint.getTime(); if (!orderedTsPoints.containsKey(newTsPointTimestamp)) { orderedTsPoints.put(newTsPointTimestamp, new ArrayList<NamedDoubleTimeSeriesPoint>()); } final List<NamedDoubleTimeSeriesPoint> tsPointList = orderedTsPoints.get(newTsPointTimestamp); tsPointList.add(newTsPoint); }
private void addNewTsPoint(final Map<Long, List<NamedDoubleTimeSeriesPoint>> orderedTsPoints, final NamedDoubleTimeSeriesPoint newTsPoint) { final long newTsPointTimestamp = newTsPoint.getTime(); if (!orderedTsPoints.containsKey(newTsPointTimestamp)) { orderedTsPoints.put(newTsPointTimestamp, new ArrayList<NamedDoubleTimeSeriesPoint>()); } final List<NamedDoubleTimeSeriesPoint> tsPointList = orderedTsPoints.get(newTsPointTimestamp); tsPointList.add(newTsPoint); }
/** * 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()); } }
/** * 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 synchronized void processInputGlobalScope(final NamedDoubleTimeSeriesPoint input) { // NOPMD (AvoidSynchronizedAtMethodLevel) final long inputTimestamp = input.getTime(); final AggregationVariableSet inputVariables = this.aggregationVariables.get(input.getName()); final long startOfInputTimestampsInterval = this.computeFirstTimestampInInterval(inputTimestamp, inputVariables);
private synchronized void processInputGlobalScope(final NamedDoubleTimeSeriesPoint input) { // NOPMD (AvoidSynchronizedAtMethodLevel) final long inputTimestamp = input.getTime(); final AggregationVariableSet inputVariables = this.aggregationVariables.get(input.getName()); final long startOfInputTimestampsInterval = this.computeFirstTimestampInInterval(inputTimestamp, inputVariables);
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); }
/** * Test the extraction of the data from ResponseTimeDoubleRecords. * * @throws InterruptedException * If interrupted */ @Test public void testResponsetimeOnly() throws InterruptedException { final AnalysisControllerThread thread = new AnalysisControllerThread(this.controller); thread.start(); Thread.sleep(2000); thread.terminate(); Assert.assertEquals(3, this.sinkPlugin.getList().size()); // Test on the timestamp conversion (here as configured to milliseconds Assert.assertEquals(1369127, this.sinkPlugin.getList().get(0).getTime(), 0); Assert.assertEquals(1369128, this.sinkPlugin.getList().get(1).getTime(), 0); Assert.assertEquals(1369129, this.sinkPlugin.getList().get(2).getTime(), 0); // Test on the extracted values Assert.assertEquals(10341.94, this.sinkPlugin.getList().get(0).getDoubleValue(), 0); Assert.assertEquals(8341.00, this.sinkPlugin.getList().get(1).getDoubleValue(), 0); Assert.assertEquals(78.26, this.sinkPlugin.getList().get(2).getDoubleValue(), 0); } }
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); }