--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java Wed Oct 30 16:14:56 2019 +0100
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java Wed Oct 30 19:43:52 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -84,6 +84,7 @@
private TimerTask startTask;
private AccessControlContext noDestinationDumpOnExitAccessControlContext;
private boolean shuoldWriteActiveRecordingEvent = true;
+ private Duration flushInterval = Duration.ofSeconds(1);
PlatformRecording(PlatformRecorder recorder, long id) {
// Typically the access control context is taken
@@ -98,9 +99,10 @@
this.name = String.valueOf(id);
}
- public void start() {
+ public long start() {
RecordingState oldState;
RecordingState newState;
+ long startNanos = -1;
synchronized (recorder) {
oldState = getState();
if (!Utils.isBefore(state, RecordingState.RUNNING)) {
@@ -111,7 +113,7 @@
startTask = null;
startTime = null;
}
- recorder.start(this);
+ startNanos = recorder.start(this);
Logger.log(LogTag.JFR, LogLevel.INFO, () -> {
// Only print non-default values so it easy to see
// which options were added
@@ -143,6 +145,8 @@
newState = getState();
}
notifyIfStateChanged(oldState, newState);
+
+ return startNanos;
}
public boolean stop(String reason) {
@@ -780,4 +784,28 @@
public SafePath getDumpOnExitDirectory() {
return this.dumpOnExitDirectory;
}
+
+ public void setFlushInterval(Duration interval) {
+ synchronized (recorder) {
+ if (getState() == RecordingState.CLOSED) {
+ throw new IllegalStateException("Can't set stream interval when recording is closed");
+ }
+ this.flushInterval = interval;
+ }
+ }
+
+ public Duration getFlushInterval() {
+ synchronized (recorder) {
+ return flushInterval;
+ }
+ }
+
+ public long getStreamIntervalMillis() {
+ synchronized (recorder) {
+ if (flushInterval != null) {
+ return flushInterval.toMillis();
+ }
+ return Long.MAX_VALUE;
+ }
+ }
}