Class Controller
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoidadvanceGeneration(String description) Advances object generation number.Captures snapshot with heap data in HPROF format.Captures JFR snapshot.Captures snapshot with heap data.Captures snapshot without heap data.voidclearEventTables(List<? extends String> tableNames) Clears event table(s) by name.voidforceGc()Forces garbage collection in the profiled application.Map<? extends String, ? extends ProbeActivityMode> Obtains current trigger description.static Controller.BuildervoidClears recorded allocations.voidClears current results of CPU profiling in any mode, be it sampling, tracing or call counting.voidClears recorded exceptions.voidresetJfr()Clears the collected flight recording data and continues the recording if it is active.voidClears monitor profiling data.voidClears telemetry.voidClears the collected thread profiling data and continues the thread profiling if it is active.voidsetProbeActivityModes(Map<? extends String, ? extends ProbeActivityMode> probeClassName2Mode) Changes probe activity modes of the specified probes.voidsetTriggers(String triggers, boolean append) Sets triggers.voidStarts object allocation profiling.voidstartAsyncSamplingCpu(CpuProfilingSettings settings) Starts asynchronous CPU sampling.voidStarts asynchronous periodic sampling.voidStarts CPU call counting.voidStarts exception profiling.voidstartJfr(JfrSettings settings) Starts flight recording.voidStarts monitor profiling.voidstartSampling(CpuProfilingSettings settings) Starts CPU sampling.voidStarts collecting performance telemetry.voidstartThreadProfiling(ThreadProfilingSettings settings) Starts thread profiling.voidstartTracing(CpuProfilingSettings settings) Starts CPU tracing.voidStops allocation profiling.voidStops CPU profiling in any mode, be it sampling, tracing or call counting.voidStops exception profiling.voidstopJfr()Stops flight recording.voidStops monitor profiling.voidStops collecting performance telemetry.voidStops thread profiling.
-
Method Details
-
newBuilder
- Returns:
- New builder to construct the
Controller.
-
advanceGeneration
Advances object generation number.
- Parameters:
description- Optional description associated with the generation.- Throws:
IOException
-
capturePerformanceSnapshot
Captures snapshot without heap data.- Returns:
- Absolute file path of the captured snapshot file. If a remote application is being profiled, then the path is in the file system of the remote host.
- Throws:
IOException
-
captureMemorySnapshot
Captures snapshot with heap data.- Returns:
- Absolute file path of the captured snapshot file. If a remote application is being profiled, then the path is in the file system of the remote host.
- Throws:
IOException
-
captureHprofSnapshot
Captures snapshot with heap data in HPROF format.- Returns:
- Absolute file path of the captured snapshot file. If a remote application is being profiled, then the path is in the file system of the remote host.
- Throws:
ControllerException- If JVM does not support HPROF snapshots.IOException
-
getAddress
- Returns:
- Profiler agent address.
-
forceGc
Forces garbage collection in the profiled application.- Throws:
IOException
-
getJvmTelemetry
- Returns:
- Current
JvmTelemetry. - Throws:
IOException
-
getStatus
- Returns:
Statusof the profiler agent. You can also use getStatus counter-part from the HTTP API.- Throws:
IOException
-
getTotalCreatedObjects
- Returns:
- Statistics of object allocation profiling.
- Throws:
IOException- See Also:
-
getProbeActivityModes
@NotNull public Map<? extends String,? extends ProbeActivityMode> getProbeActivityModes() throws IOException- Returns:
- The mapping of probe class names to the
ProbeActivityMode. - Throws:
IOException
-
setProbeActivityModes
public void setProbeActivityModes(@NotNull Map<? extends String, ? extends ProbeActivityMode> probeClassName2Mode) throws IOExceptionChanges probe activity modes of the specified probes.- Parameters:
probeClassName2Mode- Mapping of probe class names toProbeActivityMode. It specifies the probes whose mode should be changed. If a probe is not present in the mapping, its mode will remain unchanged.- Throws:
IOException
-
getTriggers
Obtains current trigger description.- Returns:
- Description of triggers.
The returned value is never
null. If there are no triggers, an empty string will be returned. - Throws:
IOException
-
setTriggers
public void setTriggers(@NotNull String triggers, boolean append) throws IOException, ControllerException Sets triggers.- Parameters:
triggers- Description of trigger(s). See detail hereappend- IfTRUE, the triggers will be added to the currently existing triggers, ifFALSE- will replace them.- Throws:
ControllerException- Possible reasons:- The trigger description is invalid.
IOException
-
resetAllocationProfiling
Clears recorded allocations.Note: when allocation profiling starts, collected allocation data is cleared automatically, so you do not have to explicitly call this method in that case.
- Throws:
IOException
-
resetCpuProfiling
Clears current results of CPU profiling in any mode, be it sampling, tracing or call counting.Note: when CPU profiling starts, collected CPU profiling data is cleared automatically, so you do not have to explicitly call this method in that case.
- Throws:
IOException
-
clearEventTables
Clears event table(s) by name. If the specified tables have dependent tables, they will be cleared too.- Throws:
IOException
-
resetExceptionProfiling
Clears recorded exceptions.Note: when exception profiling starts, recorded exceptions are cleared automatically, so you do not have to explicitly call this method in that case.
- Throws:
IOException
-
resetMonitorProfiling
Clears monitor profiling data.Note: when monitor profiling starts, collected monitor profiling data is cleared automatically, so you do not have to explicitly call this method in that case.
- Throws:
IOException
-
startAllocationProfiling
public void startAllocationProfiling(@NotNull AllocationProfilingSettings settings) throws IOException, ControllerException Starts object allocation profiling. The method clears previously recorded allocation data.If allocation profiling is already running, it will reset and start anew.
- Throws:
ControllerException- Possible reasons:- Allocation profiling has been disabled for the profiled application with startup options 'disable_alloc' or 'disable_all'.
IOException
-
startAsyncSamplingCpu
public void startAsyncSamplingCpu(@NotNull CpuProfilingSettings settings) throws IOException, ControllerException Starts asynchronous CPU sampling.
Asynchronous sampling is a low-overhead profiling mode that does not suffer from the Safepoint bias problem. It features HotSpot-specific APIs to collect stack traces. It works with OpenJDK, Oracle JDK and other Java runtimes based on the HotSpot JVM.
Time measurement accuracy is high for methods consuming CPU cycles. Methods like sleep() and wait() which don't consume much CPU time will not be shown in the results.
If CPU profiling is already running, it will reset and start anew.
- Parameters:
settings- CPU sampling settings. Passnullto use the profiled application's settings, or pass your custom settings as a non-nullstring.- Throws:
ControllerException- Possible reasons:- Asynchronous sampling is not supported by the JVM.
IOException
-
startAsyncSamplingPeriodic
public void startAsyncSamplingPeriodic(@NotNull CpuProfilingSettings settings) throws IOException, ControllerException Starts asynchronous periodic sampling.
Asynchronous sampling is a low overhead profiling mode that does not suffer from the Safepoint bias problem. It features HotSpot-specific APIs to collect stack traces. It works with OpenJDK, Oracle JDK and other Java runtimes based on the HotSpot JVM.
If CPU profiling is already running, it will reset and start anew.
- Parameters:
settings- CPU sampling settings. Passnullto use the profiled application's settings, or pass your custom settings as a non-nullstring.- Throws:
ControllerException- Possible reasons:- Asynchronous sampling is not supported by the JVM.
IOException
-
stopAllocationProfiling
Stops allocation profiling. If allocation profiling is not running, this method has no effect.- Throws:
IOException
-
startCallCounting
Starts CPU call counting. Unlike other CPU profiling modes, only method invocations are counted, neither call stacks nor times are gathered.If CPU profiling is already running, it will reset and start anew.
- Throws:
ControllerException- Possible reasons:- Call counting (along with CPU tracing) has been disabled for the profiled application with startup options 'disable_tracing' or 'disable_all'.
IOException
-
startExceptionProfiling
Starts exception profiling. If exception profiling is not running when this method is called, previous exception profiling data is cleared. If exception profiling is already running, this method has no effect.- Throws:
IOException
-
stopExceptionProfiling
Stops exception profiling. If exception profiling is not running, this method has no effect.- Throws:
IOException
-
startMonitorProfiling
Starts monitor profiling. If monitor profiling is not running when this method is called, previous monitor profiling data is cleared. If monitor profiling is already running, this method has no effect.- Throws:
IOException
-
stopMonitorProfiling
Stops monitor profiling. If monitor profiling is not running, this method has no effect.- Throws:
IOException
-
startSampling
public void startSampling(@NotNull CpuProfilingSettings settings) throws IOException, ControllerException Starts CPU sampling. When sampling is used, the profiler periodically queries stacks and times of running threads to estimate the slowest parts of the code. In this mode, method invocation counts are not available.If CPU profiling is already running, it will reset and start anew.
- Throws:
IOExceptionControllerException
-
startThreadProfiling
Starts thread profiling. If thread profiling is already running, this method has no effect.- Throws:
IOException
-
stopThreadProfiling
Stops thread profiling. If thread profiling is not running, this method has no effect.- Throws:
IOException
-
resetThreadProfiling
Clears the collected thread profiling data and continues the thread profiling if it is active.Note: when thread profiling starts, collected thread profiling results are cleared automatically, so you do not have to explicitly call this method in that case.
- Throws:
IOException
-
startTelemetry
Starts collecting performance telemetry. If telemetry is already being collected, the method has no effect.- Throws:
IOException
-
stopTelemetry
Stops collecting performance telemetry. If telemetry is not being collected, the method has no effect.- Throws:
IOException
-
resetTelemetry
Clears telemetry.Note: when telemetry starts, collected telemetry is cleared automatically, so you do not have to explicitly call this method in that case.
- Throws:
IOException
-
startTracing
public void startTracing(@NotNull CpuProfilingSettings settings) throws IOException, ControllerException Starts CPU tracing. When tracing is used, the profiler instruments the bytecode of the profiled application for recording time spent inside each profiled method. Both times and invocation counts are available.If CPU profiling is already running, it will reset and start anew.
- Throws:
ControllerException- Possible reasons:- CPU tracing has been disabled for the profiled application with startup options 'disable_tracing' or 'disable_all'.
IOException
-
stopCpuProfiling
Stops CPU profiling in any mode, be it sampling, tracing or call counting. If CPU profiling is not running, this method has no effect.- Throws:
IOException
-
getJfrConfigs
- Returns:
- Available flight recording configurations, which can be started.
- Throws:
IOException
-
startJfr
Starts flight recording.If a flight recording is already running, it will be reset and started again.
- Parameters:
settings- flight recording settings ornullfor default.- Throws:
ControllerException- Possible reasons:- If JVM does not support JFR.
- flight recording settings are invalid.
IOException
-
stopJfr
Stops flight recording. If flight recording is not running, this method has no effect.- Throws:
ControllerException- If JVM does not support JFR.IOException
-
resetJfr
Clears the collected flight recording data and continues the recording if it is active.Note: when flight recording starts, collected results are cleared automatically, so you do not have to explicitly call this method in that case.
- Throws:
ControllerException- If JVM does not support JFR.IOException
-
captureJfrSnapshot
Captures JFR snapshot.- Returns:
- Absolute file path of the snapshot file. If a remote application is being profiled, then the path is in the file system of the remote host.
- Throws:
ControllerException- If JVM does not support JFR.IOException
-