Rotate disk on JFR.configure repositorypath=...
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java Wed Aug 14 20:34:11 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java Thu Aug 15 02:51:20 2019 +0200
@@ -357,6 +357,18 @@
MetadataRepository.getInstance().setSettings(list);
}
+ public synchronized void rotateIfRecordingToDisk() {
+ boolean disk = false;
+ for (PlatformRecording s : getRecordings()) {
+ if (RecordingState.RUNNING == s.getState() && s.isToDisk()) {
+ disk = true;
+ }
+ }
+ if (disk) {
+ rotateDisk();
+ }
+ }
+
synchronized void rotateDisk() {
Instant now = Instant.now();
RepositoryChunk newChunk = repository.newChunk(now);
@@ -571,4 +583,7 @@
target.setStopTime(endTime);
target.setInternalDuration(Duration.between(startTime, endTime));
}
+
+
+
}
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdConfigure.java Wed Aug 14 20:34:11 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdConfigure.java Thu Aug 15 02:51:20 2019 +0200
@@ -27,10 +27,13 @@
+import jdk.jfr.FlightRecorder;
import jdk.jfr.internal.LogLevel;
import jdk.jfr.internal.LogTag;
import jdk.jfr.internal.Logger;
import jdk.jfr.internal.Options;
+import jdk.jfr.internal.PlatformRecorder;
+import jdk.jfr.internal.PrivateAccess;
import jdk.jfr.internal.Repository;
import jdk.jfr.internal.SecuritySupport.SafePath;
@@ -89,6 +92,9 @@
SafePath s = new SafePath(repositoryPath);
Repository.getRepository().setBasePath(s);
Logger.log(LogTag.JFR, LogLevel.INFO, "Base repository path set to " + repositoryPath);
+ if (FlightRecorder.isInitialized()) {
+ PrivateAccess.getInstance().getPlatformRecorder().rotateIfRecordingToDisk();;
+ }
} catch (Exception e) {
throw new DCmdException("Could not use " + repositoryPath + " as repository. " + e.getMessage(), e);
}