@Override public StorableDetectionResult create(final IValueDeserializer deserializer) { return new StorableDetectionResult(deserializer); }
/** * {@inheritDoc} */ @Override public int hashCode() { int code = 0; code += this.getApplicationName().hashCode(); code += ((int)this.getValue()); code += ((int)this.getTimestamp()); code += ((int)this.getForecast()); code += ((int)this.getScore()); return code; }
/** * {@inheritDoc} */ @Override public boolean equals(final Object obj) { if (obj == null) return false; if (obj == this) return true; if (obj.getClass() != this.getClass()) return false; final StorableDetectionResult castedRecord = (StorableDetectionResult) obj; if (this.getLoggingTimestamp() != castedRecord.getLoggingTimestamp()) return false; if (!this.getApplicationName().equals(castedRecord.getApplicationName())) return false; if (isNotEqual(this.getValue(), castedRecord.getValue())) return false; if (this.getTimestamp() != castedRecord.getTimestamp()) return false; if (isNotEqual(this.getForecast(), castedRecord.getForecast())) return false; if (isNotEqual(this.getScore(), castedRecord.getScore())) return false; return true; }
/** * {@inheritDoc} */ @Override public void registerStrings(final IRegistry<String> stringRegistry) { // NOPMD (generated code) stringRegistry.get(this.getApplicationName()); } /**
/** * Test of the AnomalyScoreCalculationFilter. * * @throws InterruptedException * If interrupted * @throws IllegalStateException * If illegal state * @throws AnalysisConfigurationException * If wrong configuration */ @Test public void testAnomalyScoreCalculationOnly() throws InterruptedException, IllegalStateException, AnalysisConfigurationException { final AnalysisControllerThread thread = new AnalysisControllerThread(this.controller); thread.start(); Thread.sleep(1000); thread.terminate(); Assert.assertEquals(3, this.sinkAnomalyScore.getList().size()); Assert.assertEquals(this.sinkAnomalyScore.getList().get(0).getScore(), 0.19999999999999996, 0); Assert.assertEquals(this.sinkAnomalyScore.getList().get(1).getScore(), 0.1428571428571429, 0); Assert.assertEquals(this.sinkAnomalyScore.getList().get(2).getScore(), 0.0, 0); }
/** * {@inheritDoc} * * @deprecated since 1.13. Use {@link #serialize(IValueSerializer)} with an array serializer instead. */ @Override @Deprecated public Object[] toArray() { return new Object[] { this.getApplicationName(), this.getValue(), this.getTimestamp(), this.getForecast(), this.getScore() }; } /**
if (this.getLoggingTimestamp() != castedRecord.getLoggingTimestamp()) { return false; if (!this.getApplicationName().equals(castedRecord.getApplicationName())) { return false; if (isNotEqual(this.getValue(), castedRecord.getValue())) { return false; if (this.getTimestamp() != castedRecord.getTimestamp()) { return false; if (isNotEqual(this.getForecast(), castedRecord.getForecast())) { return false; if (isNotEqual(this.getScore(), castedRecord.getScore())) { return false;
@Override public StorableDetectionResult create(final IValueDeserializer deserializer) throws RecordInstantiationException { return new StorableDetectionResult(deserializer); }
private void updateDisplays(final StorableDetectionResult record) { final Date date = new Date(TimeUnit.MILLISECONDS.convert(record.getTimestamp(), super.recordsTimeUnitFromProjectContext)); final String minutesAndSeconds = date.toString().substring(14, 19); this.xyplot.setEntry(record.getApplicationName() + " - Actual Value", minutesAndSeconds, record.getValue()); this.xyplot.setEntry(record.getApplicationName() + " - Forecast", minutesAndSeconds, record.getForecast()); }
@Override @Deprecated public StorableDetectionResult create(final Object[] values) { return new StorableDetectionResult(values); }
private void updateDisplays(final StorableDetectionResult record) { final Date date = new Date(TimeUnit.MILLISECONDS.convert(record.getTimestamp(), super.recordsTimeUnitFromProjectContext)); final String minutesAndSeconds = date.toString().substring(14, 19); this.xyplot.setEntry(record.getApplicationName() + " - Actual Value", minutesAndSeconds, record.getValue()); this.xyplot.setEntry(record.getApplicationName() + " - Forecast", minutesAndSeconds, record.getForecast()); }
private StorableDetectionResult createNDTSP(final String signature, final double value) { return new StorableDetectionResult(signature, value, System.currentTimeMillis(), value, value); }
@InputPort(eventTypes = { StorableDetectionResult.class }, name = AnomalyDetectionFilter.INPUT_PORT_ANOMALY_SCORE) public void inputForecastAndMeasurement( final StorableDetectionResult anomalyScore) { if (anomalyScore.getScore() >= this.threshold.get()) { super.deliver(OUTPUT_PORT_ANOMALY_SCORE_IF_ANOMALY, anomalyScore); } else { super.deliver(OUTPUT_PORT_ANOMALY_SCORE_ELSE, anomalyScore); } final ExtendedStorableDetectionResult extAnomalyScore = new ExtendedStorableDetectionResult(anomalyScore.getApplicationName(), anomalyScore.getValue(), anomalyScore.getTimestamp(), anomalyScore.getForecast(), anomalyScore.getScore(), this.threshold.get().doubleValue()); super.deliver(OUTPUT_PORT_ALL, extAnomalyScore); }
@Test public void testEquality() { int i = 0; final StorableDetectionResult oneRecord = new StorableDetectionResult(STRING_VALUES.get(i % STRING_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), LONG_VALUES.get(i % LONG_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size())); i = 0; final StorableDetectionResult copiedRecord = new StorableDetectionResult(STRING_VALUES.get(i % STRING_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), LONG_VALUES.get(i % LONG_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size())); Assert.assertEquals(oneRecord, copiedRecord); }
@InputPort(eventTypes = { StorableDetectionResult.class }, name = AnomalyDetectionFilter.INPUT_PORT_ANOMALY_SCORE) public void inputForecastAndMeasurement( final StorableDetectionResult anomalyScore) { if (anomalyScore.getScore() >= this.threshold.get()) { super.deliver(OUTPUT_PORT_ANOMALY_SCORE_IF_ANOMALY, anomalyScore); } else { super.deliver(OUTPUT_PORT_ANOMALY_SCORE_ELSE, anomalyScore); } final ExtendedStorableDetectionResult extAnomalyScore = new ExtendedStorableDetectionResult(anomalyScore.getApplicationName(), anomalyScore.getValue(), anomalyScore.getTimestamp(), anomalyScore.getForecast(), anomalyScore.getScore(), this.threshold.get().doubleValue()); super.deliver(OUTPUT_PORT_ALL, extAnomalyScore); }
@Test public void testUnequality() { int i = 0; final StorableDetectionResult oneRecord = new StorableDetectionResult(STRING_VALUES.get(i % STRING_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), LONG_VALUES.get(i % LONG_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size())); i = 2; final StorableDetectionResult anotherRecord = new StorableDetectionResult(STRING_VALUES.get(i % STRING_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), LONG_VALUES.get(i % LONG_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size()), DOUBLE_VALUES.get(i % DOUBLE_VALUES.size())); Assert.assertNotEquals(oneRecord, anotherRecord); } }
/** * {@inheritDoc} */ @Override public void serialize(final IValueSerializer serializer) throws BufferOverflowException { //super.serialize(serializer); serializer.putString(this.getApplicationName()); serializer.putDouble(this.getValue()); serializer.putLong(this.getTimestamp()); serializer.putDouble(this.getForecast()); serializer.putDouble(this.getScore()); }
final StorableDetectionResult dr = new StorableDetectionResult(fmp.getName(), fmp.getValue(), fmp.getTime(), fmp.getForecasted(), score); super.deliver(OUTPUT_PORT_ANOMALY_SCORE, dr);
/** * {@inheritDoc} */ @Override public void serialize(final IValueSerializer serializer) throws BufferOverflowException { //super.serialize(serializer); serializer.putString(this.getApplicationName()); serializer.putDouble(this.getValue()); serializer.putLong(this.getTimestamp()); serializer.putDouble(this.getForecast()); serializer.putDouble(this.getScore()); } /**
final StorableDetectionResult dr = new StorableDetectionResult(fmp.getName(), fmp.getValue(), fmp.getTime(), fmp.getForecasted(), score); super.deliver(OUTPUT_PORT_ANOMALY_SCORE, dr);