MockHDFSWriter hdfsWriter = new MockHDFSWriter();
BucketWriter bucketWriter = new BucketWriter(ROLL_INTERVAL, 0, 0, 0, ctx,
"/tmp", "file", "", ".tmp", null, null, SequenceFile.CompressionType.NONE,
hdfsWriter, timedRollerPool, null,
new SinkCounter("test-bucket-writer-" + System.currentTimeMillis()),
0, new HDFSEventSink.WriterCallback() {
@Override
public void run(String filePath) {
calledBack.set(true);
}
}, null, 30000, Executors.newSingleThreadExecutor(), 0, 0);
Event e = EventBuilder.withBody("foo", Charsets.UTF_8);
long startNanos = System.nanoTime();
for (int i = 0; i < NUM_EVENTS - 1; i++) {
bucketWriter.append(e);
}
// sleep to force a roll... wait 2x interval just to be sure
Thread.sleep(2 * ROLL_INTERVAL * 1000L);
Assert.assertTrue(bucketWriter.closed);
Assert.assertTrue(calledBack.get());
bucketWriter = new BucketWriter(ROLL_INTERVAL, 0, 0, 0, ctx,
"/tmp", "file", "", ".tmp", null, null, SequenceFile.CompressionType.NONE,
hdfsWriter, timedRollerPool, null,
new SinkCounter("test-bucket-writer-"
+ System.currentTimeMillis()), 0, null, null, 30000,
Executors.newSingleThreadExecutor(), 0, 0);
// write one more event (to reopen a new file so we will roll again later)
bucketWriter.append(e);