jdk.jfr.internal.consumer.ChunkHeader Java Examples

The following examples show how to use jdk.jfr.internal.consumer.ChunkHeader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChunkParser.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private ChunkParser(ChunkHeader header) throws IOException {
    this.input = header.getInput();
    this.chunkHeader = header;
    this.metadata = header.readMetadata();
    this.absoluteChunkEnd = header.getEnd();
    this.timeConverter =  new TimeConverter(chunkHeader);

    ParserFactory factory = new ParserFactory(metadata, timeConverter);
    LongMap<ConstantMap> constantPools = factory.getConstantPools();
    parsers = factory.getParsers();
    typeMap = factory.getTypeMap();

    fillConstantPools(parsers, constantPools);
    constantPools.forEach(ConstantMap::setIsResolving);
    constantPools.forEach(ConstantMap::resolve);
    constantPools.forEach(ConstantMap::setResolved);

    input.position(chunkHeader.getEventStart());
}
 
Example #2
Source File: PrettyWriter.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
void print(Path source) throws FileNotFoundException, IOException {
    try (RecordingInput input = new RecordingInput(source.toFile())) {
        HashSet<Type> typeSet = new HashSet<>();
        for (ChunkHeader ch = new ChunkHeader(input); !ch.isLastChunk(); ch = ch.nextHeader()) {
            typeSet.addAll(ch.readMetadata().getTypes());
        }
        List<Type> types = new ArrayList<>(typeSet);
        Collections.sort(types, (c1, c2) -> Long.compare(c1.getId(), c2.getId()));
        for (Type t : types) {
            printType(t);
        }
        flush();
    }

    try (RecordingFile es = new RecordingFile(source)) {
        while (es.hasMoreEvents()) {
            print(es.readEvent());
            flush();
        }
    }
    flush();
}
 
Example #3
Source File: ChunkParser.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private ChunkParser(ChunkHeader header) throws IOException {
    this.input = header.getInput();
    this.chunkHeader = header;
    this.metadata = header.readMetadata();
    this.absoluteChunkEnd = header.getEnd();
    this.timeConverter = new TimeConverter(chunkHeader, metadata.getGMTOffset());

    ParserFactory factory = new ParserFactory(metadata, timeConverter);
    LongMap<ConstantMap> constantPools = factory.getConstantPools();
    parsers = factory.getParsers();
    typeMap = factory.getTypeMap();

    fillConstantPools(parsers, constantPools);
    constantPools.forEach(ConstantMap::setIsResolving);
    constantPools.forEach(ConstantMap::resolve);
    constantPools.forEach(ConstantMap::setResolved);

    input.position(chunkHeader.getEventStart());
}
 
Example #4
Source File: ChunkParser.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private ChunkParser(ChunkHeader header) throws IOException {
    this.input = header.getInput();
    this.chunkHeader = header;
    this.metadata = header.readMetadata();
    this.absoluteChunkEnd = header.getEnd();
    this.timeConverter = new TimeConverter(chunkHeader, metadata.getGMTOffset());

    ParserFactory factory = new ParserFactory(metadata, timeConverter);
    LongMap<ConstantMap> constantPools = factory.getConstantPools();
    parsers = factory.getParsers();
    typeMap = factory.getTypeMap();

    fillConstantPools(parsers, constantPools);
    constantPools.forEach(ConstantMap::setIsResolving);
    constantPools.forEach(ConstantMap::resolve);
    constantPools.forEach(ConstantMap::setResolved);

    input.position(chunkHeader.getEventStart());
}
 
Example #5
Source File: RecordingFile.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
List<Type> readTypes() throws IOException  {
    ensureOpen();
    List<Type> types = new ArrayList<>();
    HashSet<Long> foundIds = new HashSet<>();
    try (RecordingInput ri = new RecordingInput(file)) {
        ChunkHeader ch = new ChunkHeader(ri);
        aggregateTypeForChunk(ch, types, foundIds);
        while (!ch.isLastChunk()) {
            ch = ch.nextHeader();
            aggregateTypeForChunk(ch, types, foundIds);
        }
    }
    return types;
}
 
Example #6
Source File: Disassemble.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private List<Long> findChunkSizes(Path p) throws IOException {
    try (RecordingInput input = new RecordingInput(p.toFile())) {
        List<Long> sizes = new ArrayList<>();
        ChunkHeader ch = new ChunkHeader(input);
        sizes.add(ch.getSize());
        while (!ch.isLastChunk()) {
            ch = ch.nextHeader();
            sizes.add(ch.getSize());
        }
        return sizes;
    }
}
 
Example #7
Source File: RecordingFile.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void aggregateEventTypeForChunk(ChunkHeader ch, List<EventType> types, HashSet<Long> foundIds) throws IOException {
    MetadataDescriptor m = ch.readMetadata();
    for (EventType t : m.getEventTypes()) {
        if (!foundIds.contains(t.getId())) {
            types.add(t);
            foundIds.add(t.getId());
        }
    }
}
 
Example #8
Source File: RecordingFile.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void aggregateTypeForChunk(ChunkHeader ch, List<Type> types, HashSet<Long> foundIds) throws IOException {
    MetadataDescriptor m = ch.readMetadata();
    for (Type t : m.getTypes()) {
        if (!foundIds.contains(t.getId())) {
            types.add(t);
            foundIds.add(t.getId());
        }
    }
}
 
Example #9
Source File: RecordingFile.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
List<Type> readTypes() throws IOException  {
    ensureOpen();
    List<Type> types = new ArrayList<>();
    HashSet<Long> foundIds = new HashSet<>();
    try (RecordingInput ri = new RecordingInput(file)) {
        ChunkHeader ch = new ChunkHeader(ri);
        aggregateTypeForChunk(ch, types, foundIds);
        while (!ch.isLastChunk()) {
            ch = ch.nextHeader();
            aggregateTypeForChunk(ch, types, foundIds);
        }
    }
    return types;
}
 
Example #10
Source File: RecordingFile.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a list of all event types in this recording.
 *
 * @return a list of event types, not {@code null}
 * @throws IOException if an I/O error occurred while reading from the file
 *
 * @see #hasMoreEvents()
 */
public List<EventType> readEventTypes() throws IOException {
    ensureOpen();
    List<EventType> types = new ArrayList<>();
    HashSet<Long> foundIds = new HashSet<>();
    try (RecordingInput ri = new RecordingInput(file)) {
        ChunkHeader ch = new ChunkHeader(ri);
        aggregateEventTypeForChunk(ch, types, foundIds);
        while (!ch.isLastChunk()) {
            ch = ch.nextHeader();
            aggregateEventTypeForChunk(ch, types, foundIds);
        }
    }
    return types;
}
 
Example #11
Source File: Disassemble.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private List<Long> findChunkSizes(Path p) throws IOException {
    try (RecordingInput input = new RecordingInput(p.toFile())) {
        List<Long> sizes = new ArrayList<>();
        ChunkHeader ch = new ChunkHeader(input);
        sizes.add(ch.getSize());
        while (!ch.isLastChunk()) {
            ch = ch.nextHeader();
            sizes.add(ch.getSize());
        }
        return sizes;
    }
}
 
Example #12
Source File: RecordingFile.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void aggregateEventTypeForChunk(ChunkHeader ch, List<EventType> types, HashSet<Long> foundIds) throws IOException {
    MetadataDescriptor m = ch.readMetadata();
    for (EventType t : m.getEventTypes()) {
        if (!foundIds.contains(t.getId())) {
            types.add(t);
            foundIds.add(t.getId());
        }
    }
}
 
Example #13
Source File: RecordingFile.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void aggregateTypeForChunk(ChunkHeader ch, List<Type> types, HashSet<Long> foundIds) throws IOException {
    MetadataDescriptor m = ch.readMetadata();
    for (Type t : m.getTypes()) {
        if (!foundIds.contains(t.getId())) {
            types.add(t);
            foundIds.add(t.getId());
        }
    }
}
 
Example #14
Source File: RecordingFile.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a list of all event types in this recording.
 *
 * @return a list of event types, not {@code null}
 * @throws IOException if an I/O error occurred while reading from the file
 *
 * @see #hasMoreEvents()
 */
public List<EventType> readEventTypes() throws IOException {
    ensureOpen();
    List<EventType> types = new ArrayList<>();
    HashSet<Long> foundIds = new HashSet<>();
    try (RecordingInput ri = new RecordingInput(file)) {
        ChunkHeader ch = new ChunkHeader(ri);
        aggregateEventTypeForChunk(ch, types, foundIds);
        while (!ch.isLastChunk()) {
            ch = ch.nextHeader();
            aggregateEventTypeForChunk(ch, types, foundIds);
        }
    }
    return types;
}
 
Example #15
Source File: SplitCommand.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private List<Long> findChunkSizes(Path p) throws IOException {
    try (RecordingInput input = new RecordingInput(p.toFile())) {
        List<Long> sizes = new ArrayList<>();
        ChunkHeader ch = new ChunkHeader(input);
        sizes.add(ch.getSize());
        while (!ch.isLastChunk()) {
            ch = ch.nextHeader();
            sizes.add(ch.getSize());
        }
        return sizes;
    }
}
 
Example #16
Source File: RecordingFile.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void aggregateTypeForChunk(ChunkHeader ch, List<EventType> types, HashSet<Long> foundIds) throws IOException {
    MetadataDescriptor m = ch.readMetadata();
    for (EventType t : m.getEventTypes()) {
        if (!foundIds.contains(t.getId())) {
            types.add(t);
            foundIds.add(t.getId());
        }
    }
}
 
Example #17
Source File: RecordingFile.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a list of all event types in this recording.
 *
 * @return a list of event types, not {@code null}
 * @throws IOException if an I/O error occurred while reading from the file
 *
 * @see #hasMoreEvents()
 */
public List<EventType> readEventTypes() throws IOException {
    ensureOpen();
    List<EventType> types = new ArrayList<>();
    HashSet<Long> foundIds = new HashSet<>();
    try (RecordingInput ri = new RecordingInput(file)) {
        ChunkHeader ch = new ChunkHeader(ri);
        aggregateTypeForChunk(ch, types, foundIds);
        while (!ch.isLastChunk()) {
            ch = ch.nextHeader();
            aggregateTypeForChunk(ch, types, foundIds);
        }
    }
    return types;
}
 
Example #18
Source File: TimeConverter.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
TimeConverter(ChunkHeader chunkHeader) {
    this.startTicks = chunkHeader.getStartTicks();
    this.startNanos = chunkHeader.getStartNanos();
    this.divisor = chunkHeader.getTicksPerSecond() / 1000_000_000L;
}
 
Example #19
Source File: TimeConverter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
TimeConverter(ChunkHeader chunkHeader, int rawOffset) {
    this.startTicks = chunkHeader.getStartTicks();
    this.startNanos = chunkHeader.getStartNanos();
    this.divisor = chunkHeader.getTicksPerSecond() / 1000_000_000L;
    this.zoneOffet = zoneOfSet(rawOffset);
}
 
Example #20
Source File: ChunkParser.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public ChunkParser(RecordingInput input) throws IOException {
    this(new ChunkHeader(input));
}
 
Example #21
Source File: ChunkParser.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public ChunkParser(RecordingInput input) throws IOException {
    this(new ChunkHeader(input));
}
 
Example #22
Source File: TimeConverter.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
TimeConverter(ChunkHeader chunkHeader, int rawOffset) {
    this.startTicks = chunkHeader.getStartTicks();
    this.startNanos = chunkHeader.getStartNanos();
    this.divisor = chunkHeader.getTicksPerSecond() / 1000_000_000L;
    this.zoneOffet = zoneOfSet(rawOffset);
}
 
Example #23
Source File: ChunkParser.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public ChunkParser(RecordingInput input) throws IOException {
  this(new ChunkHeader(input));
}