/** * {@inheritDoc} */ @Override public void run() { try { this.analysisController.run(); this.terminationLatch.countDown(); } catch (final Exception ex) { // NOPMD NOCS (Exception) LOGGER.error("Error running AnalysisController.", ex); } }
/** * {@inheritDoc} */ @Override public void run() { try { this.analysisController.run(); this.terminationLatch.countDown(); } catch (final Exception ex) { // NOPMD NOCS (Exception) LOG.error("Error running AnalysisController.", ex); } }
public static void main(final String[] args) { final IAnalysisController analysisController = new AnalysisController("TCPThroughput"); TestTCPReader.createAndConnectPlugins(analysisController); try { analysisController.run(); } catch (final AnalysisConfigurationException ex) { TestTCPReader.LOGGER.error("Failed to start the example project.", ex); } }
/** * 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); }
public static void main(final String[] args) { final IAnalysisController analysisController; if (TestAnalysis.LOADCONFIG) { try { analysisController = new AnalysisController(new File(TestAnalysis.KAX_FILENAME)); } catch (final IOException ex) { TestAnalysis.LOGGER.error("Failed to load {}", TestAnalysis.KAX_FILENAME, ex); return; } catch (final AnalysisConfigurationException ex) { TestAnalysis.LOGGER.error("Failed to load {}", TestAnalysis.KAX_FILENAME, ex); return; } } else { analysisController = new AnalysisController("TestProject"); TestAnalysis.createAndConnectPlugins(analysisController); } try { analysisController.run(); } catch (final AnalysisConfigurationException ex) { TestAnalysis.LOGGER.error("Failed to start the example project.", ex); } }
/** * Checks whether the expected {@link Execution}s were generated by the * filter. * * @param expectedExecutions * @throws AnalysisConfigurationException * If the internally assembled analysis configuration is somehow invalid. * @throws IllegalStateException * If the internally assembled analysis is in an invalid state. */ public void doTestFilter(final List<Execution> expectedExecutions) throws IllegalStateException, AnalysisConfigurationException { this.analysisController.run(); Assert.assertEquals("Expected sink to contain 1 Execution", expectedExecutions.size(), this.sinkPlugin.getExecutions().size()); final List<Execution> generatedExecutions = this.sinkPlugin.getExecutions(); Assert.assertEquals("Unexpected number of generated executions", expectedExecutions.size(), generatedExecutions.size()); // note that we assume that the records are processed in FIFO order by the filter Assert.assertEquals("Lists of expected and generated executions not equal", expectedExecutions, generatedExecutions); } }
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()); }
/** * 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()); }
@Test public void testNormal() throws IllegalStateException, AnalysisConfigurationException, InterruptedException { final List<Entry<Long, Integer>> eventList = this.passEventListToReader(this.simpleListReader); Assert.assertEquals(0, this.sinkPlugin.size()); this.analysisController.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, this.analysisController.getState()); // Make sure that all events have been provided to the delay filter (otherwise the test make no sense) Assert.assertEquals("Test invalid: Unexpected number of events provided TO the delay filter", eventList.size(), this.countingFilterReader.getMessageCount()); // Make sure that all events have been passed through the delay filter Assert.assertEquals("Unexpected number of events relayed by the delay filter", eventList.size(), this.countingFilterDelayed.getMessageCount()); this.checkTiming(); // Make sure that exactly the right objects have been passed this.checkRelayedRecords(); } }
/** * 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()); }
/** * 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 is a test using only one reader. * * @throws IllegalStateException * If the analysis is in an invalid state (should not happen). * @throws AnalysisConfigurationException * If there is a configuration error in the analysis (should not happen). */ @Test public void testOnlyReader() throws IllegalStateException, AnalysisConfigurationException { final IAnalysisController ctrl = new AnalysisController(); final ShutdownReader r1 = new ShutdownReader(new Configuration(), ctrl); ctrl.run(); Assert.assertEquals(0, r1.shutdownNr); Assert.assertEquals(AnalysisController.STATE.TERMINATED, ctrl.getState()); }
/** * 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()); }
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()); }
@Ignore // NOCS @Test public void testRecords() throws IOException, IllegalStateException, AnalysisConfigurationException { final IAnalysisController analysisController = new AnalysisController(); final Configuration configurationFSReader = new Configuration(); configurationFSReader.setProperty(FSReader.CONFIG_PROPERTY_NAME_INPUTDIRS, this.tmpFolder.getRoot().getCanonicalPath()); final FSReader reader = new FSReader(configurationFSReader, analysisController); final CountingFilter sink = new CountingFilter(new Configuration(), analysisController); analysisController.connect(reader, FSReader.OUTPUT_PORT_NAME_RECORDS, sink, CountingFilter.INPUT_PORT_NAME_EVENTS); analysisController.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, analysisController.getState()); Assert.assertEquals(5L, sink.getMessageCount()); // 5 records are expected } }
/** * This is a test using one reader and one filter. * * @throws IllegalStateException * If the analysis is in an invalid state (should not happen). * @throws AnalysisConfigurationException * If there is a configuration error in the analysis (should not happen). */ @Test public void testReaderWithUnconnectedFilter() throws IllegalStateException, AnalysisConfigurationException { final IAnalysisController ctrl = new AnalysisController(); final ShutdownReader r1 = new ShutdownReader(new Configuration(), ctrl); final ShutdownFilter f1 = new ShutdownFilter(new Configuration(), ctrl); ctrl.run(); Assert.assertEquals(0, r1.shutdownNr); Assert.assertEquals(1, f1.shutdownNr); Assert.assertEquals(AnalysisController.STATE.TERMINATED, ctrl.getState()); }
/** * This is a test using only one reader connected with one filter. * * @throws IllegalStateException * If the analysis is in an invalid state (should not happen). * @throws AnalysisConfigurationException * If there is a configuration error in the analysis (should not happen). */ @Test public void testReaderWithConnectedFilter() throws IllegalStateException, AnalysisConfigurationException { final IAnalysisController ctrl = new AnalysisController(); final ShutdownReader r1 = new ShutdownReader(new Configuration(), ctrl); final ShutdownFilter f1 = new ShutdownFilter(new Configuration(), ctrl); ctrl.connect(r1, ShutdownReader.OUTPUT_PORT_NAME, f1, ShutdownFilter.INPUT_PORT_NAME); ctrl.run(); Assert.assertEquals(0, r1.shutdownNr); Assert.assertEquals(1, f1.shutdownNr); Assert.assertEquals(AnalysisController.STATE.TERMINATED, ctrl.getState()); }
/** * This is a test using two readers and one filter. * * @throws IllegalStateException * If the analysis is in an invalid state (should not happen). * @throws AnalysisConfigurationException * If there is a configuration error in the analysis (should not happen). */ @Test public void testTwoReadersOneFilter() throws IllegalStateException, AnalysisConfigurationException { final IAnalysisController ctrl = new AnalysisController(); final ShutdownReader r1 = new ShutdownReader(new Configuration(), ctrl); final ShutdownReader r2 = new ShutdownReader(new Configuration(), ctrl); final ShutdownFilter f1 = new ShutdownFilter(new Configuration(), ctrl); ctrl.connect(r1, ShutdownReader.OUTPUT_PORT_NAME, f1, ShutdownFilter.INPUT_PORT_NAME); ctrl.connect(r2, ShutdownReader.OUTPUT_PORT_NAME, f1, ShutdownFilter.INPUT_PORT_NAME); ctrl.run(); Assert.assertEquals(0, r1.shutdownNr); Assert.assertEquals(1, r2.shutdownNr); Assert.assertEquals(2, f1.shutdownNr); Assert.assertEquals(AnalysisController.STATE.TERMINATED, ctrl.getState()); }
/** * This test would have more than one correct answer! * * @throws IllegalStateException * If the internally assembled analysis is in an invalid state. * @throws AnalysisConfigurationException * If the internally assembled analysis configuration is somehow invalid. */ @Test public void testLoop() throws IllegalStateException, AnalysisConfigurationException { final IAnalysisController ctrl = new AnalysisController(); final ShutdownReader r1 = new ShutdownReader(new Configuration(), ctrl); final ShutdownFilter f1 = new ShutdownFilter(new Configuration(), ctrl); final ShutdownFilter f2 = new ShutdownFilter(new Configuration(), ctrl); ctrl.connect(r1, ShutdownReader.OUTPUT_PORT_NAME, f1, ShutdownFilter.INPUT_PORT_NAME); ctrl.connect(f1, ShutdownFilter.OUTPUT_PORT_NAME, f2, ShutdownFilter.INPUT_PORT_NAME); ctrl.connect(f2, ShutdownFilter.OUTPUT_PORT_NAME, f1, ShutdownFilter.INPUT_PORT_NAME); ctrl.run(); Assert.assertEquals(0, r1.shutdownNr); Assert.assertEquals(1, f2.shutdownNr); Assert.assertEquals(2, f1.shutdownNr); Assert.assertEquals(AnalysisController.STATE.TERMINATED, ctrl.getState()); }