FlumeNode node = FlumeNode.getInstance();
File tmpdir = FileUtil.mktempdir();
EventSource ackedmem = setupAckRoll();
Pair<RollSink, EventSink> p = setupSink(node, tmpdir);
EventSink snk = p.getRight();
RollSink roll = p.getLeft();
snk.open();
String tag1 = roll.getCurrentTag();
LOG.info(tag1);
snk.append(ackedmem.next()); // ack beg
snk.append(ackedmem.next()); // data
snk.append(ackedmem.next()); // ack end
snk.append(ackedmem.next()); // ack beg
Clock.sleep(10); // have to make sure it is not in the same millisecond
roll.rotate(); // we should have the first batch and part of the second
// one ack pending
assertEquals(1, node.getAckChecker().getPendingAckTags().size());
node.getAckChecker().checkAcks();
// no acks pending
assertEquals(0, node.getAckChecker().getPendingAckTags().size());
// we are partially through the second batch, at a different split point
String tag2 = roll.getCurrentTag();
LOG.info(tag2);
snk.append(ackedmem.next()); // data
snk.append(ackedmem.next()); // ack end
snk.append(ackedmem.next()); // ack beg
snk.append(ackedmem.next()); // data
snk.append(ackedmem.next()); // ack end
Clock.sleep(10); // have to make sure it is not in the same millisecond
roll.rotate();
// now we have closed off group2 and group3
assertEquals(2, node.getAckChecker().getPendingAckTags().size());
node.getAckChecker().checkAcks();
Clock.sleep(10); // have to make sure it is not in the same millisecond
// no more acks left
LOG.info("pending ack tags: " + node.getAckChecker().getPendingAckTags());
assertEquals(0, node.getAckChecker().getPendingAckTags().size());
snk.close();
FileUtil.rmr(tmpdir);
BenchmarkHarness.cleanupLocalWriteDir();
}