# HG changeset patch # User egahlin # Date 1558723511 -7200 # Node ID 41f0051285e0dbecda8d0f5b01f134c9b2259a1c # Parent 400db63e4937e0bf46443f96e7618fbb96336131 First stab at EventFileStream diff -r 400db63e4937 -r 41f0051285e0 src/jdk.jfr/share/classes/jdk/jfr/consumer/EventFileStream.java --- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/EventFileStream.java Fri May 24 20:30:12 2019 +0200 +++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/EventFileStream.java Fri May 24 20:45:11 2019 +0200 @@ -42,8 +42,11 @@ */ final class EventFileStream implements EventStream { - final static class FileEventConsumer extends EventConsumer { + private final static class FileEventConsumer extends EventConsumer { private final RecordingInput input; + private ChunkParser chunkParser; + private RecordedEvent event; + private boolean moreEvents = true; public FileEventConsumer(AccessControlContext acc, RecordingInput input) throws IOException { super(acc); @@ -52,11 +55,30 @@ @Override public void process() throws Exception { - // TODO This need more work; filter, multiple chunk etc - ChunkParser cp = new ChunkParser(input); - while (true) { - RecordedEvent e = cp.readEvent(); - dispatch(e); + chunkParser = new ChunkParser(input); + while (moreEvents) { + event = chunkParser.readEvent(); + if (event == null) { + findNext(); + if (!moreEvents) { + return; + } + } + dispatch(event); + } + } + + private void findNext() throws IOException { + while (event == null) { + if (chunkParser == null) { + chunkParser = new ChunkParser(input); + } else if (!chunkParser.isLastChunk()) { + chunkParser = chunkParser.nextChunkParser(); + } else { + moreEvents = false; + return; + } + event = chunkParser.readEvent(); } } }