CollectorController { public void offerEvent(final Event event) throws IOException { if (!acceptEvents.get()) { return; } eventsReceived.incrementAndGet(); try { log.debug("Writing event: {}", event); eventWriter.write(event); } catch (IOException e) { log.error(String.format("Failed to write event: %s", event), e); eventsLost.incrementAndGet(); throw e; } } CollectorController(final EventWriter eventWriter); void offerEvent(final Event event); void close(); void setAcceptEvents(final boolean accept); @Managed(description = "Whether the eventtracker library accepts events") boolean isAcceptEvents(); @Managed(description = "Number of events received") AtomicLong getEventsReceived(); @Managed(description = "Number of events lost (unable to serialize them to disk)") AtomicLong getEventsLost(); @Managed(description = "Promote events to final spool area") void commit(); @Managed(description = "Flush events to remote agent") void flush();  }
@Test(groups = "fast") public void testOfferEvent() throws Exception { controller.offerEvent(event); Assert.assertEquals(controller.getEventsReceived().get(), 1); diskWriter.commit(); Assert.assertEquals(controller.getEventsLost().get(), 0); }