/** * {@inheritDoc} */ @Override public final void terminate() { this.terminate(false); }
/** * {@inheritDoc} */ @Override public final void terminate() { this.terminate(false); }
@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 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();
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();
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();
/** * 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(); }
/** * This test should make sure that the timer delivers a correct amount of records within a given limit. * * @throws InterruptedException * If the test thread is interrupted. * @throws IllegalStateException * If the analysis is in the wrong state. * @throws AnalysisConfigurationException * If the analysis is somehow invalid configured. */ @Test public void testIntervalTimer() throws InterruptedException, IllegalStateException, AnalysisConfigurationException { // Running 5 seconds, firing one event per 100 ms, we expect to receive approx. 50 events. final AnalysisController ac = new AnalysisController(); final AnalysisControllerThread thread = new AnalysisControllerThread(ac); final Configuration configuration = new Configuration(); configuration.setProperty(TimeReader.CONFIG_PROPERTY_NAME_UPDATE_INTERVAL_NS, "100000000"); final TimeReader tr = new TimeReader(configuration, ac); final CountingFilter cf = new CountingFilter(new Configuration(), ac); ac.connect(tr, TimeReader.OUTPUT_PORT_NAME_TIMESTAMP_RECORDS, cf, CountingFilter.INPUT_PORT_NAME_EVENTS); thread.start(); Thread.sleep(5000); ac.terminate(); Assert.assertTrue(cf.getMessageCount() > 40); Assert.assertTrue(cf.getMessageCount() < 60); }