public double getDoubleValue() { return this.getValue(); }
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 NamedDoubleTimeSeriesPoint createNDTSP(final String signature, final double value) { return new NamedDoubleTimeSeriesPoint(System.currentTimeMillis(), value, signature); }
private void calculateAndDeliverAggregationValue(final AggregationVariableSet variables) { final double aggregationValue; final NamedDoubleTimeSeriesPoint tsPoint; synchronized (this) { final int listSize = variables.getAggregationList().size(); final double[] a = new double[listSize]; for (int i = 0; i < listSize; i++) { a[i] = variables.getAggregationList().get(i).getValue(); } aggregationValue = this.aggregationMethod.getAggregationValue(a); tsPoint = new NamedDoubleTimeSeriesPoint(variables.getLastTimestampInCurrentInterval(), aggregationValue, variables.getAggregationList().get(0).getName()); // use name of first element (any will do) variables.getAggregationList().clear(); } super.deliver(OUTPUT_PORT_NAME_AGGREGATED_TSPOINT, tsPoint); }
Double score = 0.0; if (null != fmp.getForecasted()) { final double nextpredicted = fmp.getForecasted(); final double measuredValue = fmp.getValue(); final StorableDetectionResult dr = new StorableDetectionResult(fmp.getName(), fmp.getValue(), fmp.getTime(), fmp.getForecasted(), score); super.deliver(OUTPUT_PORT_ANOMALY_SCORE, dr);
/** * 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 NamedDoubleTimeSeriesPoint calculateAggregationValueOfCurrentInterval(final AggregationVariableSet variables, final String name) { final double aggregationValue; final NamedDoubleTimeSeriesPoint tsPoint; final long firstTimestampInCurrentInterval = variables.getFirstTimestampInCurrentInterval(); final long lastTimestampInCurrentInterval = variables.getLastTimestampInCurrentInterval(); synchronized (this) { final int listSize = variables.getAggregationList().size(); if (listSize <= 0) { tsPoint = new NamedDoubleTimeSeriesPoint(lastTimestampInCurrentInterval, Double.NaN, name); } else { final double[] a = new double[listSize]; for (int i = 0; i < listSize; i++) { a[i] = variables.getAggregationList().get(i).getValue(); } aggregationValue = this.aggregationMethod.getAggregationValue(a); tsPoint = new NamedDoubleTimeSeriesPoint(lastTimestampInCurrentInterval, aggregationValue, name); variables.getAggregationList().clear(); } variables.setFirstTimestampInCurrentInterval(firstTimestampInCurrentInterval + this.aggregationSpan); variables.setLastTimestampInCurrentInterval(lastTimestampInCurrentInterval + this.aggregationSpan); } return tsPoint; }
private void assertAppNames(final List<NamedDoubleTimeSeriesPoint> sinkList, final int firstIndex, final int secondIndex) throws AssertionError { // the order of the app names varies from execution to execution since the aggregation filter uses an unsorted map final String firstAppName = sinkList.get(firstIndex).getName(); final String secondAppName = sinkList.get(secondIndex).getName(); if (OP_SIGNATURE_D.equals(firstAppName)) { Assert.assertEquals(OP_SIGNATURE_C, secondAppName); } else if (OP_SIGNATURE_C.equals(firstAppName)) { Assert.assertEquals(OP_SIGNATURE_D, secondAppName); } else { throw new AssertionError("Unexpected app name: " + firstAppName); } } }
/** * 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 ForecastMeasurementPair createFMP(final String name, final Double forecast, final Double measurement) { return new ForecastMeasurementPair(name, forecast, measurement, System.currentTimeMillis()); }
private void calculateAndDeliverAggregationValue(final AggregationVariableSet variables) { final double aggregationValue; final NamedDoubleTimeSeriesPoint tsPoint; synchronized (this) { final int listSize = variables.getAggregationList().size(); final double[] a = new double[listSize]; for (int i = 0; i < listSize; i++) { a[i] = variables.getAggregationList().get(i).getValue(); } aggregationValue = this.aggregationMethod.getAggregationValue(a); tsPoint = new NamedDoubleTimeSeriesPoint(variables.getLastTimestampInCurrentInterval(), aggregationValue, variables.getAggregationList().get(0).getName()); // use name of first element (any will do) variables.getAggregationList().clear(); } super.deliver(OUTPUT_PORT_NAME_AGGREGATED_TSPOINT, tsPoint); }
Double score = 0.0; if (null != fmp.getForecasted()) { final double nextpredicted = fmp.getForecasted(); final double measuredValue = fmp.getValue(); final StorableDetectionResult dr = new StorableDetectionResult(fmp.getName(), fmp.getValue(), fmp.getTime(), fmp.getForecasted(), score); super.deliver(OUTPUT_PORT_ANOMALY_SCORE, dr);
/** * 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 NamedDoubleTimeSeriesPoint calculateAggregationValueOfCurrentInterval(final AggregationVariableSet variables, final String name) { final double aggregationValue; final NamedDoubleTimeSeriesPoint tsPoint; final long firstTimestampInCurrentInterval = variables.getFirstTimestampInCurrentInterval(); final long lastTimestampInCurrentInterval = variables.getLastTimestampInCurrentInterval(); synchronized (this) { final int listSize = variables.getAggregationList().size(); if (listSize <= 0) { tsPoint = new NamedDoubleTimeSeriesPoint(lastTimestampInCurrentInterval, Double.NaN, name); } else { final double[] a = new double[listSize]; for (int i = 0; i < listSize; i++) { a[i] = variables.getAggregationList().get(i).getValue(); } aggregationValue = this.aggregationMethod.getAggregationValue(a); tsPoint = new NamedDoubleTimeSeriesPoint(lastTimestampInCurrentInterval, aggregationValue, name); variables.getAggregationList().clear(); } variables.setFirstTimestampInCurrentInterval(firstTimestampInCurrentInterval + this.aggregationSpan); variables.setLastTimestampInCurrentInterval(lastTimestampInCurrentInterval + this.aggregationSpan); } return tsPoint; }
@InputPort(name = INPUT_PORT_NAME_VALUE, eventTypes = { NamedDoubleRecord.class }) public void inputExecutionRecord(final NamedDoubleRecord record) { final long timestampMillis = this.timeunit.convert(record.getTimestamp(), super.recordsTimeUnitFromProjectContext); final NamedDoubleTimeSeriesPoint tspoint = new NamedDoubleTimeSeriesPoint(timestampMillis, record.getResponseTime(), record.getApplicationName()); super.deliver(OUTPUT_PORT_NAME_VALUE, tspoint); }
/** * 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); } }
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); }
public double getDoubleValue() { return this.getValue(); }
@InputPort(name = INPUT_PORT_NAME_VALUE, eventTypes = { NamedDoubleRecord.class }) public void inputExecutionRecord(final NamedDoubleRecord record) { final long timestampMillis = this.timeunit.convert(record.getTimestamp(), super.recordsTimeUnitFromProjectContext); final NamedDoubleTimeSeriesPoint tspoint = new NamedDoubleTimeSeriesPoint(timestampMillis, record.getResponseTime(), record.getApplicationName()); super.deliver(OUTPUT_PORT_NAME_VALUE, tspoint); }
/** * 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); } }