1 /* |
1 /* |
2 * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
78 * @return result output |
78 * @return result output |
79 * |
79 * |
80 * @throws DCmdException if recording could not be started |
80 * @throws DCmdException if recording could not be started |
81 */ |
81 */ |
82 @SuppressWarnings("resource") |
82 @SuppressWarnings("resource") |
83 public String execute(String name, String[] settings, Long delay, Long duration, Boolean disk, String path, Long maxAge, Long maxSize, Boolean dumpOnExit, Boolean pathToGcRoots) throws DCmdException { |
83 public String execute(String name, String[] settings, Long delay, Long duration, Boolean disk, String path, Long maxAge, Long maxSize, Long flush, Boolean dumpOnExit, Boolean pathToGcRoots) throws DCmdException { |
84 if (Logger.shouldLog(LogTag.JFR_DCMD, LogLevel.DEBUG)) { |
84 if (Logger.shouldLog(LogTag.JFR_DCMD, LogLevel.DEBUG)) { |
85 Logger.log(LogTag.JFR_DCMD, LogLevel.DEBUG, "Executing DCmdStart: name=" + name + |
85 Logger.log(LogTag.JFR_DCMD, LogLevel.DEBUG, "Executing DCmdStart: name=" + name + |
86 ", settings=" + Arrays.asList(settings) + |
86 ", settings=" + Arrays.asList(settings) + |
87 ", delay=" + delay + |
87 ", delay=" + delay + |
88 ", duration=" + duration + |
88 ", duration=" + duration + |
89 ", disk=" + disk+ |
89 ", disk=" + disk+ |
90 ", filename=" + path + |
90 ", filename=" + path + |
91 ", maxage=" + maxAge + |
91 ", maxage=" + maxAge + |
|
92 ", flush=" + flush + |
92 ", maxsize=" + maxSize + |
93 ", maxsize=" + maxSize + |
93 ", dumponexit =" + dumpOnExit + |
94 ", dumponexit =" + dumpOnExit + |
94 ", path-to-gc-roots=" + pathToGcRoots); |
95 ", path-to-gc-roots=" + pathToGcRoots); |
95 } |
96 } |
96 if (name != null) { |
97 if (name != null) { |
129 // to avoid typo, delay shorter than 1s makes no sense. |
130 // to avoid typo, delay shorter than 1s makes no sense. |
130 throw new DCmdException("Could not start recording, delay must be at least 1 second."); |
131 throw new DCmdException("Could not start recording, delay must be at least 1 second."); |
131 } |
132 } |
132 } |
133 } |
133 |
134 |
|
135 if (flush != null) { |
|
136 if (Boolean.FALSE.equals(disk)) { |
|
137 throw new DCmdException("Flush can only be set for recordings that are to disk."); |
|
138 } |
|
139 } |
|
140 |
134 if (!FlightRecorder.isInitialized() && delay == null) { |
141 if (!FlightRecorder.isInitialized() && delay == null) { |
135 initializeWithForcedInstrumentation(s); |
142 initializeWithForcedInstrumentation(s); |
136 } |
143 } |
137 |
144 |
138 Recording recording = new Recording(); |
145 Recording recording = new Recording(); |
170 |
178 |
171 if (maxAge != null) { |
179 if (maxAge != null) { |
172 recording.setMaxAge(Duration.ofNanos(maxAge)); |
180 recording.setMaxAge(Duration.ofNanos(maxAge)); |
173 } |
181 } |
174 |
182 |
|
183 if (flush != null) { |
|
184 recording.setFlushInterval(Duration.ofNanos(flush)); |
|
185 } |
|
186 |
175 if (maxSize != null) { |
187 if (maxSize != null) { |
176 recording.setMaxSize(maxSize); |
188 recording.setMaxSize(maxSize); |
177 } |
189 } |
178 |
190 |
179 if (duration != null) { |
191 if (duration != null) { |