Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
JDK 17 jdk.jfr.jmod - JFR Module
JDK 17 jdk.jfr.jmod is the JMOD file for JDK 17 JFR module.
JDK 17 JFR module compiled class files are stored in \fyicenter\jdk-17.0.5\jmods\jdk.jfr.jmod.
JDK 17 JFR module compiled class files are also linked and stored in the \fyicenter\jdk-17.0.5\lib\modules JImage file.
JDK 17 JFR module source code files are stored in \fyicenter\jdk-17.0.5\lib\src.zip\jdk.jfr.
You can click and view the content of each source code file in the list below.
✍: FYIcenter
⏎ jdk/jfr/internal/consumer/ChunkHeader.java
/*
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package jdk.jfr.internal.consumer;
import java.io.IOException;
import jdk.jfr.internal.LogLevel;
import jdk.jfr.internal.LogTag;
import jdk.jfr.internal.Logger;
import jdk.jfr.internal.MetadataDescriptor;
import jdk.jfr.internal.Utils;
public final class ChunkHeader {
static final long HEADER_SIZE = 68;
static final byte UPDATING_CHUNK_HEADER = (byte) 255;
static final long CHUNK_SIZE_POSITION = 8;
static final long DURATION_NANOS_POSITION = 40;
static final long FILE_STATE_POSITION = 64;
static final long FLAG_BYTE_POSITION = 67;
static final long METADATA_TYPE_ID = 0;
static final byte[] FILE_MAGIC = { 'F', 'L', 'R', '\0' };
static final int MASK_FINAL_CHUNK = 1 << 1;
private final short major;
private final short minor;
private final long chunkStartTicks;
private final long ticksPerSecond;
private final long chunkStartNanos;
private final long absoluteChunkStart;
private final RecordingInput input;
private final long id;
private long absoluteEventStart;
private long chunkSize = 0;
private long constantPoolPosition = 0;
private long metadataPosition = 0;
private long durationNanos;
private long absoluteChunkEnd;
private boolean isFinished;
private boolean finished;
private boolean finalChunk;
public ChunkHeader(RecordingInput input) throws IOException {
this(input, 0, 0);
}
private ChunkHeader(RecordingInput input, long absoluteChunkStart, long id) throws IOException {
this.absoluteChunkStart = absoluteChunkStart;
this.absoluteEventStart = absoluteChunkStart + HEADER_SIZE;
if (input.getFileSize() < HEADER_SIZE) {
throw new IOException("Not a complete Chunk header");
}
input.setValidSize(absoluteChunkStart + HEADER_SIZE);
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: file=" + input.getFilename());
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.");
}
long c = input.readRawLong(); // chunk size
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: chunkSize=" + c);
input.readRawLong(); // constant pool position
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: constantPoolPosition=" + constantPoolPosition);
input.readRawLong(); // metadata position
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: metadataPosition=" + metadataPosition);
chunkStartNanos = input.readRawLong(); // nanos since epoch
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: startNanos=" + chunkStartNanos);
durationNanos = input.readRawLong(); // duration nanos, not used
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(); // ignore file state and flag bits
refresh();
input.position(absoluteEventStart);
}
public void refresh() throws IOException {
while (true) {
byte fileState1;
input.positionPhysical(absoluteChunkStart + FILE_STATE_POSITION);
while ((fileState1 = input.readPhysicalByte()) == UPDATING_CHUNK_HEADER) {
input.pollWait();
input.positionPhysical(absoluteChunkStart + FILE_STATE_POSITION);
}
input.positionPhysical(absoluteChunkStart + CHUNK_SIZE_POSITION);
long chunkSize = input.readPhysicalLong();
long constantPoolPosition = input.readPhysicalLong();
long metadataPosition = input.readPhysicalLong();
input.positionPhysical(absoluteChunkStart + DURATION_NANOS_POSITION);
long durationNanos = input.readPhysicalLong();
input.positionPhysical(absoluteChunkStart + FILE_STATE_POSITION);
byte fileState2 = input.readPhysicalByte();
input.positionPhysical(absoluteChunkStart + FLAG_BYTE_POSITION);
int flagByte = input.readPhysicalByte();
if (fileState1 == fileState2) { // valid header
finished = fileState1 == 0;
if (metadataPosition != 0) {
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Setting input size to " + (absoluteChunkStart + chunkSize));
if (finished) {
// This assumes that the whole recording
// is finished if the first chunk is.
// This is a limitation we may want to
// remove, but greatly improves performance as
// data can be read across chunk boundaries
// of multi-chunk files and only once.
input.setValidSize(input.getFileSize());
} else {
input.setValidSize(absoluteChunkStart + chunkSize);
}
this.chunkSize = chunkSize;
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: chunkSize=" + chunkSize);
this.constantPoolPosition = constantPoolPosition;
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: constantPoolPosition=" + constantPoolPosition);
this.metadataPosition = metadataPosition;
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: metadataPosition=" + metadataPosition);
this.durationNanos = durationNanos;
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: durationNanos =" + durationNanos);
isFinished = fileState2 == 0;
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: generation=" + fileState2);
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: finished=" + isFinished);
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: fileSize=" + input.size());
this.finalChunk = (flagByte & MASK_FINAL_CHUNK) != 0;
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: finalChunk=" + finalChunk);
absoluteChunkEnd = absoluteChunkStart + chunkSize;
return;
}
}
}
}
public boolean readHeader(byte[] bytes, int count) throws IOException {
input.position(absoluteChunkStart);
for (int i = 0; i< count; i++) {
bytes[i] = input.readPhysicalByte();
}
return bytes[(int)FILE_STATE_POSITION] != UPDATING_CHUNK_HEADER;
}
public void awaitFinished() throws IOException {
if (finished) {
return;
}
long pos = input.position();
try {
input.positionPhysical(absoluteChunkStart + FILE_STATE_POSITION);
while (true) {
byte filestate = input.readPhysicalByte();
if (filestate == 0) {
finished = true;
return;
}
input.pollWait();
}
} finally {
input.position(pos);
}
}
public boolean isLastChunk() throws IOException {
awaitFinished();
// streaming files only have one chunk
return input.getFileSize() == absoluteChunkEnd;
}
public boolean isFinalChunk() {
return finalChunk;
}
public boolean isFinished() throws IOException {
return isFinished;
}
public ChunkHeader nextHeader() throws IOException {
return new ChunkHeader(input, absoluteChunkEnd, id + 1);
}
public MetadataDescriptor readMetadata() throws IOException {
return readMetadata(null);
}
public MetadataDescriptor readMetadata(MetadataDescriptor previous) throws IOException {
input.position(absoluteChunkStart + metadataPosition);
input.readInt(); // size
long id = input.readLong(); // event type id
if (id != METADATA_TYPE_ID) {
throw new IOException("Expected metadata event. Type id=" + id + ", should have been " + METADATA_TYPE_ID);
}
input.readLong(); // start time
input.readLong(); // duration
long metadataId = input.readLong();
if (previous != null && metadataId == previous.metadataId) {
return previous;
}
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.TRACE, "New metadata id = " + metadataId);
MetadataDescriptor m = MetadataDescriptor.read(input);
m.metadataId = metadataId;
return m;
}
public short getMajor() {
return major;
}
public short getMinor() {
return minor;
}
public long getAbsoluteChunkStart() {
return absoluteChunkStart;
}
public long getAbsoluteEventStart() {
return absoluteEventStart;
}
public long getConstantPoolPosition() {
return constantPoolPosition;
}
public long getMetataPosition() {
return metadataPosition;
}
public long getStartTicks() {
return chunkStartTicks;
}
public long getChunkSize() {
return chunkSize;
}
public double getTicksPerSecond() {
return ticksPerSecond;
}
public long getStartNanos() {
return chunkStartNanos;
}
public long getEnd() {
return absoluteChunkEnd;
}
public long getSize() {
return chunkSize;
}
public long getDurationNanos() {
return durationNanos;
}
public RecordingInput getInput() {
return input;
}
private static void verifyMagic(RecordingInput input) throws IOException {
for (byte c : FILE_MAGIC) {
if (input.readByte() != c) {
throw new IOException("Not a Flight Recorder file");
}
}
}
public long getEventStart() {
return absoluteEventStart;
}
static long headerSize() {
return HEADER_SIZE;
}
public long getLastNanos() {
return getStartNanos() + getDurationNanos();
}
}
⏎ jdk/jfr/internal/consumer/ChunkHeader.java
Or download all of them as a single archive file:
File name: jdk.jfr-17.0.5-src.zip File size: 363343 bytes Release date: 2022-09-13 Download
⇒ JDK 17 jdk.jlink.jmod - JLink Tool
2023-04-17, ≈108🔥, 0💬
Popular Posts:
HttpComponents Client Source Code Files are provided in the source package file, httpcomponents-clie...
JDK 11 jdk.httpserver.jmod is the JMOD file for JDK 11 HTTP Server module. JDK 11 HTTP Server module...
How to download and install JDK (Java Development Kit) 6? If you want to write Java applications, yo...
commons-fileupload-1.3.3 -sources.jaris the source JAR file for Apache Commons FileUpload 1.3., whic...
How to perform XML Schema validation with sax\Writer.java provided in the Apache Xerces package? You...