@Test public void receiveEventTest() { buffer.setSendingInterval(1); buffer.receiveEvent(new LoggableEvent("a", "a", "a", new byte[1], "a")); try { Thread.sleep(50); } catch (InterruptedException e) { e.printStackTrace(); } assertEquals(7, sendQueue.size()); verify(sendingTask, atLeastOnce()).run(); }
@Override public void receiveEvent(LoggableEvent event) { if (!settings.isSpywareEnabled()) { return; } synchronized (sendQueue) { if (sendQueue.size() >= maxEvents) { sendQueue.pop(); eventsToRemoveAfterSend.decrementAndGet(); } sendQueue.add(event); maybeAutosend(); } }
EventSendBuffer implements EventReceiver { @Override public void receiveEvent(LoggableEvent event) { if (!settings.isSpywareEnabled()) { return; } synchronized (sendQueue) { if (sendQueue.size() >= maxEvents) { sendQueue.pop(); eventsToRemoveAfterSend.decrementAndGet(); } sendQueue.add(event); maybeAutosend(); } } }
EventSendBuffer implements EventReceiver { @Override public void receiveEvent(LoggableEvent event) { if (!settings.isSpywareEnabled()) { return; } synchronized (sendQueue) { if (sendQueue.size() >= maxEvents) { sendQueue.pop(); eventsToRemoveAfterSend.decrementAndGet(); } sendQueue.add(event); maybeAutosend(); } } EventSendBuffer(EventStore store, Settings settings, ArrayDeque<LoggableEvent> sendQueue,
            SingletonTask sendingTask, SingletonTask savingTask, AtomicInteger eventsToRemoveAfterSend); }
EventSendBuffer implements EventReceiver { @Override public void receiveEvent(LoggableEvent event) { if (!settings.isSpywareEnabled()) { return; } synchronized (sendQueue) { if (sendQueue.size() >= maxEvents) { sendQueue.pop(); eventsToRemoveAfterSend.decrementAndGet(); } sendQueue.add(event); maybeAutosend(); } } EventSendBuffer(EventStore store, Settings settings, ArrayDeque<LoggableEvent> sendQueue,
            SingletonTask sendingTask, SingletonTask savingTask, AtomicInteger eventsToRemoveAfterSend); void setSendingInterval(long interval); void setSavingInterval(long interval); void waitUntilCurrentSendingFinished(long timeout); @Override void receiveEvent(LoggableEvent event); @Override void close(); }
EventSendBuffer implements EventReceiver { @Override public void receiveEvent(LoggableEvent event) { if (!settings.isSpywareEnabled()) { return; } synchronized (sendQueue) { if (sendQueue.size() >= maxEvents) { sendQueue.pop(); eventsToRemoveAfterSend.decrementAndGet(); } sendQueue.add(event); maybeAutosend(); } } EventSendBuffer(EventStore store, Settings settings, ArrayDeque<LoggableEvent> sendQueue,
            SingletonTask sendingTask, SingletonTask savingTask, AtomicInteger eventsToRemoveAfterSend); void setSendingInterval(long interval); void setSavingInterval(long interval); void waitUntilCurrentSendingFinished(long timeout); @Override void receiveEvent(LoggableEvent event); @Override void close(); static final long DEFAULT_SEND_INTERVAL; static final long DEFAULT_SAVE_INTERVAL; static final int DEFAULT_MAX_EVENTS; static final int DEFAULT_AUTOSEND_THREHSOLD; static final int DEFAULT_AUTOSEND_COOLDOWN; }