/** * This method sends a given records directly to the output port. * * @param rec * The new record object. * @return true if and only if the record has been delivered. */ @Override public boolean newMonitoringRecord(final IMonitoringRecord rec) { return super.deliver(OUTPUT_PORT_NAME_RECORDS, rec); }
@Override public void run() { try { if (!reader.read()) { // here we started and won't throw any exceptions! LOG.error("Calling read() on Reader '{}' ({}) returned false.", reader.getName(), reader.getPluginName()); AnalysisController.this.terminate(true); } } catch (final Throwable t) { // NOPMD NOCS (we also want errors) LOG.error("Exception while reading on Reader '{}' ({}).", reader.getName(), reader.getPluginName(), t); AnalysisController.this.terminate(true); } finally { readerLatch.countDown(); } } }).start();
@Override public boolean init() { this.tcpStringRecordReaderThread = new Thread(this.tcpStringRecordReader); // BETTER move to ctor this.tcpStringRecordReaderThread.start(); return super.init(); }
if (!reader.areAllRepositoryPortsConnected()) { this.terminate(true); throw new AnalysisConfigurationException("Reader '" + reader.getName() + "' (" + reader.getPluginName() + ") has unconnected repositories."); if (!reader.start()) { this.terminate(true); throw new AnalysisConfigurationException("Reader '" + reader.getName() + "' (" + reader.getPluginName() + ") failed to initialize.");
/** * Registers the given reader with this analysis instance. <b>This method is for internal use only!</b> * * @param reader * The reader to register with this analysis. * * @throws IllegalStateException * If the analysis has already been started when this method is called. */ public final void registerReader(final AbstractReaderPlugin reader) throws IllegalStateException { if (this.state != STATE.READY) { throw new IllegalStateException("Unable to register filter after starting analysis."); } if (this.readers.contains(reader)) { LOG.warn("Reader {} already registered.", reader.getName()); return; } this.readers.add(reader); LOG.debug("Registered reader {}", reader); }
reader.shutdown(error);
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); } } }; }
if (!reader.areAllRepositoryPortsConnected()) { this.terminate(true); throw new AnalysisConfigurationException("Reader '" + reader.getName() + "' (" + reader.getPluginName() + ") has unconnected repositories."); if (!reader.start()) { this.terminate(true); throw new AnalysisConfigurationException("Reader '" + reader.getName() + "' (" + reader.getPluginName() + ") failed to initialize.");
/** * Registers the given reader with this analysis instance. <b>This method is for internal use only!</b> * * @param reader * The reader to register with this analysis. * * @throws IllegalStateException * If the analysis has already been started when this method is called. */ public final void registerReader(final AbstractReaderPlugin reader) throws IllegalStateException { if (this.state != STATE.READY) { throw new IllegalStateException("Unable to register filter after starting analysis."); } if (this.readers.contains(reader)) { LOG.warn("Reader " + reader.getName() + " already registered."); return; } this.readers.add(reader); if (LOG.isDebugEnabled()) { LOG.debug("Registered reader " + reader); } }
reader.shutdown(error);
/** * This method sends a given records directly to the output port. * * @param rec * The new record object. * @return true if and only if the record has been delivered. */ @Override public boolean newMonitoringRecord(final IMonitoringRecord rec) { return super.deliver(OUTPUT_PORT_NAME_RECORDS, rec); }
@Override public void run() { try { if (!reader.read()) { // here we started and won't throw any exceptions! LOG.error("Calling read() on Reader '" + reader.getName() + "' (" + reader.getPluginName() + ") returned false."); AnalysisController.this.terminate(true); } } catch (final Throwable t) { // NOPMD NOCS (we also want errors) LOG.error("Exception while reading on Reader '" + reader.getName() + "' (" + reader.getPluginName() + ").", t); AnalysisController.this.terminate(true); } finally { readerLatch.countDown(); } } }).start();
@Override public boolean init() { this.tcpStringRecordReaderThread = new Thread(this.tcpStringRecordReader); // BETTER move to ctor this.tcpStringRecordReaderThread.start(); return super.init(); }
@Override public void onRecordReceived(final IMonitoringRecord record) { super.deliver(OUTPUT_PORT_NAME_RECORDS, record); }
@Override public boolean init() { // Invoke super init final boolean superInitSuccessful = super.init(); if (!superInitSuccessful) { return false; } // Initialize the reader final Outcome readerInitOutcome = this.initReader(); return readerInitOutcome == Outcome.SUCCESS; }
@Override public void onRecordReceived(final IMonitoringRecord record) { super.deliver(OUTPUT_PORT_NAME_RECORDS, record); }
@Override public boolean init() { // Invoke super init final boolean superInitSuccessful = super.init(); if (!superInitSuccessful) { return false; } // Initialize the reader final Outcome readerInitOutcome = this.initReader(); if (readerInitOutcome != Outcome.SUCCESS) { return false; } return true; }
final boolean deliverIndirect(final String outputPortName, final Object data) { // NOPMD (package visible for inner class) return super.deliver(outputPortName, data); }
@Override public boolean init() { final boolean superInitSucceeded = super.init(); if (!superInitSucceeded) { return false; } // Set up record handlers this.registryRecordHandler = new RegistryRecordHandler(this.stringRegistryLookup); this.regularRecordHandler = new RegularRecordHandler(this, this.stringRegistryLookup); // Set up threads this.registryRecordHandlerThread = new Thread(this.registryRecordHandler); this.registryRecordHandlerThread.setDaemon(true); this.regularRecordHandlerThread = new Thread(this.regularRecordHandler); this.regularRecordHandlerThread.setDaemon(true); return true; }
final boolean deliverIndirect(final String outputPortName, final Object data) { // NOPMD (package visible for inner class) return super.deliver(outputPortName, data); }