- All Superinterfaces:
- PlatformManagedObject
public interface FlightRecorderMXBean extends PlatformManagedObject
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:
- Recording options
 Specify how long a recording should last, and where and when data should be dumped.
- Settings
 Specify which events should be enabled and what kind information each event should capture.
- Configurations
 Predefined sets of settings, typically derived from a settings file, that specify the configuration of multiple events simultaneously.
 See the package jdk.jfr documentation for descriptions of the settings
 syntax and the ConfigurationInfo class documentation for configuration information.
 
Recording options
 The following table shows the options names to use with setRecordingOptions(long, Map)
 and getRecordingOptions(long).
 
| Name | Descripion | 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 positiveLongvalue 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 disk
 repository. Only works if disk=true, otherwise this parameter is ignored. | "0"(no limit) | String representation of a Longvalue, must be positive | "0","1000000000" | 
| dumpOnExit | Dumps recording data to disk on Java Virtual Machine (JVM) exit | "false" | String representation of a Booleanvalue,"true"or"false" | "true","false" | 
| destination | Specifies the path where recording data is written when the recording stops. | "false" | See Paths#getPathfor 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\recotding.jfr","/recordings/recording.jfr","recording.jfr" | 
| disk | Stores recorded data as it is recorded | "false" | String representation of a Booleanvalue,"true"or"false" | "true","false" | 
| duration | Sets how long the recording should be running | "0"(no limit, continuous) | "0"if no limit should be imposed, otherwise a string
 representation of a positiveLongfollowed 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" | 
- Since:
- 9
- 
Field SummaryFields Modifier and Type Field Description static StringMXBEAN_NAMEString representation of theObjectNamefor theFlightRecorderMXBean.
- 
Method SummaryModifier and Type Method Description longcloneRecording(long recordingId, boolean stop)Creates a copy of an existing recording, useful for extracting parts of a recording.voidcloseRecording(long recordingId)Closes the recording with the specified ID and releases any system resources that are associated with the recording.voidcloseStream(long streamId)Closes the recording stream with the specified ID and releases any system resources that are associated with the stream.voidcopyTo(long recordingId, String outputFile)Writes recording data to the specified file.List<ConfigurationInfo>getConfigurations()Returns the list of predefined configurations for this Java Virtual Machine (JVM).List<EventTypeInfo>getEventTypes()Returns the list of currently registered event types.Map<String,String>getRecordingOptions(long 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).List<RecordingInfo>getRecordings()Returns the list of the available recordings, not necessarily running.Map<String,String>getRecordingSettings(long recordingId)Returns aMapthat contains the settings for the recording with the specified ID, (for example, the event thresholds)longnewRecording()Creates a recording, but doesn't start it.longopenStream(long recordingId, Map<String,String> streamOptions)Opens a data stream for the recording with the specified ID, or0to get data irrespective of recording.byte[]readStream(long streamId)Reads a portion of data from the stream with the specified ID, or returnsnullif no more data is available.voidsetConfiguration(long recordingId, String contents)Sets a configuration as a string representation for the recording with the specified ID.voidsetPredefinedConfiguration(long recordingId, String configurationName)Sets a predefined configuration for the recording with the specified ID.voidsetRecordingOptions(long recordingId, Map<String,String> options)Configures the recording options (for example, destination file and time span to keep data).voidsetRecordingSettings(long recordingId, Map<String,String> settings)Sets and replaces all previous settings for the specified recording.voidstartRecording(long recordingId)Starts the recording with the specified ID.booleanstopRecording(long recordingId)Stops the running recording with the specified ID.longtakeSnapshot()Creates a snapshot recording of all available recorded data.
- 
Field Details- 
MXBEAN_NAMEString representation of theObjectNamefor theFlightRecorderMXBean.- See Also:
- Constant Field Values
 
 
- 
- 
Method Details- 
newRecordingCreates a recording, but doesn't start it.- Returns:
- a unique ID that can be used to start, stop, close and configure the recording
- Throws:
- IllegalStateException- if Flight Recorder can't be created (for example, if the Java Virtual Machine (JVM) lacks Flight Recorder support, or if the file repository can't be created or accessed)
- SecurityException- if a security manager exists and the caller does not have- ManagementPermission("control")
- See Also:
- Recording
 
- 
takeSnapshotlong 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 0is returned.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. - Returns:
- a snapshot of all available recording data, not null
- Throws:
- SecurityException- if a security manager exists and the caller does not have- ManagementPermission("control")
- See Also:
- Recording
 
- 
cloneRecordinglong cloneRecording(long recordingId, boolean stop) throws IllegalArgumentException, SecurityExceptionCreates 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 "Clone of recording". If the original recording is running, then the clone is also running.- Parameters:
- recordingId- the recording ID of the recording to create a clone from
- stop- if the newly created clone is stopped before returning.
- Returns:
- a unique ID that can be used to start, stop, close and configure the recording
- Throws:
- IllegalArgumentException- if a recording with the specified ID doesn't exist
- SecurityException- if a security manager exists and the caller does not have- ManagementPermission("control")
- See Also:
- Recording
 
- 
startRecordingStarts the recording with the specified ID.A recording that is stopped can't be restarted. - Parameters:
- recordingId- ID of the recording to start
- Throws:
- IllegalArgumentException- if a recording with the specified ID doesn't exist
- SecurityException- if a security manager exists and the caller does not have- ManagementPermission("control")
- IllegalStateException
- See Also:
- Recording
 
- 
stopRecordingboolean stopRecording(long recordingId) throws IllegalArgumentException, IllegalStateException, SecurityExceptionStops the running recording with the specified ID.- Parameters:
- recordingId- the ID of the recording to stop
- Returns:
- trueif the recording is stopped,- falseotherwise
- Throws:
- IllegalArgumentException- if a recording with the specified ID doesn't exist
- IllegalStateException- if the recording is not running
- SecurityException- if a security manager exists and the caller does not have- ManagementPermission("control")
- See Also:
- newRecording()
 
- 
closeRecordingCloses 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. - Parameters:
- recordingId- the ID of the recording to close
- Throws:
- IllegalArgumentException- if a recording with the specified ID doesn't exist
- IOException- if an I/O error occurs
- SecurityException- if a security manager exists and the caller does not have- ManagementPermission("control")
- See Also:
- newRecording()
 
- 
openStreamOpens a data stream for the recording with the specified ID, or0to get data irrespective of recording.
 If an option is omitted from the map the default value is used.Recording stream options Name Descripion Default value Format Example values startTimeSpecifies the point in time to start a recording stream. Due to how data is stored, some events that start or end prior to the start time may be included. Instant.MIN_VALUE.toString()ISO-8601. See Instant.toString()
 or milliseconds since epoch"2015-11-03T00:00",
 "1446508800000"endTimeSpecifies the point in time to end a recording stream. Due to how data is stored, some events that start or end after the end time may be included. Instant.MAX_VALUE.toString()ISO-8601. See Instant.toString()
 or milliseconds since epoch"2015-11-03T01:00",
 "1446512400000"blockSizeSpecifies the maximum number of bytes to read with a call to readStream"50000"A positive longvalue.
 
 SettingblockSizeto a very high value may result inOutOfMemoryErroror anIllegalArgumentException, if the Java Virtual Machine (JVM) deems the value too large to handle."50000",
 "1000000",
 The recording with the specified ID must be stopped before a stream can be opened. This restriction might be lifted in future releases. - Parameters:
- recordingId- ID of the recording to open the stream for
- streamOptions- a map that contains the options that controls the amount of data and how it is read, or- nullto get all data for the recording with the default block size
- Returns:
- a unique ID for the stream.
- Throws:
- IllegalArgumentException- if a recording with the iD doesn't exist, or if- optionscontains invalid values
- IOException- if the recording is closed, an I/O error occurs, or no data is available for the specified recording or interval
- SecurityException- if a security manager exists and the caller does not have- ManagementPermission("control")
 
- 
closeStreamCloses 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. - Parameters:
- streamId- the ID of the stream
- Throws:
- IllegalArgumentException- if a stream with the specified ID doesn't exist
- IOException- if an I/O error occurs while trying to close the stream
- SecurityException- if a security manager exists and the caller does not have- ManagementPermission("control")
- See Also:
- openStream(long, Map)
 
- 
readStreamReads a portion of data from the stream with the specified ID, or returnsnullif no more data is available.To read all data for a recording, invoke this method repeatedly until nullis returned.- Parameters:
- streamId- the ID of the stream
- Returns:
- byte array that contains recording data, or nullwhen no more data is available
- Throws:
- IOException- if the stream is closed, or an I/O error occurred while trying to read the stream
- IllegalArgumentException- if no recording with the stream ID exists
- SecurityException- if a security manager exists and the caller does not have- ManagementPermission("monitor")
 
- 
getRecordingOptionsReturns 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 FlightRecorderMXBeanfor available option names.- Parameters:
- recordingId- the ID of the recording to get options for
- Returns:
- a map describing the recording options, not null
- Throws:
- IllegalArgumentException- if no recording with the specified ID exists
- SecurityException- if a security manager exists and the caller does not have- ManagementPermission("monitor")
 
- 
getRecordingSettingsReturns aMapthat contains the settings for the recording with the specified ID, (for example, the event thresholds)If multiple recordings are running at the same time, more data could be recorded than what is specified in the Mapobject.The name in the Mapis the event name and the setting name separated by"#"(for example,"jdk.VMInfo#period"). The value is a textual representation of the settings value (for example,"60 s").- Parameters:
- recordingId- the ID of the recordings to get settings for
- Returns:
- a map that describes the recording settings, not null
- Throws:
- IllegalArgumentException- if no recording with the specified ID exists
- SecurityException- if a security manager exists and the caller does not have- ManagementPermission("monitor")
 
- 
setConfigurationSets a configuration as a string representation for the recording with the specified ID.- Parameters:
- recordingId- ID of the recording
- contents- a string representation of the configuration file to use, not- null
- Throws:
- IllegalArgumentException- if no recording with the specified ID exists or if the configuration could not be parsed.
- SecurityException- if a security manager exists and the caller does not have- ManagementPermission("control")
- See Also:
- Configuration.getContents()
 
- 
setPredefinedConfigurationvoid setPredefinedConfiguration(long recordingId, String configurationName) throws IllegalArgumentExceptionSets a predefined configuration for the recording with the specified ID.- Parameters:
- recordingId- ID of the recording to set the configuration for
- configurationName- the name of the configuration (for example,- "profile"or- "default"), not- null
- Throws:
- IllegalArgumentException- if no recording with the specified ID exists
- SecurityException- if a security manager exists and the caller does not have- ManagementPermission("control")
- See Also:
- getConfigurations()
 
- 
setRecordingSettingsvoid setRecordingSettings(long recordingId, Map<String,String> settings) throws IllegalArgumentExceptionSets 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: <event-name> + "#" + <setting-name>or <event-id> + "#" + <setting-name>For example, to set the sample interval of the CPU Load event to once every second, use the name "jdk.CPULoad#period"and the value"1 s". If multiple events use the same name, for example if an event class is loaded in multiple class loaders, and differentiation is needed between them, then the name is"56#period". The ID for an event is obtained by invokingEventType.getId()method and is valid for the Java Virtual Machine (JVM) instance that the event is registered in.A list of available event names is retrieved by invoking FlightRecorder.getEventTypes()andEventType.getName(). A list of available settings for an event type is obtained by invokingEventType.getSettingDescriptors()andValueDescriptor.getName().- Parameters:
- recordingId- ID of the recording
- settings- name value map of the settings to set, not- null
- Throws:
- IllegalArgumentException- if no recording with the specified ID exists
- SecurityException- if a security manager exists and the caller does not have- ManagementPermission("control")
- See Also:
- Recording.getId()
 
- 
setRecordingOptionsvoid setRecordingOptions(long recordingId, Map<String,String> options) throws IllegalArgumentExceptionConfigures the recording options (for example, destination file and time span to keep data).See FlightRecorderMXBeanfor a description of the options and values that can be used. Setting a value tonullrestores the value to the default value.- Parameters:
- recordingId- the ID of the recording to set options for
- options- name/value map of the settings to set, not- null
- Throws:
- IllegalArgumentException- if no recording with the specified ID exists
- SecurityException- if a security manager exists, and the caller does not have- ManagementPermission("control")or an option contains a file that the caller does not have permission to operate on.
- See Also:
- Recording.getId()
 
- 
getRecordingsList<RecordingInfo> getRecordings()Returns the list of the available recordings, not necessarily running.MBeanServer access: 
 The mapped type ofRecordingInfoisCompositeDatawith attributes as specified in theRecordingInfo.frommethod.- Returns:
- list of recordings, not null
- Throws:
- SecurityException- if a security manager exists and the caller does not have- ManagementPermission("monitor")
- See Also:
- RecordingInfo,- Recording
 
- 
getConfigurationsList<ConfigurationInfo> getConfigurations()Returns the list of predefined configurations for this Java Virtual Machine (JVM).MBeanServer access: 
 The mapped type ofConfigurationInfoisCompositeDatawith attributes as specified in theConfigurationInfo.frommethod.- Returns:
- the list of predefined configurations, not null
- Throws:
- SecurityException- if a security manager exists and the caller does not have- ManagementPermission("monitor")
- See Also:
- ConfigurationInfo,- Configuration
 
- 
getEventTypesList<EventTypeInfo> getEventTypes()Returns the list of currently registered event types.MBeanServer access: 
 The mapped type ofEventTypeInfoisCompositeDatawith attributes as specified in theEventTypeInfo.frommethod.- Returns:
- the list of registered event types, not null
- Throws:
- SecurityException- if a security manager exists and the caller does not have- ManagementPermission("monitor")
- See Also:
- EventTypeInfo,- EventType
 
- 
copyToWrites recording data to the specified file.If this method is invoked remotely from another process, the data is written to a file named outputFileon the machine where the target Java Virtual Machine (JVM) is running. If the file location is a relative path, it is relative to the working directory where the target JVM was started.- Parameters:
- recordingId- the ID of the recording to dump data for
- outputFile- the system-dependent file name where data is written, not- null
- Throws:
- IOException- if the recording can't be dumped due to an I/O error (for example, an invalid path)
- IllegalArgumentException- if a recording with the specified ID doesn't exist
- IllegalStateException- if the recording is not yet started or if it is already closed
- SecurityException- if a security manager exists and its- SecurityManager.checkWrite(java.lang.String)method denies write access to the named file or the caller does not have- ManagmentPermission("control")
- See Also:
- Path.toString(),- Recording.dump(java.nio.file.Path)
 
 
-