package jdk.jfr.internal.consumer;
import java.io.DataInput;
import java.io.IOException;
import jdk.jfr.internal.LogLevel;
import jdk.jfr.internal.LogTag;
import jdk.jfr.internal.Logger;
import jdk.jfr.internal.MetadataDescriptor;
public final class {
private static final long = 0;
private static final byte[] = { 'F', 'L', 'R', '\0' };
private final short ;
private final short ;
private final long ;
private final long ;
private final long ;
private final long ;
private final long ;
private final long ;
private final long ;
private final long ;
private final boolean ;
private final RecordingInput ;
private final long ;
private final long ;
private long ;
public (RecordingInput input) throws IOException {
this(input, 0, 0);
}
private (RecordingInput input, long absoluteChunkStart, long id) throws IOException {
input.position(absoluteChunkStart);
if (input.position() >= input.size()) {
throw new IOException("Chunk contains no data");
}
verifyMagic(input);
this.input = input;
this.id = id;
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk " + id);
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: startPosition=" + absoluteChunkStart);
major = input.readRawShort();
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: major=" + major);
minor = input.readRawShort();
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: minor=" + minor);
if (major != 1 && major != 2) {
throw new IOException("File version " + major + "." + minor + ". Only Flight Recorder files of version 1.x and 2.x can be read by this JDK.");
}
chunkSize = input.readRawLong();
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: chunkSize=" + chunkSize);
this.constantPoolPosition = input.readRawLong();
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: constantPoolPosition=" + constantPoolPosition);
metadataPosition = input.readRawLong();
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: metadataPosition=" + metadataPosition);
chunkStartNanos = input.readRawLong();
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: startNanos=" + chunkStartNanos);
durationNanos = input.readRawLong();
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: durationNanos=" + durationNanos);
chunkStartTicks = input.readRawLong();
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: startTicks=" + chunkStartTicks);
ticksPerSecond = input.readRawLong();
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: ticksPerSecond=" + ticksPerSecond);
input.readRawInt();
this.absoluteChunkStart = absoluteChunkStart;
absoluteChunkEnd = absoluteChunkStart + chunkSize;
lastChunk = input.size() == absoluteChunkEnd;
absoluteEventStart = input.position();
input.position(absoluteEventStart);
}
public ChunkHeader () throws IOException {
return new ChunkHeader(input, absoluteChunkEnd, id + 1);
}
public MetadataDescriptor () throws IOException {
input.position(absoluteChunkStart + metadataPosition);
input.readInt();
long id = input.readLong();
if (id != METADATA_TYPE_ID) {
throw new IOException("Expected metadata event. Type id=" + id + ", should have been " + METADATA_TYPE_ID);
}
input.readLong();
input.readLong();
long metadataId = input.readLong();
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.TRACE, "Metadata id=" + metadataId);
return MetadataDescriptor.read(input);
}
public boolean () {
return lastChunk;
}
public short () {
return major;
}
public short () {
return minor;
}
public long () {
return absoluteChunkStart;
}
public long () {
return constantPoolPosition;
}
public long () {
return chunkStartTicks;
}
public double () {
return ticksPerSecond;
}
public long () {
return chunkStartNanos;
}
public long () {
return absoluteChunkEnd;
}
public long () {
return chunkSize;
}
public long () {
return durationNanos;
}
public RecordingInput () {
return input;
}
private static void (DataInput input) throws IOException {
for (byte c : FILE_MAGIC) {
if (input.readByte() != c) {
throw new IOException("Not a Flight Recorder file");
}
}
}
public long () {
return absoluteEventStart;
}
}