/** * A test for the counting filter with multiple readers. * * @throws IllegalStateException * If the test setup is somehow invalid (should not happen). * @throws AnalysisConfigurationException * If the test setup is somehow invalid (should not happen). */ @Test public void testConcurrently() throws IllegalStateException, AnalysisConfigurationException { this.simpleListReader.addObject(new Object()); // register multiple readers (they fire concurrently) final ListReader<Object> reader2 = new ListReader<Object>(new Configuration(), this.analysisController); this.analysisController.connect(reader2, ListReader.OUTPUT_PORT_NAME, this.countingFilter, CountingFilter.INPUT_PORT_NAME_EVENTS); reader2.addObject(new Object()); final ListReader<Object> reader3 = new ListReader<Object>(new Configuration(), this.analysisController); this.analysisController.connect(reader3, ListReader.OUTPUT_PORT_NAME, this.countingFilter, CountingFilter.INPUT_PORT_NAME_EVENTS); reader3.addObject(new Object()); Assert.assertEquals(0, this.countingFilter.getMessageCount()); this.analysisController.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, this.analysisController.getState()); Assert.assertEquals(3, this.countingFilter.getMessageCount()); }
@Override protected AbstractReaderPlugin createReader(final IAnalysisController analysisController) { final Configuration listReaderConfig = new Configuration(); listReaderConfig.setProperty(ListReader.CONFIG_PROPERTY_NAME_AWAIT_TERMINATION, Boolean.toString(Boolean.FALSE)); final ListReader<IMonitoringRecord> listReader = new ListReader<>(listReaderConfig, analysisController); listReader.addAllObjects(this.replayList); return listReader; } }
private List<Entry<Long, Integer>> passEventListToReader(final ListReader<IMonitoringRecord> reader) { long currentTimeSeconds; int curNumRecords = 0; final List<Entry<Long, Integer>> eventList = new ArrayList<>(this.eventTimeOffsetsSeconds.length); for (final long eventDelaySeconds : this.eventTimeOffsetsSeconds) { curNumRecords++; currentTimeSeconds = START_TIME_SECONDS + eventDelaySeconds; final Entry<Long, Integer> curEntry = new SimpleImmutableEntry<>(eventDelaySeconds, curNumRecords); eventList.add(curEntry); final EmptyRecord r = new EmptyRecord(); r.setLoggingTimestamp(TimeUnit.NANOSECONDS.convert(currentTimeSeconds, TimeUnit.SECONDS)); this.inputRecords.add(r); reader.addObject(r); } return eventList; }
/** * This method initializes the setup. */ @Before public void before() { this.controller = new AnalysisController(); this.reader = new ListReader<>(new Configuration(), this.controller); this.sinkPlugin = new ListCollectionFilter<>(new Configuration(), this.controller); }
records.add(r3); this.simpleListReader.addAllObjects(records);
/** * Converts the OperationExecutionRecord using the previously set up filter structure. * * @param oer * @throws IllegalStateException * exception that can possibly be thrown by AnalysisController * @throws AnalysisConfigurationException * exception that can possibly be thrown by AnalysisController */ private void convertRecord(final OperationExecutionRecord oer) throws IllegalStateException, AnalysisConfigurationException { this.simpleListReader.addObject(oer); this.analysisController.run(); this.conversionResult = this.listCollectionfilter.getList().get(0); }
/** * This method prepares the test setup. * * @throws IllegalStateException * If something went wrong during the test setup (should not happen). * @throws AnalysisConfigurationException * If something went wrong during the test setup (should not happen). */ @Before public void before() throws IllegalStateException, AnalysisConfigurationException { this.analysisController = new AnalysisController(); this.countingFilter = new CountingFilter(new Configuration(), this.analysisController); this.simpleListReader = new ListReader<Object>(new Configuration(), this.analysisController); this.analysisController.connect(this.simpleListReader, ListReader.OUTPUT_PORT_NAME, this.countingFilter, CountingFilter.INPUT_PORT_NAME_EVENTS); }
final ListReader<NamedDoubleTimeSeriesPoint> theReaderAggregator = new ListReader<>(readerAggregationConfiguration, controller); theReaderAggregator.addObject(new NamedDoubleTimeSeriesPoint(664L, 1000.0, OP_SIGNATURE_A)); theReaderAggregator.addObject(new NamedDoubleTimeSeriesPoint(665L, 2000.0, OP_SIGNATURE_A)); theReaderAggregator.addObject(new NamedDoubleTimeSeriesPoint(664L, 1000.0, OP_SIGNATURE_C)); theReaderAggregator.addObject(new NamedDoubleTimeSeriesPoint(668L, 5500.0, OP_SIGNATURE_C)); theReaderAggregator.addObject(new NamedDoubleTimeSeriesPoint(674L, 2000.0, OP_SIGNATURE_B)); theReaderAggregator.addObject(new NamedDoubleTimeSeriesPoint(674L, 3000.0, OP_SIGNATURE_A)); theReaderAggregator.addObject(new NamedDoubleTimeSeriesPoint(684L, 4000.0, OP_SIGNATURE_A)); theReaderAggregator.addObject(new NamedDoubleTimeSeriesPoint(674L, 2000.0, OP_SIGNATURE_C)); theReaderAggregator.addObject(new NamedDoubleTimeSeriesPoint(684L, 5000.0, OP_SIGNATURE_B)); theReaderAggregator.addObject(new NamedDoubleTimeSeriesPoint(687L, 1000.0, OP_SIGNATURE_B)); theReaderAggregator.addObject(new NamedDoubleTimeSeriesPoint(714L, 6000.0, OP_SIGNATURE_A)); theReaderAggregator.addObject(new NamedDoubleTimeSeriesPoint(724L, 7000.0, OP_SIGNATURE_A)); theReaderAggregator.addObject(new NamedDoubleTimeSeriesPoint(694L, 5000.0, OP_SIGNATURE_B)); theReaderAggregator.addObject(new NamedDoubleTimeSeriesPoint(714L, 5000.0, OP_SIGNATURE_B));
private void executeAnalysis(final File tempFile, final boolean append, final List<Integer> objectsToWrite) throws IllegalStateException, AnalysisConfigurationException { final Configuration configuration = new Configuration(); configuration.setProperty(TeeFilter.CONFIG_PROPERTY_NAME_APPEND, Boolean.toString(append)); configuration.setProperty(TeeFilter.CONFIG_PROPERTY_NAME_STREAM, tempFile.getAbsolutePath()); final IAnalysisController analysisController = new AnalysisController(); final TeeFilter teeFilter = new TeeFilter(configuration, analysisController); final ListReader<Integer> simpleListReader = new ListReader<Integer>(new Configuration(), analysisController); analysisController.connect(simpleListReader, ListReader.OUTPUT_PORT_NAME, teeFilter, TeeFilter.INPUT_PORT_NAME_EVENTS); simpleListReader.addAllObjects(objectsToWrite); analysisController.run(); }
/** * A simple test for the counting filter. * * @throws IllegalStateException * If the test setup is somehow invalid (should not happen). * @throws AnalysisConfigurationException * If the test setup is somehow invalid (should not happen). */ @Test public void testNormal() throws IllegalStateException, AnalysisConfigurationException { this.simpleListReader.addObject(new Object()); this.simpleListReader.addObject(new Object()); this.simpleListReader.addObject(new Object()); Assert.assertEquals(0, this.countingFilter.getMessageCount()); this.analysisController.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, this.analysisController.getState()); Assert.assertEquals(3, this.countingFilter.getMessageCount()); }
/** * 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 void runTestFailed(final TraceEventRecords records, final long maxTraceDuration, final long maxTraceTimeout) throws IllegalStateException, AnalysisConfigurationException { final IAnalysisController controller = new AnalysisController(); final ListReader<Object> reader = new ListReader<>(new Configuration(), controller); final Configuration configuration = new Configuration(); configuration.setProperty(EventRecordTraceReconstructionFilter.CONFIG_PROPERTY_NAME_MAX_TRACE_DURATION, Long.toString(maxTraceDuration)); configuration.setProperty(EventRecordTraceReconstructionFilter.CONFIG_PROPERTY_NAME_MAX_TRACE_TIMEOUT, Long.toString(maxTraceTimeout)); final EventRecordTraceReconstructionFilter traceFilter = new EventRecordTraceReconstructionFilter(configuration, controller); final ListCollectionFilter<TraceEventRecords> sinkPlugin = new ListCollectionFilter<>(new Configuration(), controller); Assert.assertTrue(sinkPlugin.getList().isEmpty()); controller.connect(reader, ListReader.OUTPUT_PORT_NAME, traceFilter, EventRecordTraceReconstructionFilter.INPUT_PORT_NAME_TRACE_RECORDS); controller.connect(traceFilter, EventRecordTraceReconstructionFilter.OUTPUT_PORT_NAME_TRACE_VALID, sinkPlugin, ListCollectionFilter.INPUT_PORT_NAME); reader.addObject(records.getTraceMetadata()); for (final AbstractTraceEvent e : records.getTraceEvents()) { reader.addObject(e); } controller.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, controller.getState()); // Make sure that no trace is generated Assert.assertEquals("There should be no trace", 0, sinkPlugin.getList().size()); }
@Test public void testIt() throws Exception { final AbstractTraceProcessingFilter filter = this.provideWriterFilter(this.outputFile.getAbsolutePath(), this.analysisController); final ListReader<Object> reader = new ListReader<Object>(new Configuration(), this.analysisController); final List<Object> eventList = this.createTraces(); reader.addAllObjects(eventList); this.analysisController.connect(reader, ListReader.OUTPUT_PORT_NAME, filter, this.provideFilterInputName()); this.analysisController.connect(filter, AbstractTraceAnalysisFilter.REPOSITORY_PORT_NAME_SYSTEM_MODEL, this.modelRepo); this.analysisController.run(); final String actualFileContent = StringUtils.readOutputFileAsString(this.outputFile); final String expectedFileContent = this.provideExpectedFileContent(eventList); Assert.assertEquals("Unexpected file content", expectedFileContent, actualFileContent); }
public ExecRecordTransformationFilterChecker(final List<OperationExecutionRecord> records) throws IllegalStateException, AnalysisConfigurationException { for (final OperationExecutionRecord record : records) { // the reader will provide these records via its output port this.listReader.addObject(record); } this.analysisController.connect(this.listReader, ListReader.OUTPUT_PORT_NAME, this.execRecFilter, ExecutionRecordTransformationFilter.INPUT_PORT_NAME_RECORDS); this.analysisController.connect(this.execRecFilter, ExecutionRecordTransformationFilter.OUTPUT_PORT_NAME_EXECUTIONS, this.sinkPlugin, ExecutionSinkClass.INPUT_PORT_NAME); this.analysisController.connect(this.execRecFilter, AbstractTraceAnalysisFilter.REPOSITORY_PORT_NAME_SYSTEM_MODEL, this.systemModelRepository); }
this.simpleListReader = new ListReader<>(readerConfiguration, this.analysisController);
private void runTestFailedInterleaved(final TraceEventRecords trace1, final TraceEventRecords trace2, final long maxTraceDuration, final long maxTraceTimeout) throws IllegalStateException, AnalysisConfigurationException { final IAnalysisController controller = new AnalysisController(); final ListReader<Object> reader = new ListReader<>(new Configuration(), controller); final Configuration configuration = new Configuration(); configuration.setProperty(EventRecordTraceReconstructionFilter.CONFIG_PROPERTY_NAME_MAX_TRACE_DURATION, Long.toString(maxTraceDuration)); configuration.setProperty(EventRecordTraceReconstructionFilter.CONFIG_PROPERTY_NAME_MAX_TRACE_TIMEOUT, Long.toString(maxTraceTimeout)); final EventRecordTraceReconstructionFilter traceFilter = new EventRecordTraceReconstructionFilter(configuration, controller); final ListCollectionFilter<TraceEventRecords> sinkPlugin = new ListCollectionFilter<>(new Configuration(), controller); Assert.assertTrue(sinkPlugin.getList().isEmpty()); final ListCollectionFilter<TraceEventRecords> sinkPluginFailed = new ListCollectionFilter<>(new Configuration(), controller); Assert.assertTrue(sinkPluginFailed.getList().isEmpty()); controller.connect(reader, ListReader.OUTPUT_PORT_NAME, traceFilter, EventRecordTraceReconstructionFilter.INPUT_PORT_NAME_TRACE_RECORDS); controller.connect(traceFilter, EventRecordTraceReconstructionFilter.OUTPUT_PORT_NAME_TRACE_VALID, sinkPlugin, ListCollectionFilter.INPUT_PORT_NAME); controller.connect(traceFilter, EventRecordTraceReconstructionFilter.OUTPUT_PORT_NAME_TRACE_INVALID, sinkPluginFailed, ListCollectionFilter.INPUT_PORT_NAME); reader.addObject(trace1.getTraceMetadata()); reader.addObject(trace2.getTraceMetadata()); final AbstractTraceEvent[] events1 = trace1.getTraceEvents(); final AbstractTraceEvent[] events2 = trace2.getTraceEvents(); for (int i = 0; i < events1.length; i++) { reader.addObject(events1[i]); reader.addObject(events2[i]); } controller.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, controller.getState()); // Make sure that only one of the two traces is generated Assert.assertEquals("There should be no trace", 1, sinkPlugin.getList().size()); }
/** * 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); }
/** * A simple test for the counting filter using objects of different classes. * * @throws IllegalStateException * If the test setup is somehow invalid (should not happen). * @throws AnalysisConfigurationException * If the test setup is somehow invalid (should not happen). */ @Test public void testDifferentClasses() throws IllegalStateException, AnalysisConfigurationException { this.simpleListReader.addObject(Long.valueOf(10)); this.simpleListReader.addObject(null); this.simpleListReader.addObject(""); Assert.assertEquals(0, this.countingFilter.getMessageCount()); this.analysisController.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, this.analysisController.getState()); Assert.assertEquals(2, this.countingFilter.getMessageCount()); } }
this.simpleListReader = new ListReader<>(new Configuration(), this.analysisController);
final ListReader<Object> reader = new ListReader<Object>(new Configuration(), controller); final TypeFilter typeFilter = new TypeFilter(typeFilterConfiguration, controller); final ListCollectionFilter<Object> sinkPluginValidElements = new ListCollectionFilter<Object>(new Configuration(), controller); reader.addObject(MATCHING_OBJECTS[i]); reader.addObject(MISMATCHING_OBJECTS[i]);