final TimestampFilter timestampFilter = new TimestampFilter(timestampFilterConfiguration, analysisInstance); analysisInstance.connect(lastFilter, lastOutputPortName, timestampFilter, TimestampFilter.INPUT_PORT_NAME_ANY_RECORD); lastFilter = timestampFilter; lastOutputPortName = TimestampFilter.OUTPUT_PORT_NAME_WITHIN_PERIOD; final RealtimeRecordDelayFilter rtFilter = new RealtimeRecordDelayFilter(delayFilterConfiguration, analysisInstance); analysisInstance.connect(lastFilter, lastOutputPortName, rtFilter, RealtimeRecordDelayFilter.INPUT_PORT_NAME_RECORDS); lastFilter = rtFilter; lastOutputPortName = RealtimeRecordDelayFilter.OUTPUT_PORT_NAME_RECORDS; final MonitoringRecordLoggerFilter recordLogger = new MonitoringRecordLoggerFilter(recordLoggerConfig, analysisInstance); analysisInstance.connect(lastFilter, lastOutputPortName, recordLogger, MonitoringRecordLoggerFilter.INPUT_PORT_NAME_RECORD); analysisInstance.run(); } catch (final IllegalStateException e) { LOGGER.error("An error occurred while replaying", e);
/** * Initiates a termination of the executed {@link AnalysisController}. */ public void terminate() { synchronized (this) { this.analysisController.terminate(); } } }
@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 } }
/** * 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()); }
/** * {@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); } }
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); }
analysisController.connect(reader, TCPReader.OUTPUT_PORT_NAME_RECORDS, teeFilter1, TeeFilter.INPUT_PORT_NAME_EVENTS); analysisController.connect(timer, TimeReader.OUTPUT_PORT_NAME_TIMESTAMPS, countingFilter1, AnalysisThroughputFilter.INPUT_PORT_NAME_TIME); analysisController.connect(teeFilter1, TeeFilter.OUTPUT_PORT_NAME_RELAYED_EVENTS, countingFilter1, AnalysisThroughputFilter.INPUT_PORT_NAME_OBJECTS); analysisController.connect(countingFilter1, AnalysisThroughputFilter.OUTPUT_PORT_NAME_THROUGHPUT, teeFilter2, TeeFilter.INPUT_PORT_NAME_EVENTS); } catch (final AnalysisConfigurationException ex) { TestTCPReader.LOGGER.error("Failed to wire the example project.", ex); analysisController.saveToFile(new File(TestTCPReader.KAX_FILENAME)); } catch (final IOException ex) { TestTCPReader.LOGGER.error("Failed to save configuration to {}", TestTCPReader.KAX_FILENAME, ex);
/** * 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()); }
/** * 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()); }
/** * {@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); } }
/** * Creates a {@link TimestampFilter} with the given properties * using the constructor {@link TimestampFilter#TimestampFilter(kieker.common.configuration.Configuration, java.util.Map)}. * * @param ignoreExecutionsBeforeTimestamp * @param ignoreExecutionsAfterTimestamp * @return * @throws AnalysisConfigurationException * If the internally assembled analysis configuration is somehow invalid. * @throws IllegalStateException * If the internal analysis is in an invalid state. */ private void createTimestampFilter(final long ignoreExecutionsBeforeTimestamp, final long ignoreExecutionsAfterTimestamp) throws IllegalStateException, AnalysisConfigurationException { final Configuration cfg = new Configuration(); cfg.setProperty(TimestampFilter.CONFIG_PROPERTY_NAME_IGNORE_BEFORE_TIMESTAMP, Long.toString(ignoreExecutionsBeforeTimestamp)); cfg.setProperty(TimestampFilter.CONFIG_PROPERTY_NAME_IGNORE_AFTER_TIMESTAMP, Long.toString(ignoreExecutionsAfterTimestamp)); final TimestampFilter filter = new TimestampFilter(cfg, this.controller); this.controller.connect(this.reader, ListReader.OUTPUT_PORT_NAME, filter, TimestampFilter.INPUT_PORT_NAME_FLOW); this.controller.connect(filter, TimestampFilter.OUTPUT_PORT_NAME_WITHIN_PERIOD, this.sinkPlugin, ListCollectionFilter.INPUT_PORT_NAME); }
analysisController.connect(reader, FSReader.OUTPUT_PORT_NAME_RECORDS, buffer, StringBufferFilter.INPUT_PORT_NAME_EVENTS); analysisController.connect(buffer, StringBufferFilter.OUTPUT_PORT_NAME_RELAYED_EVENTS, countingFilter1, CountingFilter.INPUT_PORT_NAME_EVENTS); analysisController.connect(countingFilter1, CountingFilter.OUTPUT_PORT_NAME_RELAYED_EVENTS, typeFilter, TypeFilter.INPUT_PORT_NAME_EVENTS); analysisController.connect(typeFilter, TypeFilter.OUTPUT_PORT_NAME_TYPE_MATCH, timestampFilter, TimestampFilter.INPUT_PORT_NAME_FLOW); analysisController.connect(countingFilter1, CountingFilter.OUTPUT_PORT_NAME_COUNT, teeFilter2, TeeFilter.INPUT_PORT_NAME_EVENTS); analysisController.connect(timestampFilter, TimestampFilter.OUTPUT_PORT_NAME_WITHIN_PERIOD, traceIdFilter, TraceIdFilter.INPUT_PORT_NAME_COMBINED); analysisController.connect(traceIdFilter, TraceIdFilter.OUTPUT_PORT_NAME_MATCH, countingFilter2, CountingFilter.INPUT_PORT_NAME_EVENTS); analysisController.connect(countingFilter2, CountingFilter.OUTPUT_PORT_NAME_COUNT, teeFilter3, TeeFilter.INPUT_PORT_NAME_EVENTS); analysisController.connect( countingFilter2, CountingFilter.OUTPUT_PORT_NAME_RELAYED_EVENTS, eventTraceReconstructionFilter, EventRecordTraceReconstructionFilter.INPUT_PORT_NAME_TRACE_RECORDS); analysisController.connect(traceEvents2ExecutionAndMessageTraceFilter, AbstractTraceAnalysisFilter.REPOSITORY_PORT_NAME_SYSTEM_MODEL, traceRepo); analysisController.connect( eventTraceReconstructionFilter, EventRecordTraceReconstructionFilter.OUTPUT_PORT_NAME_TRACE_VALID, traceEvents2ExecutionAndMessageTraceFilter, TraceEventRecords2ExecutionAndMessageTraceFilter.INPUT_PORT_NAME_EVENT_TRACE); analysisController.connect( traceEvents2ExecutionAndMessageTraceFilter, TraceEventRecords2ExecutionAndMessageTraceFilter.OUTPUT_PORT_NAME_MESSAGE_TRACE, teeFilter1, TeeFilter.INPUT_PORT_NAME_EVENTS);
/** * 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()); }
final TimestampFilter timestampFilter = new TimestampFilter(timestampFilterConfiguration, analysisInstance); analysisInstance.connect(lastFilter, lastOutputPortName, timestampFilter, TimestampFilter.INPUT_PORT_NAME_ANY_RECORD); lastFilter = timestampFilter; lastOutputPortName = TimestampFilter.OUTPUT_PORT_NAME_WITHIN_PERIOD; final RealtimeRecordDelayFilter rtFilter = new RealtimeRecordDelayFilter(delayFilterConfiguration, analysisInstance); analysisInstance.connect(lastFilter, lastOutputPortName, rtFilter, RealtimeRecordDelayFilter.INPUT_PORT_NAME_RECORDS); lastFilter = rtFilter; lastOutputPortName = RealtimeRecordDelayFilter.OUTPUT_PORT_NAME_RECORDS; final MonitoringRecordLoggerFilter recordLogger = new MonitoringRecordLoggerFilter(recordLoggerConfig, analysisInstance); analysisInstance.connect(lastFilter, lastOutputPortName, recordLogger, MonitoringRecordLoggerFilter.INPUT_PORT_NAME_RECORD); analysisInstance.run(); } catch (final IllegalStateException e) { LOG.error("An error occurred while replaying", e);
@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(); } }
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); } }
this.analysisController.connect(this.simpleListReader, ListReader.OUTPUT_PORT_NAME, monitoringThroughputFilter, MonitoringThroughputFilter.INPUT_PORT_NAME_RECORDS); this.analysisController.connect(monitoringThroughputFilter, MonitoringThroughputFilter.OUTPUT_PORT_NAME_UNCOUNTED_RECORDS, uncountedRecordsCountingFilter, CountingFilter.INPUT_PORT_NAME_EVENTS); this.analysisController.connect(monitoringThroughputFilter, MonitoringThroughputFilter.OUTPUT_PORT_NAME_RELAYED_RECORDS, relayedRecordsCountingFilter, CountingFilter.INPUT_PORT_NAME_EVENTS); this.analysisController.connect(uncountedRecordsCountingFilter, CountingFilter.OUTPUT_PORT_NAME_COUNT, this.sinkPluginUncountedRecords, ListCollectionFilter.INPUT_PORT_NAME); this.analysisController.connect(relayedRecordsCountingFilter, CountingFilter.OUTPUT_PORT_NAME_COUNT, this.sinkPluginRelayedRecords, ListCollectionFilter.INPUT_PORT_NAME); this.analysisController.connect(monitoringThroughputFilter, MonitoringThroughputFilter.OUTPUT_PORT_NAME_THROUGHPUT, this.sinkPluginCount, ListCollectionFilter.INPUT_PORT_NAME);
/** * Initiates a termination of the executed {@link AnalysisController}. */ public void terminate() { synchronized (this) { this.analysisController.terminate(); } } }
/** * 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()); }
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(); }