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 |
79 * @return result output |
79 * @return result output |
80 * |
80 * |
81 * @throws DCmdException if recording could not be started |
81 * @throws DCmdException if recording could not be started |
82 */ |
82 */ |
83 @SuppressWarnings("resource") |
83 @SuppressWarnings("resource") |
84 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 { |
84 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 { |
85 if (Logger.shouldLog(LogTag.JFR_DCMD, LogLevel.DEBUG)) { |
85 if (Logger.shouldLog(LogTag.JFR_DCMD, LogLevel.DEBUG)) { |
86 Logger.log(LogTag.JFR_DCMD, LogLevel.DEBUG, "Executing DCmdStart: name=" + name + |
86 Logger.log(LogTag.JFR_DCMD, LogLevel.DEBUG, "Executing DCmdStart: name=" + name + |
87 ", settings=" + Arrays.asList(settings) + |
87 ", settings=" + Arrays.asList(settings) + |
88 ", delay=" + delay + |
88 ", delay=" + delay + |
89 ", duration=" + duration + |
89 ", duration=" + duration + |
90 ", disk=" + disk+ |
90 ", disk=" + disk+ |
91 ", filename=" + path + |
91 ", filename=" + path + |
92 ", maxage=" + maxAge + |
92 ", maxage=" + maxAge + |
|
93 ", flush=" + flush + |
93 ", maxsize=" + maxSize + |
94 ", maxsize=" + maxSize + |
94 ", dumponexit =" + dumpOnExit + |
95 ", dumponexit =" + dumpOnExit + |
95 ", path-to-gc-roots=" + pathToGcRoots); |
96 ", path-to-gc-roots=" + pathToGcRoots); |
96 } |
97 } |
97 if (name != null) { |
98 if (name != null) { |
134 // to avoid typo, delay shorter than 1s makes no sense. |
135 // to avoid typo, delay shorter than 1s makes no sense. |
135 throw new DCmdException("Could not start recording, delay must be at least 1 second."); |
136 throw new DCmdException("Could not start recording, delay must be at least 1 second."); |
136 } |
137 } |
137 } |
138 } |
138 |
139 |
|
140 if (flush != null) { |
|
141 if (Boolean.FALSE.equals(disk)) { |
|
142 throw new DCmdException("Flush can only be set for recordings that are to disk."); |
|
143 } |
|
144 } |
|
145 |
139 if (!FlightRecorder.isInitialized() && delay == null) { |
146 if (!FlightRecorder.isInitialized() && delay == null) { |
140 initializeWithForcedInstrumentation(s); |
147 initializeWithForcedInstrumentation(s); |
141 } |
148 } |
142 |
149 |
143 Recording recording = new Recording(); |
150 Recording recording = new Recording(); |
175 |
183 |
176 if (maxAge != null) { |
184 if (maxAge != null) { |
177 recording.setMaxAge(Duration.ofNanos(maxAge)); |
185 recording.setMaxAge(Duration.ofNanos(maxAge)); |
178 } |
186 } |
179 |
187 |
|
188 if (flush != null) { |
|
189 recording.setFlushInterval(Duration.ofNanos(flush)); |
|
190 } |
|
191 |
180 if (maxSize != null) { |
192 if (maxSize != null) { |
181 recording.setMaxSize(maxSize); |
193 recording.setMaxSize(maxSize); |
182 } |
194 } |
183 |
195 |
184 if (duration != null) { |
196 if (duration != null) { |