Java Code Examples for jdk.jfr.RecordingState#DELAYED

The following examples show how to use jdk.jfr.RecordingState#DELAYED . 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: PlatformRecording.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private TimerTask createStartTask() {
    // Taking ref. to recording here.
    // Opens up for memory leaks.
    return new TimerTask() {
        @Override
        public void run() {
            synchronized (recorder) {
                if (getState() != RecordingState.DELAYED) {
                    return;
                }
                start();
            }
        }
    };
}
 
Example 2
Source File: PlatformRecorder.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
synchronized Recording newCopy(PlatformRecording r, boolean stop) {
    Recording newRec = new Recording();
    PlatformRecording copy = PrivateAccess.getInstance().getPlatformRecording(newRec);
    copy.setSettings(r.getSettings());
    copy.setMaxAge(r.getMaxAge());
    copy.setMaxSize(r.getMaxSize());
    copy.setDumpOnExit(r.getDumpOnExit());
    copy.setName("Clone of " + r.getName());
    copy.setToDisk(r.isToDisk());
    copy.setInternalDuration(r.getDuration());
    copy.setStartTime(r.getStartTime());
    copy.setStopTime(r.getStopTime());

    if (r.getState() == RecordingState.NEW) {
        return newRec;
    }
    if (r.getState() == RecordingState.DELAYED) {
        copy.scheduleStart(r.getStartTime());
        return newRec;
    }
    copy.setState(r.getState());
    // recording has started, copy chunks
    for (RepositoryChunk c : r.getChunks()) {
        copy.add(c);
    }
    if (r.getState() == RecordingState.RUNNING) {
        if (stop) {
            copy.stop("Stopped when cloning recording '" + r.getName() + "'");
        } else {
            if (r.getStopTime() != null) {
                TimerTask stopTask = copy.createStopTask();
                copy.setStopTask(copy.createStopTask());
                getTimer().schedule(stopTask, r.getStopTime().toEpochMilli());
            }
        }
    }
    return newRec;
}
 
Example 3
Source File: PlatformRecording.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private TimerTask createStartTask() {
    // Taking ref. to recording here.
    // Opens up for memory leaks.
    return new TimerTask() {
        @Override
        public void run() {
            synchronized (recorder) {
                if (getState() != RecordingState.DELAYED) {
                    return;
                }
                start();
            }
        }
    };
}
 
Example 4
Source File: PlatformRecorder.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
synchronized Recording newCopy(PlatformRecording r, boolean stop) {
    Recording newRec = new Recording();
    PlatformRecording copy = PrivateAccess.getInstance().getPlatformRecording(newRec);
    copy.setSettings(r.getSettings());
    copy.setMaxAge(r.getMaxAge());
    copy.setMaxSize(r.getMaxSize());
    copy.setDumpOnExit(r.getDumpOnExit());
    copy.setName("Clone of " + r.getName());
    copy.setToDisk(r.isToDisk());
    copy.setInternalDuration(r.getDuration());
    copy.setStartTime(r.getStartTime());
    copy.setStopTime(r.getStopTime());

    if (r.getState() == RecordingState.NEW) {
        return newRec;
    }
    if (r.getState() == RecordingState.DELAYED) {
        copy.scheduleStart(r.getStartTime());
        return newRec;
    }
    copy.setState(r.getState());
    // recording has started, copy chunks
    for (RepositoryChunk c : r.getChunks()) {
        copy.add(c);
    }
    if (r.getState() == RecordingState.RUNNING) {
        if (stop) {
            copy.stop("Stopped when cloning recording '" + r.getName() + "'");
        } else {
            if (r.getStopTime() != null) {
                TimerTask stopTask = copy.createStopTask();
                copy.setStopTask(copy.createStopTask());
                getTimer().schedule(stopTask, r.getStopTime().toEpochMilli());
            }
        }
    }
    return newRec;
}
 
Example 5
Source File: PlatformRecording.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private TimerTask createStartTask() {
    // Taking ref. to recording here.
    // Opens up for memory leaks.
    return new TimerTask() {
        @Override
        public void run() {
            synchronized (recorder) {
                if (getState() != RecordingState.DELAYED) {
                    return;
                }
                start();
            }
        }
    };
}
 
Example 6
Source File: PlatformRecorder.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
synchronized Recording newCopy(PlatformRecording r, boolean stop) {
    Recording newRec = new Recording();
    PlatformRecording copy = PrivateAccess.getInstance().getPlatformRecording(newRec);
    copy.setSettings(r.getSettings());
    copy.setMaxAge(r.getMaxAge());
    copy.setMaxSize(r.getMaxSize());
    copy.setDumpOnExit(r.getDumpOnExit());
    copy.setName("Clone of " + r.getName());
    copy.setToDisk(r.isToDisk());
    copy.setInternalDuration(r.getDuration());
    copy.setStartTime(r.getStartTime());
    copy.setStopTime(r.getStopTime());

    if (r.getState() == RecordingState.NEW) {
        return newRec;
    }
    if (r.getState() == RecordingState.DELAYED) {
        copy.scheduleStart(r.getStartTime());
        return newRec;
    }
    copy.setState(r.getState());
    // recording has started, copy chunks
    for (RepositoryChunk c : r.getChunks()) {
        copy.add(c);
    }
    if (r.getState() == RecordingState.RUNNING) {
        if (stop) {
            copy.stop("Stopped when cloning recording '" + r.getName() + "'");
        } else {
            if (r.getStopTime() != null) {
                TimerTask stopTask = copy.createStopTask();
                copy.setStopTask(copy.createStopTask());
                getTimer().schedule(stopTask, r.getStopTime().toEpochMilli());
            }
        }
    }
    return newRec;
}
 
Example 7
Source File: PlatformRecording.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public void copyTo(WriteableUserPath path, String reason, Map<String, String> dumpSettings) throws IOException {
    synchronized (recorder) {
        RecordingState state = getState();
        if (state == RecordingState.CLOSED) {
            throw new IOException("Recording \"" + name + "\" (id=" + id + ") has been closed, no contents to write");
        }
        if (state == RecordingState.DELAYED || state == RecordingState.NEW) {
            throw new IOException("Recording \"" + name + "\" (id=" + id + ") has not started, no contents to write");
        }
        if (state == RecordingState.STOPPED) {
            // have all we need, just write it
            dumpToFile(path, reason, getId());
            return;
        }

        // Recording is RUNNING, create a clone
        try(Recording r = new Recording()) {
            PlatformRecording clone = PrivateAccess.getInstance().getPlatformRecording(r);
            clone.setShouldWriteActiveRecordingEvent(false);
            clone.setName(getName());
            clone.setDestination(path);
            clone.setToDisk(true);
            // We purposely don't clone settings, since
            // a union a == a
            if (!isToDisk()) {
                // force memory contents to disk
                clone.start();
            } else {
                // using existing chunks on disk
                for (RepositoryChunk c : chunks) {
                    clone.add(c);
                }
                clone.setState(RecordingState.RUNNING);
                clone.setStartTime(getStartTime());
            }
            if (dumpSettings.isEmpty()) {
                clone.setSettings(getSettings());
                clone.stop(reason); // dumps to destination path here
            } else {
                // Risk of violating lock order here, since
                // clone.stop() will take recorder lock inside
                // metadata lock, but OK if we already
                // have recorder lock when we entered metadata lock
                Thread.holdsLock(recorder);
                synchronized(MetadataRepository.getInstance()) {
                    Thread.holdsLock(recorder);
                    Map<String, String> oldSettings = getSettings();
                    Map<String, String> newSettings = new HashMap<>(oldSettings);
                    // replace with dump settings
                    newSettings.putAll(dumpSettings);
                    clone.setSettings(newSettings);
                    clone.stop(reason);
                }
            }
        }
        return;
    }
}