@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; } }
/** * 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); }
/** * 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()); }
/** * 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); }
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(); }
final ListReader<TraceEventRecords> reader = new ListReader<TraceEventRecords>(readerConfiguration, this.analysisController); reader.addObject(traceEvents);
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 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); }
@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); }
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()); }
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; }
/** * 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); }
@Ignore // NOCS @Test public void testRecordsWithoutStringSame() throws IllegalStateException, AnalysisConfigurationException { final AnalysisController analysisController = new AnalysisController(); final ListReader<IMonitoringRecord> reader = new ListReader<>(new Configuration(), analysisController); final StringBufferFilter stringBufferFilter = new StringBufferFilter(new Configuration(), analysisController); final ListCollectionFilter<IMonitoringRecord> collectionFilter = new ListCollectionFilter<>(new Configuration(), analysisController); analysisController.connect(reader, ListReader.OUTPUT_PORT_NAME, stringBufferFilter, StringBufferFilter.INPUT_PORT_NAME_EVENTS); analysisController.connect(stringBufferFilter, StringBufferFilter.OUTPUT_PORT_NAME_RELAYED_EVENTS, collectionFilter, ListCollectionFilter.INPUT_PORT_NAME); final IMonitoringRecord recordIn1 = new EmptyRecord(); reader.addObject(recordIn1); analysisController.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, analysisController.getState()); final List<IMonitoringRecord> records = collectionFilter.getList(); Assert.assertEquals("Unexpected number of records", 1, records.size()); final IMonitoringRecord recordOut1 = records.get(0); Assert.assertSame("First output record not same as first input record", recordIn1, recordOut1); // includes no String, hence "as-is" }
/** * 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()); }
/** * 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()); } }
/** * Given a {@link TimestampFilter} selecting {@link AbstractTraceEvent}s within an interval <i>[a,b]</i>, * assert that a {@link AbstractTraceEvent} <i>e</i> with <i>e.timestamp < a</i> does not pass the filter. * * @throws AnalysisConfigurationException * If the internally assembled analysis configuration is somehow invalid. * @throws IllegalStateException * If the internal analysis is in an invalid state. */ @Test public void testEventBeforeIgnored() throws IllegalStateException, AnalysisConfigurationException { final long leftBorder = TestTimestampFilter.EVENT.getTimestamp() + 1; final long rightBorder = leftBorder + 1; this.createTimestampFilter(leftBorder, rightBorder); Assert.assertTrue(this.sinkPlugin.getList().isEmpty()); this.reader.addObject(TestTimestampFilter.EVENT); this.controller.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, this.controller.getState()); Assert.assertTrue("Filter passed event " + TestTimestampFilter.EVENT + " although timestamp before " + leftBorder, this.sinkPlugin.getList().isEmpty()); }
/** * Given a {@link TimestampFilter} selecting {@link AbstractTraceEvent}s within an interval <i>[a,b]</i>, * assert that an event <i>e</i> with <i>e.timestamp == a</i> does pass the filter. * * @throws AnalysisConfigurationException * If the internally assembled analysis configuration is somehow invalid. * @throws IllegalStateException * If the internal analysis is in an invalid state. */ @Test public void testRecordOnLeftBorderPasses() throws IllegalStateException, AnalysisConfigurationException { final long leftBorder = TestTimestampFilter.EVENT.getTimestamp(); final long rightBorder = leftBorder + 1; this.createTimestampFilter(leftBorder, rightBorder); Assert.assertTrue(this.sinkPlugin.getList().isEmpty()); this.reader.addObject(TestTimestampFilter.EVENT); this.controller.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, this.controller.getState()); Assert.assertFalse("Filter ignored event " + TestTimestampFilter.EVENT + " although timestamp on left Border " + leftBorder, this.sinkPlugin.getList().isEmpty()); Assert.assertTrue(this.sinkPlugin.getList().size() == 1); Assert.assertSame(this.sinkPlugin.getList().get(0), TestTimestampFilter.EVENT); }
/** * Given a {@link TimestampFilter} selecting {@link AbstractTraceEvent}s within an interval <i>[a,b]</i>, * assert that a {@link AbstractTraceEvent} <i>e</i> with <i>e.timestamp > b </i> does not * pass the filter. * * @throws AnalysisConfigurationException * If the internally assembled analysis configuration is somehow invalid. * @throws IllegalStateException * If the internal analysis is in an invalid state. */ @Test public void testEventAfterIgnored() throws IllegalStateException, AnalysisConfigurationException { final long rightBorder = TestTimestampFilter.EVENT.getTimestamp() - 1; final long leftBorder = rightBorder - 1; this.createTimestampFilter(leftBorder, rightBorder); Assert.assertTrue(this.sinkPlugin.getList().isEmpty()); this.reader.addObject(TestTimestampFilter.EVENT); this.controller.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, this.controller.getState()); Assert.assertTrue("Filter passed event " + TestTimestampFilter.EVENT + " although timestamp before " + leftBorder, this.sinkPlugin.getList().isEmpty()); }
/** * Given a {@link TimestampFilter} selecting {@link AbstractTraceEvent}s within an interval <i>[a,b]</i>, * assert that an event <i>e</i> with <i>e.timestamp == b</i> does pass the filter. * * @throws AnalysisConfigurationException * If the internally assembled analysis configuration is somehow invalid. * @throws IllegalStateException * If the internal analysis is in an invalid state. */ @Test public void testRecordOnRightBorderPasses() throws IllegalStateException, AnalysisConfigurationException { final long rightBorder = TestTimestampFilter.EVENT.getTimestamp(); final long leftBorder = rightBorder - 1; this.createTimestampFilter(leftBorder, rightBorder); Assert.assertTrue(this.sinkPlugin.getList().isEmpty()); this.reader.addObject(TestTimestampFilter.EVENT); this.controller.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, this.controller.getState()); Assert.assertFalse("Filter ignored event " + TestTimestampFilter.EVENT + " although timestamp on right Border " + rightBorder, this.sinkPlugin.getList().isEmpty()); Assert.assertTrue(this.sinkPlugin.getList().size() == 1); Assert.assertSame(this.sinkPlugin.getList().get(0), TestTimestampFilter.EVENT); }
/** * Given a {@link TimestampFilter} selecting {@link AbstractTraceEvent}s within an interval <i>[a,b]</i>, * assert that a {@link AbstractTraceEvent} <i>e</i> with <i>e.timestamp > a</i> and <i>r.timestamp * > a </i> does pass the filter. * * @throws AnalysisConfigurationException * If the internally assembled analysis configuration is somehow invalid. * @throws IllegalStateException * If the internally assembled analysis is in an invalid state. */ @Test public void testRecordTinToutWithinRangePassed() throws IllegalStateException, AnalysisConfigurationException { final long leftBorder = TestTimestampFilter.EVENT.getTimestamp() - 1; final long rightBorder = TestTimestampFilter.EVENT.getTimestamp() + 1; this.createTimestampFilter(leftBorder, rightBorder); Assert.assertTrue(this.sinkPlugin.getList().isEmpty()); this.reader.addObject(TestTimestampFilter.EVENT); this.controller.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, this.controller.getState()); Assert.assertFalse("Filter ignored event " + TestTimestampFilter.EVENT + " although timestamp in interval [" + leftBorder + "," + rightBorder + "]", this.sinkPlugin.getList().isEmpty()); Assert.assertTrue(this.sinkPlugin.getList().size() == 1); Assert.assertSame(this.sinkPlugin.getList().get(0), TestTimestampFilter.EVENT); } }