// parts. Normally this manager would want to delete a wal file (or wal
// entries). This stubs that out to a call doesn't cause a file not found
// exception.
WALManager mockWalMan = mock(WALManager.class);
BenchmarkHarness.setupFlumeNode(null, mockWalMan, null, null, null);
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
Clock.sleep(10); // have to make sure it is not in the same millisecond
// don't rotate the first one.
assertEquals(1, node.getAckChecker().getPendingAckTags().size());
node.getAckChecker().checkAcks();
// still one ack pending.
assertEquals(1, node.getAckChecker().getPendingAckTags().size());
String tag2 = roll.getCurrentTag();
LOG.info(tag2);
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();
// two acks pending.
assertEquals(2, node.getAckChecker().getPendingAckTags().size());
node.getAckChecker().checkAcks();
// no more acks pending.
assertEquals(0, node.getAckChecker().getPendingAckTags().size());
String tag3 = roll.getCurrentTag();
LOG.info(tag3);
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();
// one ack pending
assertEquals(1, node.getAckChecker().getPendingAckTags().size());
node.getAckChecker().checkAcks();
// no more acks pending.
assertEquals(0, node.getAckChecker().getPendingAckTags().size());
snk.close();
FileUtil.rmr(tmpdir);
BenchmarkHarness.cleanupLocalWriteDir();