/** * Creates an instance of this class. */ public ForecastingFilterTest() { this.controller = new AnalysisController(); }
private static <P extends AbstractPlugin & IGraphOutputtingFilter<?>> void connectGraphFilters(final P predecessor, final AbstractGraphFilter<?, ?, ?, ?> filter, final AnalysisController controller) throws IllegalStateException, AnalysisConfigurationException { controller.connect(predecessor, predecessor.getGraphOutputPortName(), filter, filter.getGraphInputPortName()); }
@Override protected boolean performTask() { boolean success = false; try { new AnalysisController(new File(this.kaxFilename)).run(); success = true; } catch (final IOException ex) { LOGGER.error("The given file could not be loaded", ex); } catch (final AnalysisConfigurationException ex) { LOGGER.error("The given configuration file is invalid", ex); } catch (final Exception ex) { // NOPMD NOCS (log all errors) LOGGER.error("Error", ex); } return success; }
/** * {@inheritDoc} */ @Override public final void saveToFile(final File file) throws IOException, AnalysisConfigurationException { final MIProject mProject = this.getCurrentConfiguration(); AnalysisController.saveToFile(file, mProject); }
this.analysisController.run(); if (this.analysisController.getState() != AnalysisController.STATE.TERMINATED) { this.analysisController.getState()); try { // NOCS (nested try) this.analysisController.saveToFile(kaxOutputFile); this.logger.info("Saved analysis configuration to file '{}'", kaxOutputFile.getCanonicalPath()); } catch (final IOException ex) {
public List<IMonitoringRecord> runAnalysis(final File workingDirectory) throws IllegalStateException, AnalysisConfigurationException { final File[] directories = workingDirectory.listFiles(FILE_FILTER); if (null == directories) { return Collections.emptyList(); } final Configuration conf = new Configuration(); final AnalysisController analysisController = new AnalysisController(); try { conf.setProperty(AsciiLogReader.CONFIG_PROPERTY_NAME_INPUTDIRS, Configuration.toProperty(directories)); final AsciiLogReader reader = new AsciiLogReader(conf, analysisController); final ListCollectionFilter<IMonitoringRecord> collectionSink = new ListCollectionFilter<>( new Configuration(), analysisController); analysisController.connect(reader, AsciiLogReader.OUTPUT_PORT_NAME_RECORDS, collectionSink, ListCollectionFilter.INPUT_PORT_NAME); analysisController.run(); return collectionSink.getList(); } finally { this.deleteTempoararyFiles(directories); } }
private List<IMonitoringRecord> readLog(final String[] monitoringLogDirs) throws AnalysisConfigurationException { final AnalysisController analysisController = new AnalysisController(); final Configuration readerConfiguration = new Configuration(); readerConfiguration.setProperty(AsciiLogReader.CONFIG_PROPERTY_NAME_INPUTDIRS, Configuration.toProperty(monitoringLogDirs)); readerConfiguration.setProperty(AsciiLogReader.CONFIG_PROPERTY_NAME_IGNORE_UNKNOWN_RECORD_TYPES, "false"); final AbstractReaderPlugin reader = new AsciiLogReader(readerConfiguration, analysisController); final ListCollectionFilter<IMonitoringRecord> sinkPlugin = new ListCollectionFilter<>(new Configuration(), analysisController); analysisController.connect(reader, AsciiLogReader.OUTPUT_PORT_NAME_RECORDS, sinkPlugin, ListCollectionFilter.INPUT_PORT_NAME); analysisController.run(); Assert.assertEquals(AnalysisController.STATE.TERMINATED, analysisController.getState()); return sinkPlugin.getList(); } }
public TestAnalysis(final Configuration configuration, final Class<? extends AbstractReaderPlugin> readerClass) throws Exception { this.analysisController = new AnalysisController(); final AbstractReaderPlugin reader = this.newReader(readerClass, configuration, this.analysisController); final String outputPortName = reader.getAllOutputPortNames()[0]; this.sinkPlugin = new ListCollectionFilter<IMonitoringRecord>(new Configuration(), this.analysisController); this.analysisController.connect(reader, outputPortName, this.sinkPlugin, ListCollectionFilter.INPUT_PORT_NAME); this.thread = new Thread("TestAnalysis thread") { @Override public void run() { try { TestAnalysis.this.getAnalysisController().run(); } catch (IllegalStateException | AnalysisConfigurationException e) { throw new IllegalStateException("Should never happen", e); } } }; }
public void testNumberOfEmittedSignals() throws InterruptedException, IllegalStateException, AnalysisConfigurationException { final AnalysisController ac = new AnalysisController(); final AnalysisControllerThread thread = new AnalysisControllerThread(ac); final CountingFilter cf = new CountingFilter(new Configuration(), ac); ac.connect(tr, TimeReader.OUTPUT_PORT_NAME_TIMESTAMP_RECORDS, cf, CountingFilter.INPUT_PORT_NAME_EVENTS); ac.terminate();
this.analysisController.connect(reader, FSReader.OUTPUT_PORT_NAME_RECORDS, stringBufferFilter, StringBufferFilter.INPUT_PORT_NAME_EVENTS); final ThreadEvent2TraceEventFilter threadEvent2TraceEventFilter = new ThreadEvent2TraceEventFilter(config, this.analysisController); this.analysisController.connect(sourceStage, sourcePort, threadEvent2TraceEventFilter, ThreadEvent2TraceEventFilter.INPUT_PORT_NAME_DEFAULT); this.analysisController.connect(sourceStage, sourcePort, timestampFilter, TimestampFilter.INPUT_PORT_NAME_EXECUTION); this.analysisController.connect(sourceStage, sourcePort, timestampFilter, TimestampFilter.INPUT_PORT_NAME_FLOW); this.analysisController.connect(timestampFilter, TimestampFilter.OUTPUT_PORT_NAME_WITHIN_PERIOD, traceIdFilter, TraceIdFilter.INPUT_PORT_NAME_COMBINED); this.analysisController); if (this.invertTraceIdFilter) { this.analysisController.connect(traceIdFilter, TraceIdFilter.OUTPUT_PORT_NAME_MISMATCH, execRecTransformer, ExecutionRecordTransformationFilter.INPUT_PORT_NAME_RECORDS); } else { this.analysisController.connect(traceIdFilter, TraceIdFilter.OUTPUT_PORT_NAME_MATCH, execRecTransformer, ExecutionRecordTransformationFilter.INPUT_PORT_NAME_RECORDS); this.analysisController.connect(execRecTransformer, AbstractTraceAnalysisFilter.REPOSITORY_PORT_NAME_SYSTEM_MODEL, systemEntityFactory); Boolean.toString(this.ignoreInvalidTraces)); mtReconstrFilter = new TraceReconstructionFilter(mtReconstrFilterConfig, this.analysisController);
@Test public void testNamedPipeReaderReceivesFromPipe() throws IllegalStateException, AnalysisConfigurationException { final AnalysisController analysis = new AnalysisController(); analysis.connect(pipeReader, PipeReader.OUTPUT_PORT_NAME_RECORDS, countingFilter, CountingFilter.INPUT_PORT_NAME_EVENTS); Assert.assertEquals(AnalysisController.STATE.TERMINATED, analysis.getState());
/** * Tests the "blocking" mode of the reader. * * @throws InterruptedException * If the thread is interrupted. This should not happen. */ @SuppressWarnings("unused") @Test public void testBlockingMode() throws InterruptedException { final AnalysisController ac = new AnalysisController(); final AnalysisControllerThread thread = new AnalysisControllerThread(ac); final Configuration configuration = new Configuration(); configuration.setProperty(TimeReader.CONFIG_PROPERTY_NAME_NUMBER_IMPULSES, Long.toString(TimeReader.INFINITE_EMITS)); new TimeReader(configuration, ac); // We expect that the reader doesn't return immediately - in this case we expect the AC to run at least five seconds thread.start(); Thread.sleep(5000); Assert.assertEquals(STATE.RUNNING, ac.getState()); ac.terminate(); }
@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); }
/** * Tests the "non blocking" mode of the reader. * * @throws InterruptedException * If the thread is interrupted. This should not happen. */ @SuppressWarnings("unused") @Test public void testNonBlockingMode() throws InterruptedException { final AnalysisController ac = new AnalysisController(); final AnalysisControllerThread thread = new AnalysisControllerThread(ac); final Configuration configuration = new Configuration(); configuration.setProperty(TimeReader.CONFIG_PROPERTY_NAME_NUMBER_IMPULSES, "1"); configuration.setProperty(TimeReader.CONFIG_PROPERTY_NAME_DELAY_NS, "0"); configuration.setProperty(TimeReader.CONFIG_PROPERTY_NAME_UPDATE_INTERVAL_NS, "1000000000"); new TimeReader(configuration, ac); // We expect the reader to return very fast - in this case we expect the AC to return within five seconds thread.start(); Thread.sleep(6000); Assert.assertEquals(STATE.TERMINATED, ac.getState()); }
@Override protected void checkControllerStateBeforeRecordsPassedToController(final IMonitoringController monitoringController) throws Exception { Assert.assertTrue(monitoringController.isMonitoringEnabled()); Assert.assertEquals(AnalysisController.STATE.RUNNING, this.analysisController.getState()); }
/** * Runs the setup by starting the enclosed analysis controller. * * @throws AnalysisConfigurationException * If an invalid configuration is detected */ public void run() throws AnalysisConfigurationException { this.analysisController.run(); }
this.notifyStateObservers(); this.terminate(true); throw new AnalysisConfigurationException("No log reader registered."); this.terminate(true); throw new AnalysisConfigurationException("Reader '" + reader.getName() + "' (" + reader.getPluginName() + ") has unconnected repositories."); this.terminate(true); throw new AnalysisConfigurationException("Reader '" + reader.getName() + "' (" + reader.getPluginName() + ") failed to initialize."); this.terminate(true); throw new AnalysisConfigurationException("Plugin '" + filter.getName() + "' (" + filter.getPluginName() + ") has unconnected repositories."); this.terminate(true); throw new AnalysisConfigurationException("Plugin '" + filter.getName() + "' (" + filter.getPluginName() + ") failed to initialize."); this.terminate();
/** * {@inheritDoc} */ @Override public final void terminate() { this.terminate(false); }
/** * This constructors creates an {@link AnalysisController} instance, using the given file to load an analysis model and the given classloader to initialize the * objects. The given file should therefore be an instance of the analysis meta model. * * @param file * The configuration file for the analysis. * @param classLoader * The classloader used to initialize the plugins etc. * * @throws IOException * If the given file could not be loaded or is not a valid kax-configuration file. * @throws AnalysisConfigurationException * If one or more plugins or repositories could not be created, one or * more properties of the plugins are invalid or if a connection between two filters is not allowed. */ public AnalysisController(final File file, final ClassLoader classLoader) throws IOException, AnalysisConfigurationException { this(AnalysisController.loadFromFile(file), classLoader); }
/** * {@inheritDoc} */ @Override public final void saveToFile(final String pathname) throws IOException, AnalysisConfigurationException { this.saveToFile(new File(pathname)); }