@Test(expected = IllegalStateException.class) public void testInvalidWriterQueueConfiguration() { final Configuration configuration = new Configuration(); configuration.setProperty(ConfigurationKeys.WRITER_CLASSNAME, "invalid writer queue fully qualified name"); new WriterController(configuration); }
private MonitoringController(final Configuration configuration) { super(configuration); this.stateController = new StateController(configuration); this.samplingController = new SamplingController(configuration); this.jmxController = new JMXController(configuration); this.writerController = new WriterController(configuration); this.stateController.setStateListener(this); this.timeSourceController = new TimeSourceController(configuration); this.probeController = new ProbeController(configuration); this.autoSetLoggingTimestamp = configuration.getBooleanProperty(ConfigurationFactory.AUTO_SET_LOGGINGTSTAMP); }
private MonitoringController(final Configuration configuration) { super(configuration); this.stateController = new StateController(configuration); this.samplingController = new SamplingController(configuration); this.jmxController = new JMXController(configuration); this.tcpController = new TCPController(configuration, this); this.writerController = new WriterController(configuration); this.stateController.setStateListener(this); this.timeSourceController = new TimeSourceController(configuration); this.probeController = new ProbeController(configuration); this.autoSetLoggingTimestamp = configuration.getBooleanProperty(ConfigurationKeys.AUTO_SET_LOGGINGTSTAMP); }
@Test @SuppressFBWarnings("SIC_INNER_SHOULD_BE_STATIC_ANON") // @SuppressFBWarnings("SIC") public void testBlockOnFailedInsertBehavior() throws Exception { final Configuration configuration = new Configuration(); configuration.setProperty(ConfigurationKeys.WRITER_CLASSNAME, DumpWriter.class.getName()); configuration.setProperty(WriterController.PREFIX + WriterController.RECORD_QUEUE_FQN, MpscArrayQueue.class.getName()); configuration.setProperty(WriterController.PREFIX + WriterController.RECORD_QUEUE_SIZE, "1"); configuration.setProperty(WriterController.PREFIX + WriterController.RECORD_QUEUE_INSERT_BEHAVIOR, "1"); final WriterController writerController = new WriterController(configuration); final Thread thread = new Thread(new Runnable() { @Override public void run() { // the first element fits into the queue writerController.newMonitoringRecord(new EmptyRecord()); // the second element exceeds the queue's capacity and triggers // the blocking wait writerController.newMonitoringRecord(new EmptyRecord()); } }); thread.start(); Await.awaitThreadState(thread, State.WAITING, THREAD_STATE_CHANGE_TIMEOUT_IN_MS); writerController.init(); // starts the queue consumer Await.awaitThreadState(thread, State.TERMINATED, THREAD_STATE_CHANGE_TIMEOUT_IN_MS); writerController.cleanup(); // triggers the termination of the queue // consumer writerController.waitForTermination(CONTROLLER_TIMEOUT_IN_MS); Assert.assertThat(writerController.getStateOfMonitoringWriterThread(), CoreMatchers.is(State.TERMINATED)); }