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());
}
}
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();
}
}
Aggregations