org.gridkit.jvmtool.jfr_jdk.parser.EventSource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sjk-jfr6 Show documentation
Show all versions of sjk-jfr6 Show documentation
Java Flight Recorder Integration for SJK (Mission Control 6)
package org.gridkit.jvmtool.jfr_jdk.parser;
import java.io.IOException;
import java.util.Collection;
import org.gridkit.jvmtool.spi.parsers.JsonEventSource;
import org.gridkit.jvmtool.util.json.JsonStreamWriter;
import jdk.jfr.consumer.RecordingFile;
class EventSource implements JsonEventSource {
private final RecordingFile rec;
private final JsonEventAdapter adapter;
public EventSource(RecordingFile rec, int maxJsonDepth) {
this.rec = rec;
this.adapter = new JsonEventAdapter(maxJsonDepth);
}
public void setWhiteList(Collection list) {
adapter.setWhiteList(list);
}
public void setBlackList(Collection list) {
adapter.setBlackList(list);
}
@Override
public boolean readNext(JsonStreamWriter writer) throws IOException {
if (!rec.hasMoreEvents()) {
return false;
}
else {
adapter.encodeEvent(rec.readEvent(), writer);
return true;
}
}
}