The object name for identifying the MXBean in the platform MBean server is:
jdk.management.jfr:type=FlightRecorder
Flight Recorder can be configured in the following ways:
See the package jdk.jfr documentation for descriptions of the settings
syntax and the ConfigurationInfo class documentation for configuration information.
The following table shows the option names to use with setRecordingOptions(long, Map)
and getRecordingOptions(long).
| Name | Description | Default value | Format | Example values |
|---|---|---|---|---|
name |
Sets a human-readable recording name | String representation of the recording id | String |
"My Recording", "profiling" |
maxAge |
Specify the length of time that the data is kept in the disk repository until the
oldest data may be deleted. Only works if disk=true, otherwise
this parameter is ignored. |
"0" (no limit) |
"0" if no limit is imposed, otherwise a string
representation of a positive long value followed by an empty space
and one of the following units,"ns" (nanoseconds)"us" (microseconds)"ms" (milliseconds)"s" (seconds)"m" (minutes)"h" (hours)"d" (days) |
"2 h","24 h","2 d","0" |
maxSize |
Specifies the size, measured in bytes, at which data is kept in the disk
repository. Only works if
disk=true, otherwise this parameter is ignored. |
"0" (no limit) |
String representation of a long value, must be positive |
"0", "1000000000" |
dumpOnExit |
Dumps recording data to disk on Java Virtual Machine (JVM) exit | "false" |
String representation of a boolean value, "true" or
"false" |
"true","false" |
destination |
Specifies the path where recording data is written when the recording stops. | "false" |
See Paths#getPath for format. If this method is invoked from another process, the data is written on the machine where the target JVM is running. If destination is a relative path, it is relative to the working directory where the target JVM was started. |
"c:\recording\recording.jfr","/recordings/recording.jfr", "recording.jfr" |
disk |
Stores recorded data as it is recorded | "false" |
String representation of a boolean value, "true" or
"false" |
"true","false" |
duration |
Specifies the duration of the recording. | "0" (no limit, continuous) |
"0" if no limit should be imposed, otherwise a string
representation of a positive long followed by an empty space and one
of the following units:"ns" (nanoseconds)"us" (microseconds)"ms" (milliseconds)"s" (seconds)"m" (minutes)"h" (hours)"d" (days) |
"60 s","10 m","4 h","0" |
| Modifier and Type | Field and Description |
|---|---|
| public static final String | MXBEAN_NAME
String representation of the |
| Modifier and Type | Method and Description |
|---|---|
| public long | Returns: a unique ID that can be used to start, stop, close and configure the recordingthe recording ID of the recording to create a clone
from recordingId, boolean if the newly created clone is stopped before
returning. stop)Creates a copy of an existing recording, useful for extracting parts of a recording. |
| public void | closeRecording(long
the ID of the recording to close recordingId)Closes the recording with the specified ID and releases any system resources that are associated with the recording. |
| public void | closeStream(long
the ID of the stream streamId)Closes the recording stream with the specified ID and releases any system resources that are associated with the stream. |
| public void | |
| public List | Returns: the list of predefined configurations, notnullReturns the list of predefined configurations for this Java Virtual Machine (JVM). |
| public List | Returns: the list of registered event types, notnullReturns the list of currently registered event types. |
| public Map | Returns: a map describing the recording options, notnullthe ID of the recording to get options for recordingId)Returns a map that contains the options for the recording with the specified ID (for example, the destination file or time span to keep recorded data). |
| public List | Returns: list of recordings, notnullReturns the list of available recordings, not necessarily running. |
| public Map | Returns: a map that describes the recording settings, notnullthe ID of the recording to get settings for recordingId)Returns a
If multiple recordings are running at the same time, more data could be
recorded than what is specified in the |
| public long | Returns: a unique ID that can be used to start, stop, close and configure the recordingCreates a recording, but doesn't start it. |
| public long | Returns: a unique ID for the stream.ID of the recording to open the stream for recordingId, Map<String, String> a map that contains the options that controls the amount of data
and how it is read, or streamOptions)null to get all data for the
recording with the default block sizeOpens a data stream for the recording with the specified ID, or |
| public byte[] | Returns: byte array that contains recording data, ornull when no more
data is availablethe ID of the stream streamId)Reads a portion of data from the stream with the specified ID, or returns
|
| public void | setConfiguration(long
ID of the recording recordingId, String a string representation of the configuration file to use,
not contents)nullSets a configuration as a string representation for the recording with the specified ID. |
| public void | setPredefinedConfiguration(long
ID of the recording to set the configuration for recordingId, String the name of the configuration (for example,
configurationName)"profile" or "default"), not nullSets a predefined configuration for the recording with the specified ID. |
| public void | setRecordingOptions(long
the ID of the recording to set options for recordingId, Map<String, String> name/value map of the settings to set, not options)nullConfigures the recording options (for example, destination file and time span to keep data). |
| public void | setRecordingSettings(long
ID of the recording recordingId, Map<String, String> name value map of the settings to set, not settings)nullSets and replaces all previous settings for the specified recording. |
| public void | startRecording(long
ID of the recording to start recordingId)Starts the recording with the specified ID. A recording that is stopped can't be restarted. |
| public boolean | Returns: true if the recording is stopped, false
otherwisethe ID of the recording to stop recordingId)Stops the running recording with the specified ID. |
| public long | Returns: a unique ID that can be used for reading recording dataCreates a snapshot recording of all available recorded data. |
| MXBEAN_NAME | back to summary |
|---|---|
| public static final String MXBEAN_NAME String representation of the | |
| cloneRecording | back to summary |
|---|---|
| public long cloneRecording(long recordingId, boolean stop) throws IllegalArgumentException Creates a copy of an existing recording, useful for extracting parts of a recording.
The cloned recording contains the same recording data as the
original, but it has a new ID and a name prefixed with
| |
| closeRecording | back to summary |
|---|---|
| public void closeRecording(long recordingId) throws IOException Closes the recording with the specified ID and releases any system resources that are associated with the recording. If the recording is already closed, invoking this method has no effect.
| |
| closeStream | back to summary |
|---|---|
| public void closeStream(long streamId) throws IOException Closes the recording stream with the specified ID and releases any system resources that are associated with the stream. If the stream is already closed, invoking this method has no effect.
| |
| copyTo | back to summary |
|---|---|
| public void copyTo(long recordingId, String outputFile) throws IOException Writes recording data to the specified file.
If this method is invoked remotely from another process, the data is written
to a file named
| |
| getConfigurations | back to summary |
|---|---|
| public List Returns the list of predefined configurations for this Java Virtual Machine (JVM).
MBeanServer access:
| |
| getEventTypes | back to summary |
|---|---|
| public List Returns the list of currently registered event types.
MBeanServer access:
| |
| getRecordingOptions | back to summary |
|---|---|
| public Map Returns a map that contains the options for the recording with the specified ID (for example, the destination file or time span to keep recorded data).
See
| |
| getRecordings | back to summary |
|---|---|
| public List Returns the list of available recordings, not necessarily running.
MBeanServer access:
| |
| getRecordingSettings | back to summary |
|---|---|
| public Map Returns a
If multiple recordings are running at the same time, more data could be
recorded than what is specified in the
The name in the
| |
| newRecording | back to summary |
|---|---|
| public long newRecording() throws IllegalStateException Creates a recording, but doesn't start it.
| |
| openStream | back to summary | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| public long openStream(long recordingId, Map<String, String> streamOptions) throws IOException Opens a data stream for the recording with the specified ID, or
The recording with the specified ID must be stopped before a stream can
be opened, unless the option
| ||||||||||||||||||||||||||
| readStream | back to summary |
|---|---|
| public byte[] readStream(long streamId) throws IOException Reads a portion of data from the stream with the specified ID, or returns
To read all data for a recording, invoke this method repeatedly until
| |
| setConfiguration | back to summary |
|---|---|
| public void setConfiguration(long recordingId, String contents) throws IllegalArgumentException Sets a configuration as a string representation for the recording with the specified ID.
| |
| setPredefinedConfiguration | back to summary |
|---|---|
| public void setPredefinedConfiguration(long recordingId, String configurationName) throws IllegalArgumentException Sets a predefined configuration for the recording with the specified ID.
| |
| setRecordingOptions | back to summary |
|---|---|
| public void setRecordingOptions(long recordingId, Map<String, String> options) throws IllegalArgumentException Configures the recording options (for example, destination file and time span to keep data).
See
| |
| setRecordingSettings | back to summary |
|---|---|
| public void setRecordingSettings(long recordingId, Map<String, String> settings) throws IllegalArgumentException Sets and replaces all previous settings for the specified recording. A setting consists of a name/value pair, where name specifies the event and setting to configure, and the value specifies what to set it to. The name can be formed in the following ways:
or
For example, to set the sample interval of the CPU Load event to once every
second, use the name
A list of available event names is retrieved by invoking
| |
| startRecording | back to summary |
|---|---|
| public void startRecording(long recordingId) throws IllegalStateException Starts the recording with the specified ID. A recording that is stopped can't be restarted.
| |
| stopRecording | back to summary |
|---|---|
| public boolean stopRecording(long recordingId) throws IllegalArgumentException, IllegalStateException Stops the running recording with the specified ID.
| |
| takeSnapshot | back to summary |
|---|---|
| public long takeSnapshot() Creates a snapshot recording of all available recorded data.
A snapshot is a synthesized recording in a stopped state. If no data is
available, a recording with size A snapshot provides stable access to data for later operations (for example, operations to change the time interval or to reduce the data size). The caller must close the recording when access to the data is no longer needed.
| |