Rename flush to flush-interval and add test for jcmd and -XX:StartFlightRecording
--- a/src/hotspot/share/jfr/dcmd/jfrDcmds.cpp Fri Aug 23 14:00:10 2019 +0200
+++ b/src/hotspot/share/jfr/dcmd/jfrDcmds.cpp Fri Aug 23 15:34:18 2019 +0200
@@ -349,7 +349,7 @@
_filename("filename", "Resulting recording filename, e.g. \\\"" JFR_FILENAME_EXAMPLE "\\\"", "STRING", false),
_maxage("maxage", "Maximum time to keep recorded data (on disk) in (s)econds, (m)inutes, (h)ours, or (d)ays, e.g. 60m, or 0 for no limit", "NANOTIME", false, "0"),
_maxsize("maxsize", "Maximum amount of bytes to keep (on disk) in (k)B, (M)B or (G)B, e.g. 500M, or 0 for no limit", "MEMORY SIZE", false, "0"),
- _flush("flush", "Maximum time before flushing buffers, measuare in (s)econds, e.g. 4 s, or 0 for flushing when a recording ends", "NANOTIME", false, "0"),
+ _flush_interval("flush-interval", "Minimum time before flushing buffers, measuared in (s)econds, e.g. 4 s, or 0 for flushing when a recording ends", "NANOTIME", false, "0"),
_dump_on_exit("dumponexit", "Dump running recording when JVM shuts down", "BOOLEAN", false),
_path_to_gc_roots("path-to-gc-roots", "Collect path to GC roots", "BOOLEAN", false, "false") {
_dcmdparser.add_dcmd_option(&_name);
@@ -360,7 +360,7 @@
_dcmdparser.add_dcmd_option(&_filename);
_dcmdparser.add_dcmd_option(&_maxage);
_dcmdparser.add_dcmd_option(&_maxsize);
- _dcmdparser.add_dcmd_option(&_flush);
+ _dcmdparser.add_dcmd_option(&_flush_interval);
_dcmdparser.add_dcmd_option(&_dump_on_exit);
_dcmdparser.add_dcmd_option(&_path_to_gc_roots);
};
@@ -413,9 +413,9 @@
maxsize = JfrJavaSupport::new_java_lang_Long(_maxsize.value()._size, CHECK);
}
- jobject flush = NULL;
- if (_flush.is_set()) {
- flush = JfrJavaSupport::new_java_lang_Long(_flush.value()._nanotime, CHECK);
+ jobject flush_interval = NULL;
+ if (_flush_interval.is_set()) {
+ flush_interval = JfrJavaSupport::new_java_lang_Long(_flush_interval.value()._nanotime, CHECK);
}
jobject duration = NULL;
if (_duration.is_set()) {
@@ -478,7 +478,7 @@
execute_args.push_jobject(filename);
execute_args.push_jobject(maxage);
execute_args.push_jobject(maxsize);
- execute_args.push_jobject(flush);
+ execute_args.push_jobject(flush_interval);
execute_args.push_jobject(dump_on_exit);
execute_args.push_jobject(path_to_gc_roots);
--- a/src/hotspot/share/jfr/dcmd/jfrDcmds.hpp Fri Aug 23 14:00:10 2019 +0200
+++ b/src/hotspot/share/jfr/dcmd/jfrDcmds.hpp Fri Aug 23 15:34:18 2019 +0200
@@ -90,7 +90,7 @@
DCmdArgument<char*> _filename;
DCmdArgument<NanoTimeArgument> _maxage;
DCmdArgument<MemorySizeArgument> _maxsize;
- DCmdArgument<NanoTimeArgument> _flush;
+ DCmdArgument<NanoTimeArgument> _flush_interval;
DCmdArgument<bool> _dump_on_exit;
DCmdArgument<bool> _path_to_gc_roots;
--- a/src/jdk.jfr/share/classes/jdk/jfr/Recording.java Fri Aug 23 14:00:10 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/Recording.java Fri Aug 23 15:34:18 2019 +0200
@@ -433,7 +433,7 @@
/**
* Returns how often events are made available for streaming purposes.
*
- * @return the desired stream interval, or {@code null} if no interval has been set
+ * @return the flush interval, or {@code null} if no interval has been set
*/
public Duration getFlushInterval() {
return internal.getFlushInterval();
--- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/UseCasesStream.java Fri Aug 23 14:00:10 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/UseCasesStream.java Fri Aug 23 15:34:18 2019 +0200
@@ -129,7 +129,7 @@
public static void repositoryAccess() throws IOException, InterruptedException {
Path repository = Paths.get("c:\\repository").toAbsolutePath();
String command = new String();
- command += "java -XX:StartFlightRecording:flush=2s";
+ command += "java -XX:StartFlightRecording:flush-interval=2s";
command += "-XX:FlightRecorderOption:repository=" + repository + " Application";
Process myProcess = Runtime.getRuntime().exec(command);
try (RecordingStream rs = new RecordingStream()) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/jdk/jfr/jcmd/TestJcmdStartFlushInterval.java Fri Aug 23 15:34:18 2019 +0200
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2015, 2018, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.jfr.jcmd;
+
+import java.time.Duration;
+
+import jdk.jfr.FlightRecorder;
+import jdk.jfr.Recording;
+
+/**
+ * @test
+ * @summary Start a recording with a flush interval
+ * @key jfr
+ * @requires vm.hasJFR
+ * @library /test/lib /test/jdk
+ * @run main/othervm jdk.jfr.jcmd.TestJcmdStartReadOnlyFile
+ */
+public class TestJcmdStartFlushInterval {
+
+ public static void main(String[] args) throws Exception {
+ JcmdHelper.jcmd("JFR.start","flush-interval=1s");
+ for (Recording r : FlightRecorder.getFlightRecorder().getRecordings()) {
+ Duration d = r.getFlushInterval();
+ if (d.equals(Duration.ofSeconds(1))) {
+ return; //OK
+ } else {
+ throw new Exception("Unexpected flush-interval=" + d);
+ }
+ }
+ throw new Exception("No recording found");
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/jdk/jfr/startupargs/TestFlushInterval.java Fri Aug 23 15:34:18 2019 +0200
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2013, 2018, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.jfr.startupargs;
+
+import java.time.Duration;
+
+import jdk.jfr.FlightRecorder;
+import jdk.jfr.Recording;
+
+/**
+ * @test
+ * @summary Start a recording with a flush interval
+ * @key jfr
+ * @requires vm.hasJFR
+ * @library /test/lib /test/jdk
+ * @run main/othervm -XX:StartFlightRecording=flush-interval=1s jdk.jfr.startupargs.TestFlushInterval
+ */
+public class TestFlushInterval {
+
+ public static void main(String[] args) throws Exception {
+ for (Recording r : FlightRecorder.getFlightRecorder().getRecordings()) {
+ Duration d = r.getFlushInterval();
+ if (d.equals(Duration.ofSeconds(1))) {
+ return; //OK
+ } else {
+ throw new Exception("Unexpected flush-interval " + d);
+ }
+ }
+ throw new Exception("No recording found");
+ }
+
+}