jdk.jfr.internal.PlatformRecording Java Examples

The following examples show how to use jdk.jfr.internal.PlatformRecording. 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: DCmdDump.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Execute JFR.dump.
 *
 * @param recordingText name or id of the recording to dump, or
 *        <code>null</code>
 *
 * @param textPath file path where recording should be written.
 *
 * @return result output
 *
 * @throws DCmdException if the dump could not be completed
 */
public String execute(String recordingText, String textPath,  Boolean pathToGcRoots) throws DCmdException {
    if (textPath == null) {
        throw new DCmdException("Failed to dump %s, missing filename.", recordingText);
    }
    Recording recording = findRecording(recordingText);
    try {
        SafePath dumpFile = resolvePath(textPath, "Failed to dump %s");
        // create file for JVM
        Utils.touch(dumpFile.toPath());
        PlatformRecording r = PrivateAccess.getInstance().getPlatformRecording(recording);
        WriteableUserPath wup = new WriteableUserPath(dumpFile.toPath());

        Map<String, String> overlay = new HashMap<>();
        Utils.updateSettingPathToGcRoots(overlay, pathToGcRoots);

        r.copyTo(wup, "Dumped by user", overlay);
        reportOperationComplete("Dumped", recording, dumpFile);
    } catch (IOException | InvalidPathException e) {
        throw new DCmdException("Failed to dump %s. Could not copy recording for dump. %s", recordingText, e.getMessage());
    }
    return getResult();
}
 
Example #2
Source File: DCmdDump.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void dump(PlatformRecorder recorder, Recording recording, String name, String filename, Long maxSize, Boolean pathToGcRoots, Instant beginTime, Instant endTime) throws DCmdException {
    try (PlatformRecording r = newSnapShot(recorder, recording, pathToGcRoots)) {
        r.filter(beginTime, endTime, maxSize);
        if (r.getChunks().isEmpty()) {
            throw new DCmdException("Dump failed. No data found in the specified interval.");
        }
        SafePath dumpFile = resolvePath(recording, filename);

        // Needed for JVM
        Utils.touch(dumpFile.toPath());
        r.dumpStopped(new WriteableUserPath(dumpFile.toPath()));
        reportOperationComplete("Dumped", name, dumpFile);
    } catch (IOException | InvalidPathException e) {
        throw new DCmdException("Dump failed. Could not copy recording data. %s", e.getMessage());
    }
}
 
Example #3
Source File: DCmdDump.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void dump(PlatformRecorder recorder, Recording recording, String name, String filename, Long maxSize, Boolean pathToGcRoots, Instant beginTime, Instant endTime) throws DCmdException {
    try (PlatformRecording r = newSnapShot(recorder, recording, pathToGcRoots)) {
        r.filter(beginTime, endTime, maxSize);
        if (r.getChunks().isEmpty()) {
            throw new DCmdException("Dump failed. No data found in the specified interval.");
        }
        SafePath dumpFile = resolvePath(recording, filename);

        // Needed for JVM
        Utils.touch(dumpFile.toPath());
        r.dumpStopped(new WriteableUserPath(dumpFile.toPath()));
        reportOperationComplete("Dumped", name, dumpFile);
    } catch (IOException | InvalidPathException e) {
        throw new DCmdException("Dump failed. Could not copy recording data. %s", e.getMessage());
    }
}
 
Example #4
Source File: Recording.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private Recording(PlatformRecording internal) {
    this.internal = internal;
    this.internal.setRecording(this);
    if (internal.getRecording() != this) {
        throw new InternalError("Internal recording not properly setup");
    }
}
 
Example #5
Source File: DCmdDump.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private PlatformRecording newSnapShot(PlatformRecorder recorder, Recording recording, Boolean pathToGcRoots) throws DCmdException, IOException {
    if (recording == null) {
        // Operate on all recordings
        PlatformRecording snapshot = recorder.newTemporaryRecording();
        recorder.fillWithRecordedData(snapshot, pathToGcRoots);
        return snapshot;
    }

    PlatformRecording pr = PrivateAccess.getInstance().getPlatformRecording(recording);
    return pr.newSnapshotClone("Dumped by user", pathToGcRoots);
}
 
Example #6
Source File: DCmdDump.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private PlatformRecording newSnapShot(PlatformRecorder recorder, Recording recording, Boolean pathToGcRoots) throws DCmdException, IOException {
    if (recording == null) {
        // Operate on all recordings
        PlatformRecording snapshot = recorder.newTemporaryRecording();
        recorder.fillWithRecordedData(snapshot, pathToGcRoots);
        return snapshot;
    }

    PlatformRecording pr = PrivateAccess.getInstance().getPlatformRecording(recording);
    return pr.newSnapshotClone("Dumped by user", pathToGcRoots);
}
 
Example #7
Source File: Recording.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
PlatformRecording getInternal() {
    return internal;
}
 
Example #8
Source File: FlightRecorder.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
PlatformRecording newInternalRecording(Map<String, String> settings) {
    return internal.newRecording(settings);
}
 
Example #9
Source File: FlightRecorderPermission.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public PlatformRecording getPlatformRecording(Recording r) {
    return r.getInternal();
}
 
Example #10
Source File: Recording.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
PlatformRecording getInternal() {
    return internal;
}
 
Example #11
Source File: FlightRecorderPermission.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public PlatformRecording getPlatformRecording(Recording r) {
    return r.getInternal();
}
 
Example #12
Source File: Recording.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
PlatformRecording getInternal() {
    return internal;
}
 
Example #13
Source File: FlightRecorderPermission.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
public PlatformRecording getPlatformRecording(Recording r) {
    return r.getInternal();
}
 
Example #14
Source File: FlightRecorder.java    From dragonwell8_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns an immutable list of the available recordings.
 * <p>
 * A recording becomes available when it is created. It becomes unavailable when it
 * is in the {@code CLOSED} state, typically after a call to
 * {@link Recording#close()}.
 *
 * @return a list of recordings, not {@code null}
 */
public List<Recording> getRecordings() {
    List<Recording> recs = new ArrayList<>();
    for (PlatformRecording internal : internal.getRecordings()) {
        recs.add(internal.getRecording());
    }
    return Collections.unmodifiableList(recs);
}
 
Example #15
Source File: FlightRecorder.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns an immutable list of the available recordings.
 * <p>
 * A recording becomes available when it is created. It becomes unavailable when it
 * is in the {@code CLOSED} state, typically after a call to
 * {@link Recording#close()}.
 *
 * @return a list of recordings, not {@code null}
 */
public List<Recording> getRecordings() {
    List<Recording> recs = new ArrayList<>();
    for (PlatformRecording r : internal.getRecordings()) {
        recs.add(r.getRecording());
    }
    return Collections.unmodifiableList(recs);
}
 
Example #16
Source File: FlightRecorder.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns an immutable list of the available recordings.
 * <p>
 * A recording becomes available when it is created. It becomes unavailable when it
 * is in the {@code CLOSED} state, typically after a call to
 * {@link Recording#close()}.
 *
 * @return a list of recordings, not {@code null}
 */
public List<Recording> getRecordings() {
    List<Recording> recs = new ArrayList<>();
    for (PlatformRecording r : internal.getRecordings()) {
        recs.add(r.getRecording());
    }
    return Collections.unmodifiableList(recs);
}