jdk.jfr.internal.consumer.RecordingInput Java Examples

The following examples show how to use jdk.jfr.internal.consumer.RecordingInput. 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: EventParser.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Object parse(RecordingInput input) throws IOException {
    Object[] values = new Object[parsers.length];
    for (int i = 0; i < parsers.length; i++) {
        values[i] = parsers[i].parse(input);
    }
    Long startTicks = (Long) values[0];
    long startTime = timeConverter.convertTimestamp(startTicks);
    if (hasDuration) {
        long durationTicks = (Long) values[1];
        long endTime = timeConverter.convertTimestamp(startTicks + durationTicks);
        return new RecordedEvent(eventType, valueDescriptors, values, startTime, endTime, timeConverter);
    } else {
        return new RecordedEvent(eventType, valueDescriptors, values, startTime, startTime, timeConverter);
    }
}
 
Example #2
Source File: EventWriter.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void putString(String s, StringPool pool) {
    if (s == null) {
        putByte(RecordingInput.STRING_ENCODING_NULL);
        return;
    }
    int length = s.length();
    if (length == 0) {
        putByte(RecordingInput.STRING_ENCODING_EMPTY_STRING);
        return;
    }
    if (length > StringPool.MIN_LIMIT && length < StringPool.MAX_LIMIT) {
        long l = StringPool.addString(s);
        if (l > 0) {
            putByte(RecordingInput.STRING_ENCODING_CONSTANT_POOL);
            putLong(l);
            return;
        }
    }
    putStringValue(s);
    return;
}
 
Example #3
Source File: EventWriter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void putString(String s, StringPool pool) {
    if (s == null) {
        putByte(RecordingInput.STRING_ENCODING_NULL);
        return;
    }
    int length = s.length();
    if (length == 0) {
        putByte(RecordingInput.STRING_ENCODING_EMPTY_STRING);
        return;
    }
    if (length > StringPool.MIN_LIMIT && length < StringPool.MAX_LIMIT) {
        long l = StringPool.addString(s);
        if (l > 0) {
            putByte(RecordingInput.STRING_ENCODING_CONSTANT_POOL);
            putLong(l);
            return;
        }
    }
    putStringValue(s);
    return;
}
 
Example #4
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 #5
Source File: EventParser.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Object parse(RecordingInput input) throws IOException {
    Object[] values = new Object[parsers.length];
    for (int i = 0; i < parsers.length; i++) {
        values[i] = parsers[i].parse(input);
    }
    Long startTicks = (Long) values[0];
    long startTime = timeConverter.convertTimestamp(startTicks);
    if (hasDuration) {
        long durationTicks = (Long) values[1];
        long endTime = timeConverter.convertTimestamp(startTicks + durationTicks);
        return new RecordedEvent(eventType, valueDescriptors, values, startTime, endTime, timeConverter);
    } else {
        return new RecordedEvent(eventType, valueDescriptors, values, startTime, startTime, timeConverter);
    }
}
 
Example #6
Source File: EventWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void putString(String s, StringPool pool) {
    if (s == null) {
        putByte(RecordingInput.STRING_ENCODING_NULL);
        return;
    }
    int length = s.length();
    if (length == 0) {
        putByte(RecordingInput.STRING_ENCODING_EMPTY_STRING);
        return;
    }
    if (length > StringPool.MIN_LIMIT && length < StringPool.MAX_LIMIT) {
        long l = StringPool.addString(s);
        if (l > 0) {
            putByte(RecordingInput.STRING_ENCODING_CONSTANT_POOL);
            putLong(l);
            return;
        }
    }
    putStringValue(s);
    return;
}
 
Example #7
Source File: EventParser.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Object parse(RecordingInput input) throws IOException {
    Object[] values = new Object[parsers.length];
    for (int i = 0; i < parsers.length; i++) {
        values[i] = parsers[i].parse(input);
    }
    Long startTicks = (Long) values[0];
    long startTime = timeConverter.convertTimestamp(startTicks);
    if (hasDuration) {
        long durationTicks = (Long) values[1];
        long endTime = timeConverter.convertTimestamp(startTicks + durationTicks);
        return new RecordedEvent(eventType, valueDescriptors, values, startTime, endTime, timeConverter);
    } else {
        return new RecordedEvent(eventType, valueDescriptors, values, startTime, startTime, timeConverter);
    }
}
 
Example #8
Source File: EventWriter.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void putStringValue(String s) {
    int length = s.length();
    if (isValidForSize(1 + 5 + 3 * length)) {
        putUncheckedByte(RecordingInput.STRING_ENCODING_CHAR_ARRAY); // 1 byte
        putUncheckedInt(length); // max 5 bytes
        for (int i = 0; i < length; i++) {
            putUncheckedChar(s.charAt(i)); // max 3 bytes
        }
    }
}
 
Example #9
Source File: ParserFactory.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object parse(RecordingInput input) throws IOException {
    final Object[] values = new Object[parsers.length];
    for (int i = 0; i < values.length; i++) {
        values[i] = parsers[i].parse(input);
    }
    return values;
}
 
Example #10
Source File: MetadataWriter.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void writeString(DataOutput out, String s) throws IOException {
    if (s == null ) {
        out.writeByte(RecordingInput.STRING_ENCODING_NULL);
        return;
    }
    out.writeByte(RecordingInput.STRING_ENCODING_CHAR_ARRAY); // encoding UTF-16
    int length = s.length();
    writeInt(out, length);
        for (int i = 0; i < length; i++) {
            writeInt(out, s.charAt(i));
        }
}
 
Example #11
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 #12
Source File: ParserFactory.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object parse(RecordingInput input) throws IOException {
    String s = parseEncodedString(input);
    if (!Objects.equals(s, last)) {
        last = s;
    }
    return last;
}
 
Example #13
Source File: ParserFactory.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private String parseEncodedString(RecordingInput input) throws IOException {
    byte encoding = input.readByte();
    if (encoding == RecordingInput.STRING_ENCODING_CONSTANT_POOL) {
        long id = input.readLong();
        return (String) stringConstantMap.get(id);
    } else {
        return input.readEncodedString(encoding);
    }
}
 
Example #14
Source File: ParserFactory.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object parse(RecordingInput input) throws IOException {
    final int size = input.readInt();
    final Object[] array = new Object[size];
    for (int i = 0; i < size; i++) {
        array[i] = elementParser.parse(input);
    }
    return array;
}
 
Example #15
Source File: ParserFactory.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object parse(RecordingInput input) throws IOException {
    final int size = input.readInt();
    final Object[] array = new Object[size];
    for (int i = 0; i < size; i++) {
        array[i] = elementParser.parse(input);
    }
    return array;
}
 
Example #16
Source File: MetadataWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void writeString(DataOutput out, String s) throws IOException {
    if (s == null ) {
        out.writeByte(RecordingInput.STRING_ENCODING_NULL);
        return;
    }
    out.writeByte(RecordingInput.STRING_ENCODING_CHAR_ARRAY); // encoding UTF-16
    int length = s.length();
    writeInt(out, length);
        for (int i = 0; i < length; i++) {
            writeInt(out, s.charAt(i));
        }
}
 
Example #17
Source File: ParserFactory.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object parse(RecordingInput input) throws IOException {
    final Object[] values = new Object[parsers.length];
    for (int i = 0; i < values.length; i++) {
        values[i] = parsers[i].parse(input);
    }
    return values;
}
 
Example #18
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 #19
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 #20
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 #21
Source File: EventWriter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void putStringValue(String s) {
    int length = s.length();
    if (isValidForSize(1 + 5 + 3 * length)) {
        putUncheckedByte(RecordingInput.STRING_ENCODING_CHAR_ARRAY); // 1 byte
        putUncheckedInt(length); // max 5 bytes
        for (int i = 0; i < length; i++) {
            putUncheckedChar(s.charAt(i)); // max 3 bytes
        }
    }
}
 
Example #22
Source File: MetadataWriter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void writeString(DataOutput out, String s) throws IOException {
    if (s == null ) {
        out.writeByte(RecordingInput.STRING_ENCODING_NULL);
        return;
    }
    out.writeByte(RecordingInput.STRING_ENCODING_CHAR_ARRAY); // encoding UTF-16
    int length = s.length();
    writeInt(out, length);
        for (int i = 0; i < length; i++) {
            writeInt(out, s.charAt(i));
        }
}
 
Example #23
Source File: ParserFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object parse(RecordingInput input) throws IOException {
    String s = parseEncodedString(input);
    if (!Objects.equals(s, last)) {
        last = s;
    }
    return last;
}
 
Example #24
Source File: ParserFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private String parseEncodedString(RecordingInput input) throws IOException {
    byte encoding = input.readByte();
    if (encoding == RecordingInput.STRING_ENCODING_CONSTANT_POOL) {
        long id = input.readLong();
        return (String) stringConstantMap.get(id);
    } else {
        return input.readEncodedString(encoding);
    }
}
 
Example #25
Source File: ParserFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object parse(RecordingInput input) throws IOException {
    final int size = input.readInt();
    final Object[] array = new Object[size];
    for (int i = 0; i < size; i++) {
        array[i] = elementParser.parse(input);
    }
    return array;
}
 
Example #26
Source File: ParserFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object parse(RecordingInput input) throws IOException {
    final Object[] values = new Object[parsers.length];
    for (int i = 0; i < values.length; i++) {
        values[i] = parsers[i].parse(input);
    }
    return values;
}
 
Example #27
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 #28
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 #29
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 #30
Source File: EventWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void putStringValue(String s) {
    int length = s.length();
    if (isValidForSize(1 + 5 + 3 * length)) {
        putUncheckedByte(RecordingInput.STRING_ENCODING_CHAR_ARRAY); // 1 byte
        putUncheckedInt(length); // max 5 bytes
        for (int i = 0; i < length; i++) {
            putUncheckedChar(s.charAt(i)); // max 3 bytes
        }
    }
}