generator.generateEvents(6, 2, 120, 38, events);
log.debug(dbusBuf.toShortString());
dbusBuf.assertBuffersLimits();
DbusEventAppender appender = new DbusEventAppender(events, dbusBuf, null, 1.0, false, -1);
appender.run();
log.info("verify new iterator");
DbusEventIterator iter1 =
dbusBuf.acquireIterator("testInternalIteratorSingleBufFull");
log.debug("it1=" + iter1);
Assert.assertEquals(iter1.getCurrentPosition(), dbusBuf.getHead());
Assert.assertEquals(iter1._iteratorTail.getPosition(), dbusBuf.getTail());
Assert.assertEquals(dbusBuf._busyIteratorPool.size(), 1);
Assert.assertTrue(iter1.hasNext());
DbusEvent e = iter1.next();
Assert.assertTrue(e.isEndOfPeriodMarker());
Assert.assertTrue(iter1.hasNext());
dbusBuf.assertBuffersLimits();
log.info("make sure we can read some events");
readAndCompareIteratorEvents(iter1, events, 0, 6, true, true, true);
log.debug("after read: " + dbusBuf.toShortString());
log.debug(iter1);
log.info("append more windows");
final Vector<DbusEvent> events2 = new Vector<DbusEvent>();
generator = new DbusEventGenerator(200);
generator.generateEvents(2, 1, 120, 39, events2);
appender = new DbusEventAppender(events2, dbusBuf, null, 1.0, false, -1);
appender.run();
log.debug("after 2 more events added: " + dbusBuf.toShortString());
log.debug(iter1);
readAndCompareIteratorEvents(iter1, events2, 0, 2, true, false, true);
log.debug("after 2 more events read: " + dbusBuf.toShortString());
log.debug(iter1);
dbusBuf.assertBuffersLimits();
// create another iterator - make sure it can read too
DbusEventIterator iter2 = dbusBuf.acquireIterator("testInternalIteratorSingleBufFull2");
long iCWP = iter2.getCurrentPosition();
long head = dbusBuf.getBufferPositionParser().sanitize(dbusBuf.getHead(), dbusBuf.getBuffer());
Assert.assertEquals(iCWP, head);
Assert.assertEquals(iter2._iteratorTail.getPosition(), dbusBuf.getTail());
Assert.assertEquals(dbusBuf._busyIteratorPool.size(), 2);
Assert.assertTrue(iter2.hasNext());
log.debug("iter2=" + iter2);
readAndCompareIteratorEvents(iter2, events2, 0, 2, true, false, true); // read same events and don't remove
dbusBuf.releaseIterator(iter2);
dbusBuf.assertBuffersLimits();
log.debug("iter1=" + iter1);
iter1.remove();
log.debug("buf (after read)=" + dbusBuf);
generator = new DbusEventGenerator(300);
final Vector<DbusEvent> events3 = new Vector<DbusEvent>();
generator.generateEvents(4, 2, 120, 39, events3);
appender = new DbusEventAppender(events3, dbusBuf, null, 1.0, false, -1);
appender.run();
dbusBuf.assertBuffersLimits();
log.info("make sure we can read remainder of events");
readAndCompareIteratorEvents(iter1, events3, 0, 4, false, true, true);