Search in sources :

Example 1 with Sender

use of org.komamitsu.fluency.sender.Sender in project fluency by komamitsu.

the class FluencyTest method testIsTerminated.

@Test
public void testIsTerminated() throws IOException, InterruptedException {
    Sender sender = new MockTCPSender(24224);
    TestableBuffer.Config bufferConfig = new TestableBuffer.Config();
    {
        Flusher.Instantiator flusherConfig = new AsyncFlusher.Config();
        Fluency fluency = new Fluency.Builder(sender).setBufferConfig(bufferConfig).setFlusherConfig(flusherConfig).build();
        assertFalse(fluency.isTerminated());
        fluency.close();
        TimeUnit.SECONDS.sleep(1);
        assertTrue(fluency.isTerminated());
    }
    {
        Flusher.Instantiator flusherConfig = new SyncFlusher.Config();
        Fluency fluency = new Fluency.Builder(sender).setBufferConfig(bufferConfig).setFlusherConfig(flusherConfig).build();
        assertFalse(fluency.isTerminated());
        fluency.close();
        TimeUnit.SECONDS.sleep(1);
        assertTrue(fluency.isTerminated());
    }
}
Also used : RetryableSender(org.komamitsu.fluency.sender.RetryableSender) SSLSender(org.komamitsu.fluency.sender.SSLSender) Sender(org.komamitsu.fluency.sender.Sender) TCPSender(org.komamitsu.fluency.sender.TCPSender) MockTCPSender(org.komamitsu.fluency.sender.MockTCPSender) NetworkSender(org.komamitsu.fluency.sender.NetworkSender) MultiSender(org.komamitsu.fluency.sender.MultiSender) MockTCPSender(org.komamitsu.fluency.sender.MockTCPSender) SyncFlusher(org.komamitsu.fluency.flusher.SyncFlusher) AsyncFlusher(org.komamitsu.fluency.flusher.AsyncFlusher) TestableBuffer(org.komamitsu.fluency.buffer.TestableBuffer) Test(org.junit.Test)

Example 2 with Sender

use of org.komamitsu.fluency.sender.Sender in project fluency by komamitsu.

the class FluencyTest method testBufferFullException.

@Test
public void testBufferFullException() throws IOException {
    final CountDownLatch latch = new CountDownLatch(1);
    Sender stuckSender = new StuckSender(latch);
    try {
        PackedForwardBuffer.Config bufferConfig = new PackedForwardBuffer.Config().setChunkInitialSize(64).setMaxBufferSize(256);
        Fluency fluency = new Fluency.Builder(stuckSender).setBufferConfig(bufferConfig).build();
        Map<String, Object> event = new HashMap<String, Object>();
        event.put("name", "xxxx");
        for (int i = 0; i < 7; i++) {
            fluency.emit("tag", event);
        }
        try {
            fluency.emit("tag", event);
            assertTrue(false);
        } catch (BufferFullException e) {
            assertTrue(true);
        }
    } finally {
        latch.countDown();
    }
}
Also used : HashMap(java.util.HashMap) CountDownLatch(java.util.concurrent.CountDownLatch) RetryableSender(org.komamitsu.fluency.sender.RetryableSender) SSLSender(org.komamitsu.fluency.sender.SSLSender) Sender(org.komamitsu.fluency.sender.Sender) TCPSender(org.komamitsu.fluency.sender.TCPSender) MockTCPSender(org.komamitsu.fluency.sender.MockTCPSender) NetworkSender(org.komamitsu.fluency.sender.NetworkSender) MultiSender(org.komamitsu.fluency.sender.MultiSender) PackedForwardBuffer(org.komamitsu.fluency.buffer.PackedForwardBuffer) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 MockTCPSender (org.komamitsu.fluency.sender.MockTCPSender)2 MultiSender (org.komamitsu.fluency.sender.MultiSender)2 NetworkSender (org.komamitsu.fluency.sender.NetworkSender)2 RetryableSender (org.komamitsu.fluency.sender.RetryableSender)2 SSLSender (org.komamitsu.fluency.sender.SSLSender)2 Sender (org.komamitsu.fluency.sender.Sender)2 TCPSender (org.komamitsu.fluency.sender.TCPSender)2 HashMap (java.util.HashMap)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 PackedForwardBuffer (org.komamitsu.fluency.buffer.PackedForwardBuffer)1 TestableBuffer (org.komamitsu.fluency.buffer.TestableBuffer)1 AsyncFlusher (org.komamitsu.fluency.flusher.AsyncFlusher)1 SyncFlusher (org.komamitsu.fluency.flusher.SyncFlusher)1