diff --git a/lib/kieker-1.6-SNAPSHOT.jar b/lib/kieker-1.6-SNAPSHOT.jar index 2afb07a8e5c010fb8960c1cf24a9cb1c092e13cf..f51548dce46bae6dd0438c565e60abbdeb2aebe6 100644 Binary files a/lib/kieker-1.6-SNAPSHOT.jar and b/lib/kieker-1.6-SNAPSHOT.jar differ diff --git a/src/com/tielefeld/opad/filter/AnomalyDetectionFilter.java b/src/com/tielefeld/opad/filter/AnomalyDetectionFilter.java deleted file mode 100644 index 1cb5d4ac42176b870128a22c3b021c6e23688205..0000000000000000000000000000000000000000 --- a/src/com/tielefeld/opad/filter/AnomalyDetectionFilter.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.tielefeld.opad.filter; - -import kieker.analysis.plugin.annotation.InputPort; -import kieker.analysis.plugin.annotation.OutputPort; -import kieker.analysis.plugin.annotation.Plugin; -import kieker.analysis.plugin.filter.AbstractFilterPlugin; -import kieker.common.configuration.Configuration; - -import com.tielefeld.opad.record.NamedDoubleTimeSeriesPoint; - - -/** - * - * This filter separates input values by their reach of a certain threshold (parameter). - * It takes events of type NamedDoubleTimeSeriesPoint and channels them into two output ports: - * + anomalyscore_anomaly - yields a NamedDoubleTimeSeriesPoint if the threshold was reached - * + anomalyscore_else - if the input value was less than the threshold - * - * This filter has one configuration: - * + threshold - The format is English with a . separator, e.g., 0.5 0.7, ... - * - * @author Tillmann Carlos Bielefeld - * - */ -@Plugin(name = "AnomalyScore Detection Filter", - outputPorts = { - @OutputPort(eventTypes = { NamedDoubleTimeSeriesPoint.class }, - name = AnomalyDetectionFilter.OUTPUT_PORT_ANOMALY_SCORE_IF_ANOMALY), - @OutputPort(eventTypes = { NamedDoubleTimeSeriesPoint.class }, - name = AnomalyDetectionFilter.OUTPUT_PORT_ANOMALY_SCORE_ELSE) - }) -public class AnomalyDetectionFilter extends AbstractFilterPlugin { - - public AnomalyDetectionFilter(Configuration configuration) { - super(configuration); - // TODO Auto-generated constructor stub - } - - - - - public static final String OUTPUT_PORT_ANOMALY_SCORE_IF_ANOMALY = "anomalyscore_anomaly"; - public static final String OUTPUT_PORT_ANOMALY_SCORE_ELSE = "anomalyscore_else"; - public static final String INPUT_PORT_ANOMALY_SCORE = "anomalyscore"; - public static final String CONFIG_PROPERTY_THRESHOLD = "threshold"; - - private double threshold; - public Double inputAnomalyScore; - - - @Override - public boolean init() { - - final String sThreshold = super.configuration.getStringProperty(CONFIG_PROPERTY_THRESHOLD); - this.threshold = Double.parseDouble(sThreshold); - - - return true; - } - - @Override - public Configuration getCurrentConfiguration() { - return null; - } - - @Override - protected Configuration getDefaultConfiguration() { - return null; - } - - - - @InputPort(eventTypes = { NamedDoubleTimeSeriesPoint.class }, name = AnomalyDetectionFilter.INPUT_PORT_ANOMALY_SCORE) - public void inputForecastAndMeasurement(NamedDoubleTimeSeriesPoint anomalyScore) { - - // TODO check for null value?! - if (anomalyScore.getDoubleValue() > this.threshold) { - super.deliver(OUTPUT_PORT_ANOMALY_SCORE_ELSE, anomalyScore); - } else { - super.deliver(OUTPUT_PORT_ANOMALY_SCORE_IF_ANOMALY, anomalyScore); - } - } - -} diff --git a/src/com/tielefeld/opad/filter/AnomalyScoreCalculationFilter.java b/src/com/tielefeld/opad/filter/AnomalyScoreCalculationFilter.java deleted file mode 100644 index 3f851c1ea1fbce9eabc4f1a779b440d94e524b83..0000000000000000000000000000000000000000 --- a/src/com/tielefeld/opad/filter/AnomalyScoreCalculationFilter.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.tielefeld.opad.filter; - -import kieker.analysis.plugin.annotation.InputPort; -import kieker.analysis.plugin.annotation.OutputPort; -import kieker.analysis.plugin.annotation.Plugin; -import kieker.analysis.plugin.filter.AbstractFilterPlugin; -import kieker.common.configuration.Configuration; - -import com.tielefeld.opad.record.ForecastMeasurementPair; -import com.tielefeld.opad.record.IDoubleValue; -import com.tielefeld.opad.record.IForecastMeasurementPair; -import com.tielefeld.opad.record.NamedDoubleTimeSeriesPoint; -import com.tielefeld.tslib.anomalycalculators.AnomalyScore; -import com.tielefeld.tslib.forecast.IForecastResult; - -/** - * This filter calculates the anomaly score from the distance of the forecast and the current value. - * - * - * @author Tillmann Carlos Bielefeld - * - */ -@Plugin(name = "AnomalyScore Calculation Filter", outputPorts = { @OutputPort(eventTypes = { NamedDoubleTimeSeriesPoint.class }, -name = AnomalyScoreCalculationFilter.OUTPUT_PORT_ANOMALY_SCORE) }) -public class AnomalyScoreCalculationFilter extends AbstractFilterPlugin { - - public static final String INPUT_PORT_CURRENT_FORECAST_PAIR = "currentforecast"; - public static final String OUTPUT_PORT_ANOMALY_SCORE = "anomalyscore"; - - public AnomalyScoreCalculationFilter(Configuration configAnomaly) { - super(configAnomaly); - } - - @InputPort(eventTypes = { IForecastMeasurementPair.class }, name = AnomalyScoreCalculationFilter.INPUT_PORT_CURRENT_FORECAST_PAIR) - public void inputForecastAndMeasurement(IForecastMeasurementPair fmp) { - - Double score = null; - - if (null != fmp.getForecasted()) { - double nextpredicted = fmp.getForecasted(); - - double measuredValue = fmp.getValue(); - - double difference = nextpredicted - measuredValue; - double sum = nextpredicted + measuredValue; - - score = Math.abs(difference / sum); - } - - super.deliver(OUTPUT_PORT_ANOMALY_SCORE, new NamedDoubleTimeSeriesPoint(fmp.getTime(), score, fmp.getName()) ); - } - - @Override - public Configuration getCurrentConfiguration() { - // TODO Auto-generated method stub - return null; - } - - @Override - protected Configuration getDefaultConfiguration() { - // TODO Auto-generated method stub - return null; - } -} diff --git a/src/com/tielefeld/opad/filter/ForecastingFilter.java b/src/com/tielefeld/opad/filter/ForecastingFilter.java deleted file mode 100644 index 021837eadce312315a9c346d12a2ba97b4c3ea10..0000000000000000000000000000000000000000 --- a/src/com/tielefeld/opad/filter/ForecastingFilter.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.tielefeld.opad.filter; - -import java.util.Date; -import java.util.concurrent.TimeUnit; - -import kieker.analysis.plugin.annotation.InputPort; -import kieker.analysis.plugin.annotation.OutputPort; -import kieker.analysis.plugin.annotation.Plugin; -import kieker.analysis.plugin.filter.AbstractFilterPlugin; -import kieker.common.configuration.Configuration; - -import com.tielefeld.opad.record.ForecastMeasurementPair; -import com.tielefeld.opad.record.IForecastMeasurementPair; -import com.tielefeld.opad.record.NamedDoubleTimeSeriesPoint; -import com.tielefeld.tslib.ForecastMethod; -import com.tielefeld.tslib.ITimeSeries; -import com.tielefeld.tslib.ITimeSeriesPoint; -import com.tielefeld.tslib.TimeSeries; -import com.tielefeld.tslib.forecast.IForecastResult; -import com.tielefeld.tslib.forecast.IForecaster; - -/** - * Filters every incoming events by a given list of names - * - * @author Tillmann Carlos Bielefeld, Andre van Hoorn - * - */ -@Plugin(name = "Forecast Filter", outputPorts = { - @OutputPort(eventTypes = { IForecastResult.class }, name = ForecastingFilter.OUTPUT_PORT_NAME_FORECAST), - @OutputPort(eventTypes = { IForecastMeasurementPair.class }, name = ForecastingFilter.OUTPUT_PORT_NAME_FORECASTED_AND_CURRENT) }) -public class ForecastingFilter extends AbstractFilterPlugin { - - private IForecaster<Double> forecaster; - - public ForecastingFilter(Configuration configuration) { - super(configuration); - - long deltat = configuration.getLongProperty(CONFIG_PROPERTY_DELTA_TIME); - TimeUnit tunit = TimeUnit.valueOf(configuration - .getStringProperty(CONFIG_PROPERTY_DELTA_UNIT)); - - timeSeriesWindow = new TimeSeries<Double>(new Date(), deltat, tunit); - - // TODO select the method based on the configuration - forecastMethod = ForecastMethod.valueOf(configuration - .getStringProperty(CONFIG_PROPERTY_FC_METHOD)); - forecaster = forecastMethod.getForecaster(timeSeriesWindow); - } - - public static final String INPUT_PORT_NAME_TSPOINT = "tspoint"; - public static final String INPUT_PORT_NAME_TRIGGER = "trigger"; - - public static final String OUTPUT_PORT_NAME_FORECAST = "forecast"; - public static final String OUTPUT_PORT_NAME_FORECASTED_AND_CURRENT = "forecastedcurrent"; - - public static final String CONFIG_PROPERTY_DELTA_TIME = "deltatime"; - public static final String CONFIG_PROPERTY_DELTA_UNIT = "deltaunit"; - public static final String CONFIG_PROPERTY_FC_METHOD = "fcmethod"; - - private final ITimeSeries<Double> timeSeriesWindow; - private final ForecastMethod forecastMethod; - private NamedDoubleTimeSeriesPoint lastPoint; - - @Override - public Configuration getCurrentConfiguration() { - return null; - } - - @Override - protected Configuration getDefaultConfiguration() { - return null; - } - - private static final Object TRIGGER = new Object(); - - @InputPort(eventTypes = { NamedDoubleTimeSeriesPoint.class }, name = ForecastingFilter.INPUT_PORT_NAME_TSPOINT) - public void inputEvent(final NamedDoubleTimeSeriesPoint input) { - this.timeSeriesWindow.append(input.getValue()); - - this.lastPoint = input; - - // TODO: have this method triggered if no trigger port is given! - this.inputTrigger(TRIGGER); - } - - @InputPort(eventTypes = { Object.class }, name = ForecastingFilter.INPUT_PORT_NAME_TRIGGER) - public void inputTrigger(final Object trigger) { - - // TODO read the steps from config - IForecastResult<Double> result = forecaster.forecast(1); - super.deliver(OUTPUT_PORT_NAME_FORECAST, result); - - ForecastMeasurementPair fmp = new ForecastMeasurementPair( - this.lastPoint.getName(), - result.getForecast().getPoints().get(0).getValue(), - this.lastPoint.getValue(), - this.lastPoint.getTime()); - super.deliver(OUTPUT_PORT_NAME_FORECASTED_AND_CURRENT, fmp); - } - - - - - - - -} diff --git a/src/com/tielefeld/opad/filter/NameFilter.java b/src/com/tielefeld/opad/filter/NameFilter.java deleted file mode 100644 index a5ddabb6d25237575eee5e21eb9ffa09f7aa0ca8..0000000000000000000000000000000000000000 --- a/src/com/tielefeld/opad/filter/NameFilter.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.tielefeld.opad.filter; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -import kieker.analysis.plugin.annotation.InputPort; -import kieker.analysis.plugin.annotation.OutputPort; -import kieker.analysis.plugin.annotation.Plugin; -import kieker.analysis.plugin.filter.AbstractFilterPlugin; -import kieker.common.configuration.Configuration; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.tielefeld.opad.record.INamedElement; - -/** - * Filters every incoming events by a given list of names - * - * @author Tillmann Carlos Bielefeld, Andre van Hoorn - * - */ -@Plugin(name = "Name Filter", - outputPorts = { @OutputPort(eventTypes = { INamedElement.class }, - name = NameFilter.OUTPUT_PORT_NAME_VALUE) }) -public class NameFilter extends AbstractFilterPlugin { - - private static final Log LOG = LogFactory.getLog(NameFilter.class); - - public static final String OUTPUT_PORT_NAME_VALUE = "outputValue"; - public static final String INPUT_PORT_NAME_VALUE = "inputValue"; - public static final String CONFIG_PROPERTY_NAME_NAMES = "names"; - private final Set<String> names = new HashSet<String>(); - - public NameFilter(final Configuration configuration) { - super(configuration); - final String[] arrNames = configuration.getStringArrayProperty(NameFilter.CONFIG_PROPERTY_NAME_NAMES); - this.names.addAll(Arrays.asList(arrNames)); - - NameFilter.LOG.info("Started NameFilter filtering for names: " + this.names); - } - - @Override - public Configuration getCurrentConfiguration() { - // TODO Auto-generated method stub - return null; - } - - @Override - protected Configuration getDefaultConfiguration() { - // TODO Auto-generated method stub - return null; - } - - @InputPort(eventTypes = { INamedElement.class }, name = NameFilter.INPUT_PORT_NAME_VALUE) - public void inputEvent(final INamedElement input) { - if (this.names.contains(input.getName())) { - LogFactory.getLog("DATAFLOW").info("MFRR valid input: " + input.getName()); - super.deliver(NameFilter.OUTPUT_PORT_NAME_VALUE, input); - } - } - - -} diff --git a/src/com/tielefeld/opad/filter/ResponseTimeExtractionFilter.java b/src/com/tielefeld/opad/filter/ResponseTimeExtractionFilter.java deleted file mode 100644 index b0fb476dc294ce5fdc3795d96d1c070607c1cedd..0000000000000000000000000000000000000000 --- a/src/com/tielefeld/opad/filter/ResponseTimeExtractionFilter.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.tielefeld.opad.filter; - -import java.sql.Date; -import java.util.concurrent.TimeUnit; - -import kieker.analysis.plugin.annotation.InputPort; -import kieker.analysis.plugin.annotation.OutputPort; -import kieker.analysis.plugin.annotation.Plugin; -import kieker.analysis.plugin.filter.AbstractFilterPlugin; -import kieker.common.configuration.Configuration; -import kieker.common.record.controlflow.OperationExecutionRecord; - -import com.tielefeld.opad.record.NamedDoubleTimeSeriesPoint; - -/** - * TODO: Current response time unit: Nanoseconds - * TODO: Make source of timestamp configurable? (may be loggingTimestamp, tin, tout) - * - * @author Andre van Hoorn - * - */ -@Plugin(outputPorts = {@OutputPort(name = ResponseTimeExtractionFilter.OUTPUT_PORT_NAME_VALUE, eventTypes = { NamedDoubleTimeSeriesPoint.class })}) -public class ResponseTimeExtractionFilter extends AbstractFilterPlugin { - //private static final Log LOG = LogFactory.getLog(ResponseTimeExtractionFilter.class); - - public static final String OUTPUT_PORT_NAME_VALUE = "outputResponseTime"; - public static final String INPUT_PORT_NAME_VALUE = "inputExecutionRecord"; - - // TODO: Add configuration property for Time Unit - - public ResponseTimeExtractionFilter(final Configuration configuration) { - super(configuration); - } - - @InputPort(name = INPUT_PORT_NAME_VALUE, eventTypes = { OperationExecutionRecord.class }) - public void inputExecutionRecord(final OperationExecutionRecord execution) { - final long toutMillis = TimeUnit.MILLISECONDS.convert(execution.getTout(), TimeUnit.NANOSECONDS); - final Date time = new Date(toutMillis); - final double responseTime = execution.getTout() - execution.getTin(); - final NamedDoubleTimeSeriesPoint tspoint = new NamedDoubleTimeSeriesPoint(time, responseTime, execution.getOperationSignature()); - super.deliver(OUTPUT_PORT_NAME_VALUE, tspoint); - } - - @Override - public Configuration getCurrentConfiguration() { - return new Configuration(); - } - - @Override - protected Configuration getDefaultConfiguration() { - return new Configuration(); - } -} diff --git a/src/com/tielefeld/opad/filter/TimeSeriesExtractionFilter.java b/src/com/tielefeld/opad/filter/TimeSeriesExtractionFilter.java index 3b53f996204dc07e34e6c715d645f30ebf4474b1..0361f5069a92cc889f96fb87f5c7f7cb21294d5d 100644 --- a/src/com/tielefeld/opad/filter/TimeSeriesExtractionFilter.java +++ b/src/com/tielefeld/opad/filter/TimeSeriesExtractionFilter.java @@ -8,13 +8,13 @@ import kieker.analysis.plugin.annotation.Plugin; import kieker.analysis.plugin.annotation.RepositoryPort; import kieker.analysis.plugin.filter.AbstractFilterPlugin; import kieker.common.configuration.Configuration; +import kieker.tools.opad.record.NamedDoubleTimeSeriesPoint; import org.apache.commons.logging.LogFactory; import com.espertech.esper.client.EPStatement; import com.espertech.esper.client.EventBean; import com.espertech.esper.client.UpdateListener; -import com.tielefeld.opad.record.NamedDoubleTimeSeriesPoint; import com.tielefeld.opad.repository.EsperRepository; /** diff --git a/src/com/tielefeld/opad/filter/reader/MultiFieldRecordReader.java b/src/com/tielefeld/opad/filter/reader/MultiFieldRecordReader.java index ae2c020a39a8a811cb1a930d3a22e09f3116fca6..64225e8179c9adfa0007ccf1969916b8d8ef197b 100644 --- a/src/com/tielefeld/opad/filter/reader/MultiFieldRecordReader.java +++ b/src/com/tielefeld/opad/filter/reader/MultiFieldRecordReader.java @@ -1,14 +1,14 @@ package com.tielefeld.opad.filter.reader; import java.util.Collection; -import java.util.Date; -import java.util.Map.Entry; import kieker.analysis.plugin.annotation.OutputPort; import kieker.analysis.plugin.annotation.Plugin; import kieker.analysis.plugin.reader.AbstractReaderPlugin; import kieker.common.configuration.Configuration; import kieker.common.record.IMonitoringRecord; +import kieker.tools.opad.record.INamedElement; +import kieker.tools.opad.record.NamedTSPoint; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -18,8 +18,6 @@ import com.tielefeld.opad.operations.AttributeListenerGrid; import com.tielefeld.opad.pnf_old.MyNamedPipeManager; import com.tielefeld.opad.pnf_old.MyPipe; import com.tielefeld.opad.pnf_old.PipeData; -import com.tielefeld.opad.record.INamedElement; -import com.tielefeld.opad.record.NamedTSPoint; @Plugin(name = "Filter Processing MultiFieldRecords", outputPorts = { @@ -87,8 +85,8 @@ public class MultiFieldRecordReader extends AbstractReaderPlugin { final MultiFieldRecord record = data.getRecordData(); record.setLoggingTimestamp(data.getLoggingTimestamp()); - for (String key : record.getFields().keySet()) { - NamedTSPoint point = new NamedTSPoint(record.getLoggingTimestamp(), record.getFields().get(key), key); + for (final String key : record.getFields().keySet()) { + final NamedTSPoint point = new NamedTSPoint(record.getLoggingTimestamp(), record.getFields().get(key), key); super.deliver(MultiFieldRecordReader.OUTPUT_PORT_NAME_VALUE, point); } diff --git a/src/com/tielefeld/opad/record/ForecastMeasurementPair.java b/src/com/tielefeld/opad/record/ForecastMeasurementPair.java deleted file mode 100644 index 2cdded0cbbd14045fad81bd00f92f2fed9e2593e..0000000000000000000000000000000000000000 --- a/src/com/tielefeld/opad/record/ForecastMeasurementPair.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.tielefeld.opad.record; - -import java.util.Date; - -public class ForecastMeasurementPair implements IForecastMeasurementPair { - - private String name; - private Double forecast; - public ForecastMeasurementPair(String name, Double forecast, - Double measurement, Date time) { - super(); - this.name = name; - this.forecast = forecast; - this.measurement = measurement; - this.time = time; - } - private Double measurement; - private Date time; - - @Override - public String getName() { - return name; - } - @Override - public Date getTime() { - // TODO Auto-generated method stub - return time; - } - @Override - public Double getValue() { - // TODO Auto-generated method stub - return this.measurement; - } - @Override - public Double getForecasted() { - // TODO Auto-generated method stub - return this.forecast; - } - - -} diff --git a/src/com/tielefeld/opad/record/IDoubleValue.java b/src/com/tielefeld/opad/record/IDoubleValue.java deleted file mode 100644 index 0eb266b9c4a5f461dc999bebbd33254d01554dd2..0000000000000000000000000000000000000000 --- a/src/com/tielefeld/opad/record/IDoubleValue.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.tielefeld.opad.record; - -public interface IDoubleValue { - public double getValue(); -} diff --git a/src/com/tielefeld/opad/record/IForecastMeasurementPair.java b/src/com/tielefeld/opad/record/IForecastMeasurementPair.java deleted file mode 100644 index 416b3a4a9020eeca6e4c04b9ee82e89a0368101b..0000000000000000000000000000000000000000 --- a/src/com/tielefeld/opad/record/IForecastMeasurementPair.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.tielefeld.opad.record; - -import com.tielefeld.tslib.ITimeSeriesPoint; - -public interface IForecastMeasurementPair extends INamedElement, ITimeSeriesPoint<Double> { - - public Double getForecasted(); - -} diff --git a/src/com/tielefeld/opad/record/INamedElement.java b/src/com/tielefeld/opad/record/INamedElement.java deleted file mode 100644 index ae3843b52f56e59f3717519af3245b1e104b8fbc..0000000000000000000000000000000000000000 --- a/src/com/tielefeld/opad/record/INamedElement.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.tielefeld.opad.record; - -public interface INamedElement { - - public String getName(); - -} diff --git a/src/com/tielefeld/opad/record/NamedDoubleTimeSeriesPoint.java b/src/com/tielefeld/opad/record/NamedDoubleTimeSeriesPoint.java deleted file mode 100644 index b0182f42076f74192f51733c54c07b32394d7a9a..0000000000000000000000000000000000000000 --- a/src/com/tielefeld/opad/record/NamedDoubleTimeSeriesPoint.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * - */ -package com.tielefeld.opad.record; - -import java.util.Date; - -import com.tielefeld.tslib.TimeSeriesPoint; - -/** - * @author till - * - * - */ -public class NamedDoubleTimeSeriesPoint extends TimeSeriesPoint<Double> implements - INamedElement { - - private final String name; - - public NamedDoubleTimeSeriesPoint(final Date time, final Double value, final String name) { - super(time, value); - this.name = name; - } - - /* (non-Javadoc) - * @see com.tielefeld.opad.record.INamedElement#getName() - */ - @Override - public String getName() { - return this.name; - } - - public double getDoubleValue() { - return this.getValue(); - } - - @Override - public String toString() { - return this.name + " >> " + super.toString(); - } -} diff --git a/src/com/tielefeld/opad/record/NamedTSPoint.java b/src/com/tielefeld/opad/record/NamedTSPoint.java deleted file mode 100644 index 660e4c35e5eb11d8673cddc5f3d0efc03e1fe88c..0000000000000000000000000000000000000000 --- a/src/com/tielefeld/opad/record/NamedTSPoint.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.tielefeld.opad.record; - -import java.io.IOException; -import java.io.StringWriter; -import java.util.LinkedHashMap; -import java.util.Map; - -import kieker.common.record.AbstractMonitoringRecord; -import kieker.common.record.IMonitoringRecord; -import net.sf.json.JSONString; - -import org.json.simple.JSONValue; - -public class NamedTSPoint extends AbstractMonitoringRecord implements - IMonitoringRecord.Factory, INamedElement, IDoubleValue, JSONString { - - public NamedTSPoint(long timestamp, double value, String name) { - super(); - this.timestamp = timestamp; - this.value = value; - this.name = name; - } - - private final long timestamp; - private final double value; - private final String name; - - @Override - public Object[] toArray() { - // TODO Auto-generated method stub - return null; - } - - @Override - @Deprecated - public void initFromArray(Object[] values) { - throw new UnsupportedOperationException(); - } - - @Override - public Class<?>[] getValueTypes() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getName() { - return this.name; - } - - @Override - public double getValue() { - return this.value; - } - - @Override - public String toJSONString() { - Map obj = new LinkedHashMap(); - obj.put("name", this.name); - obj.put("time", this.timestamp); - obj.put("value", this.value); - - StringWriter out = new StringWriter(); - try { - JSONValue.writeJSONString(obj, out); - } catch (IOException e) { - // TODO write an error json? - e.printStackTrace(); - } - return out.toString(); - } - -} diff --git a/src/com/tielefeld/opad/record/NamedTSPointJSON.java b/src/com/tielefeld/opad/record/NamedTSPointJSON.java new file mode 100644 index 0000000000000000000000000000000000000000..e048a7ef421af8656ca2208f93b5cf1aa4dcb6a5 --- /dev/null +++ b/src/com/tielefeld/opad/record/NamedTSPointJSON.java @@ -0,0 +1,54 @@ +package com.tielefeld.opad.record; + +import java.io.IOException; +import java.io.StringWriter; +import java.util.LinkedHashMap; +import java.util.Map; + +import kieker.tools.opad.record.NamedTSPoint; +import net.sf.json.JSONString; + +import org.json.simple.JSONValue; + +public class NamedTSPointJSON extends NamedTSPoint implements JSONString { + + public NamedTSPointJSON(final long timestamp, final double value, final String name) { + super(timestamp, value, name); + } + + @Override + public Object[] toArray() { + // TODO Auto-generated method stub + return null; + } + + @Override + @Deprecated + public void initFromArray(final Object[] values) { + throw new UnsupportedOperationException(); + } + + @Override + public Class<?>[] getValueTypes() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String toJSONString() { + final Map obj = new LinkedHashMap(); + obj.put("name", this.getName()); + obj.put("time", this.getTimestamp()); + obj.put("value", this.getValue()); + + final StringWriter out = new StringWriter(); + try { + JSONValue.writeJSONString(obj, out); + } catch (final IOException e) { + // TODO write an error json? + e.printStackTrace(); + } + return out.toString(); + } + +} diff --git a/src/com/tielefeld/opad/repository/EsperRepository.java b/src/com/tielefeld/opad/repository/EsperRepository.java index 5447464d7276cc7a6cc36821213aa94da5f26d4f..f4e14b54171b285927ed81cbe4f2848963a1bb86 100644 --- a/src/com/tielefeld/opad/repository/EsperRepository.java +++ b/src/com/tielefeld/opad/repository/EsperRepository.java @@ -3,12 +3,12 @@ package com.tielefeld.opad.repository; import kieker.analysis.repository.AbstractRepository; import kieker.analysis.repository.annotation.Repository; import kieker.common.configuration.Configuration; +import kieker.tools.opad.record.NamedDoubleTimeSeriesPoint; import com.espertech.esper.client.EPAdministrator; import com.espertech.esper.client.EPRuntime; import com.espertech.esper.client.EPServiceProvider; import com.espertech.esper.client.EPServiceProviderManager; -import com.tielefeld.opad.record.NamedDoubleTimeSeriesPoint; @Repository(name = "Esper Runtime Container") public class EsperRepository extends AbstractRepository { @@ -20,14 +20,14 @@ public class EsperRepository extends AbstractRepository { private final EPServiceProvider cep; - public EsperRepository(Configuration configuration) { + public EsperRepository(final Configuration configuration) { super(configuration); - com.espertech.esper.client.Configuration cepConfig = new com.espertech.esper.client.Configuration(); + final com.espertech.esper.client.Configuration cepConfig = new com.espertech.esper.client.Configuration(); cepConfig.addEventType(NamedDoubleTimeSeriesPoint.class); // TODO what if we want to have multiple repos? - cep = EPServiceProviderManager.getProvider(configuration.getStringProperty(RUNTIME_INSTANCE_NAME),cepConfig); + this.cep = EPServiceProviderManager.getProvider(configuration.getStringProperty(RUNTIME_INSTANCE_NAME),cepConfig); } @Override @@ -44,11 +44,11 @@ public class EsperRepository extends AbstractRepository { public EPRuntime getEsperRuntime() { - return cep.getEPRuntime(); + return this.cep.getEPRuntime(); } public EPAdministrator getEsperAdministrator() { - return cep.getEPAdministrator(); + return this.cep.getEPAdministrator(); } } diff --git a/src/com/tielefeld/opad/support/OPADNewFiltersRunner.java b/src/com/tielefeld/opad/support/OPADNewFiltersRunner.java index 140e81bd1f60d94589e4800e6592fc112be1b167..5a7b41a6fc7ad514d1e2b17d6a98f8511338c10b 100644 --- a/src/com/tielefeld/opad/support/OPADNewFiltersRunner.java +++ b/src/com/tielefeld/opad/support/OPADNewFiltersRunner.java @@ -10,6 +10,7 @@ import kieker.analysis.exception.AnalysisConfigurationException; import kieker.common.configuration.Configuration; import kieker.monitoring.core.controller.IMonitoringController; import kieker.monitoring.core.controller.MonitoringController; +import kieker.tools.opad.filter.NameFilter; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -21,7 +22,6 @@ import com.rabbitmq.client.ConnectionFactory; import com.rabbitmq.client.QueueingConsumer; import com.tielefeld.opad.config.OPADConfiguration; import com.tielefeld.opad.filter.AMQPPublishingReader; -import com.tielefeld.opad.filter.NameFilter; import com.tielefeld.opad.filter.reader.MultiFieldRecordReader; import com.tielefeld.opad.measures.MultiFieldRecord; @@ -41,7 +41,7 @@ public class OPADNewFiltersRunner { * @throws AnalysisConfigurationException * @throws IllegalStateException */ - public static void main(String[] args) throws IllegalStateException, + public static void main(final String[] args) throws IllegalStateException, AnalysisConfigurationException { LogFactory.getLog("STATE").info(""); LogFactory.getLog("STATE").info("______________"); @@ -65,27 +65,29 @@ public class OPADNewFiltersRunner { Date startDate = new Date(); if (!OPADConfiguration.getInstance().get(OPADConfiguration.START_TIME) - .equals("")) + .equals("")) { startDate = new Date(Long.parseLong(OPADConfiguration.getInstance() .get(OPADConfiguration.START_TIME))); + } LogFactory.getLog("STATE").info( "Starting the queueing at time: " + startDate); new Thread(new Runnable() { + @Override public void run() { - startQueueing(queueServer, exchangeName, routingKey); + OPADNewFiltersRunner.startQueueing(queueServer, exchangeName, routingKey); } }).start(); - configureAndStartKieker(startDate, alertingQueueServer, + OPADNewFiltersRunner.configureAndStartKieker(startDate, alertingQueueServer, alertingExchangeName); } - public static void configureAndStartKieker(Date startDate, - Address alertingQueueServer, String alertingExchangeName) + public static void configureAndStartKieker(final Date startDate, + final Address alertingQueueServer, final String alertingExchangeName) throws IllegalStateException, AnalysisConfigurationException { /* SPAWNING THE CONTROLLER... */ @@ -144,37 +146,37 @@ public class OPADNewFiltersRunner { analyisController.run(); } - public static void startQueueing(Address queueServer, String exchangeName, - String routingKey) { - ConnectionFactory factory = new ConnectionFactory(); + public static void startQueueing(final Address queueServer, final String exchangeName, + final String routingKey) { + final ConnectionFactory factory = new ConnectionFactory(); try { LOG.info("Trying to connect to rabbitmq at address " + queueServer); - Connection conn = factory + final Connection conn = factory .newConnection(new Address[] { queueServer }); LOG.info("... success!"); - Channel channel = conn.createChannel(); + final Channel channel = conn.createChannel(); LOG.info("Creating a new queue as our endpoint..."); - String queueName = channel.queueDeclare().getQueue(); + final String queueName = channel.queueDeclare().getQueue(); LOG.info("Bound the new queue (" + queueName + ") to exchange " + exchangeName + " and routing key: " + routingKey); channel.queueBind(queueName, exchangeName, routingKey); - boolean autoAck = false; - QueueingConsumer consumer = new QueueingConsumer(channel); + final boolean autoAck = false; + final QueueingConsumer consumer = new QueueingConsumer(channel); channel.basicConsume(queueName, autoAck, consumer); while (true) { QueueingConsumer.Delivery delivery; try { delivery = consumer.nextDelivery(); - String measureString = new String(delivery.getBody()); + final String measureString = new String(delivery.getBody()); LOG.debug("Q input: " + measureString); - MultiFieldRecord mfr = new MultiFieldRecord(measureString); + final MultiFieldRecord mfr = new MultiFieldRecord(measureString); // LOG.debug("Inserted MultiFieldRecord: " + mfr); @@ -185,7 +187,7 @@ public class OPADNewFiltersRunner { + " keys)"); MONITORING_CONTROLLER.newMonitoringRecord(mfr); - } catch (Exception ie) { + } catch (final Exception ie) { LOG.error("Invalid data from queue: " + ie); continue; } @@ -193,20 +195,20 @@ public class OPADNewFiltersRunner { channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false); } - } catch (IOException e) { + } catch (final IOException e) { e.printStackTrace(); } } - public static void setEnvironment(String[] args) { + public static void setEnvironment(final String[] args) { if (null == System.getProperty(OPADConfiguration.OPAD_ENVIRONMENT)) { String argEnv = "development"; // the default if (args.length > 0) { - Pattern pattern = Pattern.compile("opad\\_environment=(\\w*)", + final Pattern pattern = Pattern.compile("opad\\_environment=(\\w*)", Pattern.CASE_INSENSITIVE); - Matcher matcher = pattern.matcher(args[0]); + final Matcher matcher = pattern.matcher(args[0]); // Check all occurences while (matcher.find()) { argEnv = matcher.group(1); diff --git a/tests/com/tielefeld/opad/filter/AnomalyDetectionFilterTest.java b/tests/com/tielefeld/opad/filter/AnomalyDetectionFilterTest.java deleted file mode 100644 index 6985fb71c2e95fd1387f1be8f837a5515b6c8c85..0000000000000000000000000000000000000000 --- a/tests/com/tielefeld/opad/filter/AnomalyDetectionFilterTest.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.tielefeld.opad.filter; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import kieker.analysis.AnalysisController; -import kieker.analysis.AnalysisControllerThread; -import kieker.analysis.exception.AnalysisConfigurationException; -import kieker.common.configuration.Configuration; -import kieker.test.analysis.util.plugin.filter.SimpleSinkFilter; -import kieker.test.analysis.util.plugin.reader.SimpleListReader; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.tielefeld.opad.record.NamedDoubleTimeSeriesPoint; - -/** - * - * Testing the AnomalyDetectionFilter. What is basically testing is following: - * + Set Threshold of the Filter to 0.6 - * + Input 0.5, 0.6, 0.7 - * + Awaits - * - 0.5 to be normal (1 in the sink) - * - 0.6 and 0.7 to be an anomaly - * - * @author Tillmann Carlos Bielefeld - */ -public class AnomalyDetectionFilterTest { - - // private NameFilter nameFilter; - private SimpleListReader<NamedDoubleTimeSeriesPoint> theReader; - private AnomalyDetectionFilter anomalyDetectionFilter; - - private SimpleSinkFilter<NamedDoubleTimeSeriesPoint> sinkPluginIfAnomaly; - private SimpleSinkFilter<NamedDoubleTimeSeriesPoint> sinkPluginElse; - private AnalysisController controller; - - private static final String OP_SIGNATURE_A = "a.A.opA"; - - - private NamedDoubleTimeSeriesPoint createNDTSP(final String signature, final double value) { - final NamedDoubleTimeSeriesPoint r = new NamedDoubleTimeSeriesPoint(new Date(), value, signature); - return r; - } - - private List<NamedDoubleTimeSeriesPoint> createInputEventSet() { - final List<NamedDoubleTimeSeriesPoint> retList = new ArrayList<NamedDoubleTimeSeriesPoint>(); - retList.add(this.createNDTSP(OP_SIGNATURE_A, 0.5)); - retList.add(this.createNDTSP(OP_SIGNATURE_A, 0.6)); - retList.add(this.createNDTSP(OP_SIGNATURE_A, 0.7)); - return retList; - } - - @Before - public void setUp() throws IllegalStateException, AnalysisConfigurationException { - this.controller = new AnalysisController(); - - // READER - final Configuration readerConfiguration = new Configuration(); - readerConfiguration.setProperty(SimpleListReader.CONFIG_PROPERTY_NAME_AWAIT_TERMINATION, Boolean.TRUE.toString()); - this.theReader = new SimpleListReader<NamedDoubleTimeSeriesPoint>(readerConfiguration); - this.theReader.addAllObjects(this.createInputEventSet()); - this.controller.registerReader(this.theReader); - - - // ANOMALY DETECTION FILTER - final Configuration configAnomaly = new Configuration(); - configAnomaly.setProperty(AnomalyDetectionFilter.CONFIG_PROPERTY_THRESHOLD, "0.6"); - this.anomalyDetectionFilter = new AnomalyDetectionFilter(configAnomaly); - this.controller.registerFilter(this.anomalyDetectionFilter); - - // SINK 1 - this.sinkPluginIfAnomaly = new SimpleSinkFilter<NamedDoubleTimeSeriesPoint>(new Configuration()); - this.controller.registerFilter(this.sinkPluginIfAnomaly); - - // SINK 2 - this.sinkPluginElse = new SimpleSinkFilter<NamedDoubleTimeSeriesPoint>(new Configuration()); - this.controller.registerFilter(this.sinkPluginElse); - - // CONNECT the filters - this.controller.connect(this.theReader, SimpleListReader.OUTPUT_PORT_NAME, - this.anomalyDetectionFilter, AnomalyDetectionFilter.INPUT_PORT_ANOMALY_SCORE); - this.controller.connect(this.anomalyDetectionFilter, AnomalyDetectionFilter.OUTPUT_PORT_ANOMALY_SCORE_IF_ANOMALY, - this.sinkPluginIfAnomaly, SimpleSinkFilter.INPUT_PORT_NAME); - this.controller.connect(this.anomalyDetectionFilter, AnomalyDetectionFilter.OUTPUT_PORT_ANOMALY_SCORE_ELSE, - this.sinkPluginElse, SimpleSinkFilter.INPUT_PORT_NAME); - - Assert.assertTrue(this.sinkPluginIfAnomaly.getList().isEmpty()); - } - - @Test - public void testSimpleOPADFlow() throws InterruptedException, IllegalStateException, AnalysisConfigurationException { - - final AnalysisControllerThread thread = new AnalysisControllerThread(this.controller); - thread.start(); - - Thread.sleep(1000); - thread.terminate(); - - Assert.assertEquals(2, this.sinkPluginIfAnomaly.getList().size()); - Assert.assertEquals(1, this.sinkPluginElse.getList().size()); - } - - - -} diff --git a/tests/com/tielefeld/opad/filter/AnomalyScoreCalculationFilterTest.java b/tests/com/tielefeld/opad/filter/AnomalyScoreCalculationFilterTest.java deleted file mode 100644 index 12af9bdb3061b620932dee2814e63f89acd18fd6..0000000000000000000000000000000000000000 --- a/tests/com/tielefeld/opad/filter/AnomalyScoreCalculationFilterTest.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.tielefeld.opad.filter; - -import java.util.Date; - -import kieker.analysis.AnalysisController; -import kieker.analysis.exception.AnalysisConfigurationException; -import kieker.common.configuration.Configuration; -import kieker.test.analysis.util.plugin.filter.SimpleSinkFilter; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.tielefeld.opad.record.NamedDoubleTimeSeriesPoint; -import com.tielefeld.tslib.ITimeSeriesPoint; -import com.tielefeld.tslib.forecast.IForecastResult; - -public class AnomalyScoreCalculationFilterTest { - - private ForecastingFilter forecasting; - private AnalysisController controller; - private SimpleSinkFilter<IForecastResult<Double>> sinkPlugin; - - @Before - public void setUp() throws IllegalStateException, - AnalysisConfigurationException { - Configuration config = new Configuration(); - config.setProperty(ForecastingFilter.CONFIG_PROPERTY_DELTA_TIME, "1000"); - config.setProperty(ForecastingFilter.CONFIG_PROPERTY_DELTA_UNIT, - "MINUTES"); - config.setProperty(ForecastingFilter.CONFIG_PROPERTY_FC_METHOD, "MEAN"); - - this.forecasting = new ForecastingFilter(config); - - sinkPlugin = new SimpleSinkFilter<IForecastResult<Double>>(new Configuration()); - Assert.assertTrue(sinkPlugin.getList().isEmpty()); - - controller = new AnalysisController(); - controller.registerFilter(this.forecasting); - controller.registerFilter(sinkPlugin); - controller.connect(this.forecasting, - ForecastingFilter.OUTPUT_PORT_NAME_FORECAST, sinkPlugin, - SimpleSinkFilter.INPUT_PORT_NAME); - } - - @Test - public void testFilterOnly() { - this.forecasting.inputEvent(new NamedDoubleTimeSeriesPoint(new Date(), 0.3, "a")); - this.forecasting.inputEvent(new NamedDoubleTimeSeriesPoint(new Date(), 0.4, "a")); - this.forecasting.inputEvent(new NamedDoubleTimeSeriesPoint(new Date(), 0.5, "a")); - - Assert.assertEquals(3, sinkPlugin.getList().size()); - IForecastResult<Double> lastresult = sinkPlugin.getList().get(2); - ITimeSeriesPoint<Double> nextMeanFC = lastresult.getForecast().getPoints().get(0); - Assert.assertEquals(new Double(0.4), nextMeanFC.getValue()); - } - - - -} diff --git a/tests/com/tielefeld/opad/filter/CompleteOPADFlowTest.java b/tests/com/tielefeld/opad/filter/CompleteOPADFlowTest.java index 5f238cbc9c4c62833c8b2cdc62ab9398395268eb..3e93cd6c6cccf53c052532a8bc3c35d2bfa5b915 100644 --- a/tests/com/tielefeld/opad/filter/CompleteOPADFlowTest.java +++ b/tests/com/tielefeld/opad/filter/CompleteOPADFlowTest.java @@ -13,12 +13,16 @@ import kieker.common.configuration.Configuration; import kieker.common.record.controlflow.OperationExecutionRecord; import kieker.test.analysis.util.plugin.filter.SimpleSinkFilter; import kieker.test.analysis.util.plugin.reader.SimpleListReader; +import kieker.tools.opad.filter.AnomalyDetectionFilter; +import kieker.tools.opad.filter.AnomalyScoreCalculationFilter; +import kieker.tools.opad.filter.ForecastingFilter; +import kieker.tools.opad.filter.ResponseTimeExtractionFilter; +import kieker.tools.opad.record.NamedDoubleTimeSeriesPoint; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import com.tielefeld.opad.record.NamedDoubleTimeSeriesPoint; import com.tielefeld.opad.repository.EsperRepository; /** @@ -149,7 +153,7 @@ public class CompleteOPADFlowTest { this.anomalyCalc, AnomalyScoreCalculationFilter.INPUT_PORT_CURRENT_FORECAST_PAIR); // ANOMALY DETECTION FILTER - Configuration configDetection = new Configuration(); + final Configuration configDetection = new Configuration(); configDetection.setProperty(AnomalyDetectionFilter.CONFIG_PROPERTY_THRESHOLD, "0.5"); this.detectionFilter = new AnomalyDetectionFilter(configDetection); this.controller.registerFilter(this.detectionFilter); diff --git a/tests/com/tielefeld/opad/filter/ForecastingFilterTest.java b/tests/com/tielefeld/opad/filter/ForecastingFilterTest.java deleted file mode 100644 index 0ce81bb70d858f34787f3c198f5108a2f82a2e02..0000000000000000000000000000000000000000 --- a/tests/com/tielefeld/opad/filter/ForecastingFilterTest.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.tielefeld.opad.filter; - -import java.util.Date; - -import kieker.analysis.AnalysisController; -import kieker.analysis.exception.AnalysisConfigurationException; -import kieker.common.configuration.Configuration; -import kieker.test.analysis.util.plugin.filter.SimpleSinkFilter; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.tielefeld.opad.record.NamedDoubleTimeSeriesPoint; -import com.tielefeld.tslib.ITimeSeriesPoint; -import com.tielefeld.tslib.forecast.IForecastResult; - -public class ForecastingFilterTest { - - private ForecastingFilter forecasting; - private AnalysisController controller; - private SimpleSinkFilter<IForecastResult<Double>> sinkPlugin; - - @Before - public void setUp() throws IllegalStateException, - AnalysisConfigurationException { - Configuration config = new Configuration(); - config.setProperty(ForecastingFilter.CONFIG_PROPERTY_DELTA_TIME, "1000"); - config.setProperty(ForecastingFilter.CONFIG_PROPERTY_DELTA_UNIT, - "MINUTES"); - config.setProperty(ForecastingFilter.CONFIG_PROPERTY_FC_METHOD, "MEAN"); - - this.forecasting = new ForecastingFilter(config); - - sinkPlugin = new SimpleSinkFilter<IForecastResult<Double>>(new Configuration()); - Assert.assertTrue(sinkPlugin.getList().isEmpty()); - - controller = new AnalysisController(); - controller.registerFilter(this.forecasting); - controller.registerFilter(sinkPlugin); - controller.connect(this.forecasting, - ForecastingFilter.OUTPUT_PORT_NAME_FORECAST, sinkPlugin, - SimpleSinkFilter.INPUT_PORT_NAME); - } - - @Test - public void testFilterOnly() { - this.forecasting.inputEvent(new NamedDoubleTimeSeriesPoint(new Date(), 0.3, "a")); - this.forecasting.inputEvent(new NamedDoubleTimeSeriesPoint(new Date(), 0.4, "a")); - this.forecasting.inputEvent(new NamedDoubleTimeSeriesPoint(new Date(), 0.5, "a")); - - - Assert.assertEquals(3, sinkPlugin.getList().size()); - IForecastResult<Double> lastresult = sinkPlugin.getList().get(2); - ITimeSeriesPoint<Double> nextMeanFC = lastresult.getForecast().getPoints().get(0); - Assert.assertEquals(new Double(0.4), nextMeanFC.getValue()); - } - - private class DummyTSPoint implements ITimeSeriesPoint<Double> { - - private double value; - - public DummyTSPoint(double val) { - this.value = val; - } - - @Override - public Date getTime() { - return new Date(); - } - - @Override - public Double getValue() { - return this.value; - } - - } - -} diff --git a/tests/com/tielefeld/opad/filter/TimeSeriesExtractionFilterTest.java b/tests/com/tielefeld/opad/filter/TimeSeriesExtractionFilterTest.java index 2542d3cca445348930ce50c6939fde6cd897b01a..26a133b530a7b53535366387d68d419f0fbacefb 100644 --- a/tests/com/tielefeld/opad/filter/TimeSeriesExtractionFilterTest.java +++ b/tests/com/tielefeld/opad/filter/TimeSeriesExtractionFilterTest.java @@ -1,7 +1,5 @@ package com.tielefeld.opad.filter; -import static org.junit.Assert.fail; - import java.util.Date; import java.util.List; @@ -10,14 +8,12 @@ import kieker.analysis.exception.AnalysisConfigurationException; import kieker.analysis.plugin.reader.AbstractReaderPlugin; import kieker.common.configuration.Configuration; import kieker.test.analysis.util.plugin.filter.SimpleSinkFilter; +import kieker.tools.opad.record.NamedDoubleTimeSeriesPoint; -import org.apache.commons.logging.LogFactory; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import com.tielefeld.opad.record.INamedElement; -import com.tielefeld.opad.record.NamedDoubleTimeSeriesPoint; import com.tielefeld.opad.repository.EsperRepository; public class TimeSeriesExtractionFilterTest { @@ -29,23 +25,23 @@ public class TimeSeriesExtractionFilterTest { @Before public void setUp() throws IllegalStateException, AnalysisConfigurationException { - Configuration esperConfig = new Configuration(); + final Configuration esperConfig = new Configuration(); this.esperRepo = new EsperRepository(esperConfig); - Configuration tsConfig = new Configuration(); + final Configuration tsConfig = new Configuration(); tsConfig.setProperty(TimeSeriesExtractionFilter.CONFIG_PROPERTY_NAME_AGGREGATE_STEP_SIZE_MILLIS, "1000"); this.extraction = new TimeSeriesExtractionFilter(tsConfig); - sinkPlugin = new SimpleSinkFilter<NamedDoubleTimeSeriesPoint>(new Configuration()); - Assert.assertTrue(sinkPlugin.getList().isEmpty()); + this.sinkPlugin = new SimpleSinkFilter<NamedDoubleTimeSeriesPoint>(new Configuration()); + Assert.assertTrue(this.sinkPlugin.getList().isEmpty()); - controller = new AnalysisController(); - controller.registerRepository(esperRepo); - controller.registerFilter(this.extraction); - controller.registerFilter(this.sinkPlugin); + this.controller = new AnalysisController(); + this.controller.registerRepository(this.esperRepo); + this.controller.registerFilter(this.extraction); + this.controller.registerFilter(this.sinkPlugin); - controller.connect(this.extraction, TimeSeriesExtractionFilter.REPOSITORY_PORT_NAME_ESPER, this.esperRepo); - controller.connect(this.extraction, TimeSeriesExtractionFilter.OUTPUT_PORT_NAME_VALUE, sinkPlugin, SimpleSinkFilter.INPUT_PORT_NAME); + this.controller.connect(this.extraction, TimeSeriesExtractionFilter.REPOSITORY_PORT_NAME_ESPER, this.esperRepo); + this.controller.connect(this.extraction, TimeSeriesExtractionFilter.OUTPUT_PORT_NAME_VALUE, this.sinkPlugin, SimpleSinkFilter.INPUT_PORT_NAME); // TODO we need a log reader for this. Let's try to circumvent it //controller.run(); @@ -73,14 +69,14 @@ public class TimeSeriesExtractionFilterTest { Thread.sleep(1100); - List<NamedDoubleTimeSeriesPoint> checkList = this.sinkPlugin.getList(); + final List<NamedDoubleTimeSeriesPoint> checkList = this.sinkPlugin.getList(); Assert.assertEquals(2, this.sinkPlugin.getList().size()); } @Test public void testWithController() { - fail("TODO: Build a Reader and test this in a larger context!"); + Assert.fail("TODO: Build a Reader and test this in a larger context!"); this.controller.registerReader(new AbstractReaderPlugin( new Configuration()) { @@ -91,7 +87,7 @@ public class TimeSeriesExtractionFilterTest { } @Override - public void terminate(boolean error) { + public void terminate(final boolean error) { // TODO Auto-generated method stub } @@ -110,7 +106,7 @@ public class TimeSeriesExtractionFilterTest { }); // TODO@STARTHERE tcb: start here! - Assert.assertEquals(1, sinkPlugin.getList().size()); + Assert.assertEquals(1, this.sinkPlugin.getList().size()); } diff --git a/tests/com/tielefeld/opad/testsuites/AllPNFTests.java b/tests/com/tielefeld/opad/testsuites/AllPNFTests.java index 42043f8a5d4f113669c086ee5f2c05fa53b2f85a..2c5f24767787e8f5f312afe3191e489287617cf7 100644 --- a/tests/com/tielefeld/opad/testsuites/AllPNFTests.java +++ b/tests/com/tielefeld/opad/testsuites/AllPNFTests.java @@ -7,8 +7,8 @@ import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) @SuiteClasses({ - com.tielefeld.opad.filter.AnomalyScoreCalculationFilterTest.class, - com.tielefeld.opad.filter.ForecastingFilterTest.class, + kieker.test.tools.junit.opad.filter.AnomalyScoreCalculationFilterTest.class, + kieker.test.tools.junit.opad.filter.ForecastingFilterTest.class, com.tielefeld.opad.filter.TimeSeriesExtractionFilterTest.class, }) public class AllPNFTests {