|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.yourkit.api.Controller
public final class Controller
The class provides API to control profiling of Java applications.
| Field Summary | |
|---|---|
static java.lang.String |
DEFAULT_FILTERS
Default filters |
static java.lang.String |
DEFAULT_WALLTIME_SPEC
Default wall time configuration (see http://www.yourkit.com/docs/90/help/times.jsp) to be passed as a parameter of startCPUProfiling(long, String, String) |
| Constructor Summary | |
|---|---|
Controller()
Creates a contoller to profile application itself, i.e. |
|
Controller(java.lang.String host,
int port)
Creates a contoller to profile application given host it is running
and the port its profiler agent listens to. |
|
| Method Summary | |
|---|---|
void |
advanceGeneration(java.lang.String description)
Advance current object generation number. |
java.lang.String |
captureMemorySnapshot()
This method is just a convenient replacement of captureSnapshot(ProfilingModes.SNAPSHOT_WITH_HEAP) |
java.lang.String |
captureSnapshot(long snapshotFlags)
Captures snapshot, i.e. |
void |
clearAllocationData()
Clear recorded allocations. |
void |
clearCPUData()
Clear CPU profiling data. |
void |
clearExceptions()
Clear collected exception telemetry. |
void |
clearMonitorData()
Clear monitor profiling data. |
void |
disableExceptionTelemetry()
Stop collecting exception telemetry. |
void |
disableStackTelemetry()
Stop collecting thread stack and state telemetry. |
void |
enableExceptionTelemetry()
Start collecting exception telemetry. |
void |
enableStackTelemetry()
Start collecting thread stack and state telemetry. |
long[] |
forceGC()
|
java.lang.String |
getHost()
|
int[] |
getPeriodicSnapshotTrigger()
Deprecated. Use getPeriodicSnapshotTriggerStatus() |
PeriodicSnapshotTriggerStatus |
getPeriodicSnapshotTriggerStatus()
Get current status of periodic snapshot trigger - see detail in Help. |
int |
getPort()
|
long |
getStatus()
Get current profiling status. |
int |
getUsedMemoryThreshold()
Get current status of on-low-memory snapshot trigger - see detail in Help. |
static void |
main(java.lang.String[] args)
The Controller provides a command line interface to some of its functionality. |
void |
setPeriodicSnapshotTrigger(int periodSec)
Deprecated. Use setPeriodicSnapshotTrigger(int, long) instead |
void |
setPeriodicSnapshotTrigger(int periodSec,
long snapshotFlags)
Setup periodic snapshot trigger - see detail in Help.. |
void |
setUsedMemoryThreshold(int usedHeapPercent)
Setup on-low-memory snapshot trigger - see detail in Help. |
void |
startAllocationRecording(boolean recordEachEnabled,
int recordEach,
boolean sizeLimitEnabled,
int sizeLimit)
Start object allocation recording. |
void |
startCPUProfiling(long mode,
java.lang.String filters)
Same as startCPUProfiling(mode, filters, DEFAULT_WALLTIME_SPEC) |
void |
startCPUProfiling(long mode,
java.lang.String filters,
java.lang.String wallTimeSpec)
Start CPU profiling. |
void |
startMonitorProfiling()
Start monitor profiling. |
void |
stopAllocationRecording()
Stop allocation recording. |
void |
stopCPUProfiling()
Stop CPU profiling. |
void |
stopMonitorProfiling()
Stop monitor profiling. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String DEFAULT_FILTERS
public static final java.lang.String DEFAULT_WALLTIME_SPEC
startCPUProfiling(long, String, String)
| Constructor Detail |
|---|
public Controller()
throws java.lang.Exception
Creates a contoller to profile application itself, i.e. to profile the JVM running the code that invokes this constructor.
The application should be launched with profiler agent; see Help topic "Running applications with profiler" for details.
java.lang.Exception - if application is not launched with the profiler agentController(String, int)
public Controller(java.lang.String host,
int port)
throws java.lang.Exception
Creates a contoller to profile application given host it is running
and the port its profiler agent listens to.
The application to profile should be launched with profiler agent; see Help topic "Running applications with profiler" for details.
Note that the constructor attempts to connect to the specified application. If connection fails, an exception is thrown.
host - name of host where application being profiled is running. Cannot be null.port - port profiler agent listens on. Must be in range 1-65535.
java.lang.Exception - if the profiled application cannot be connected. Possible reasons:
host
started with profiler agent listening on port
Controller()| Method Detail |
|---|
public java.lang.String getHost()
null.public int getPort()
public java.lang.String captureSnapshot(long snapshotFlags)
throws java.lang.Exception
Captures snapshot, i.e. writes profiling information to file.
If profiling is being performed (e.g. started with startCPUProfiling(long, String),
startMonitorProfiling() or startAllocationRecording(boolean, int, boolean, int), or remotely),
it will not stop after the capture.
To stop it, explicitly call stopCPUProfiling(),
stopMonitorProfiling() or stopAllocationRecording().
snapshotFlags - defines what kind of snapshot to capture:
ProfilingModes.SNAPSHOT_WITHOUT_HEAP - capture
snapshot with all the recorded information (CPU profiling, monitors, telemetry),
but without the heap dump.
ProfilingModes.SNAPSHOT_WITH_HEAP - capture
snapshot with all the recorded information (CPU profiling, monitors, telemetry, allocations),
as well as with the heap dump.
ProfilingModes.SNAPSHOT_HPROF - capture snapshot in HPROF format (heap dump only).
Controller(String, int)),
the returned path will be in the file system of the remote host.
java.lang.Exception - if capture failed. The possible reasons are:
public java.lang.String captureMemorySnapshot()
throws java.lang.Exception
captureSnapshot(ProfilingModes.SNAPSHOT_WITH_HEAP)
java.lang.Exception
public void startAllocationRecording(boolean recordEachEnabled,
int recordEach,
boolean sizeLimitEnabled,
int sizeLimit)
throws java.lang.Exception
recordEach and sizeLimit
parameters are applied independently.
For example, the following call will record allocation of each 10th object OR if object size is 100K or more:
controller.startAllocationRecording(true, 10, true, 100*1024)
recordEachEnabled - whether recordEach parameter should be appliedrecordEach - record each recordEach'th object allocation; ignored if recordEachEnabled==falsesizeLimitEnabled - whether sizeLimit parameter should be appliedsizeLimit - record allocation of object with shallow size >= sizeLimit; the value is specified in bytes;
ignored if sizeLimitEnabled==false
java.lang.Exception - if failed. Possible reasons:
captureMemorySnapshot(),
stopAllocationRecording()
public void stopAllocationRecording()
throws java.lang.Exception
java.lang.Exception - if failed. Possible reasons:
startAllocationRecording(boolean, int, boolean, int),
captureMemorySnapshot()
public void clearAllocationData()
throws java.lang.Exception
java.lang.Exception - if failed. Possible reasons:
startAllocationRecording(boolean, int, boolean, int),
stopAllocationRecording(),
captureMemorySnapshot()
public void startCPUProfiling(long mode,
java.lang.String filters)
throws java.lang.Exception
startCPUProfiling(mode, filters, DEFAULT_WALLTIME_SPEC)
java.lang.Exception
public void startCPUProfiling(long mode,
java.lang.String filters,
java.lang.String wallTimeSpec)
throws java.lang.Exception
mode - ProfilingModes.CPU_SAMPLING orProfilingModes.CPU_TRACING orProfilingModes.CPU_SAMPLING | ProfilingModes.CPU_J2EE orProfilingModes.CPU_TRACING | ProfilingModes.CPU_J2EEfilters - specify filters to be applied in runtime
(read about the filters at http://www.yourkit.com/docs/90/help/filters.jsp).
The value is used with ProfilingModes.CPU_TRACING only;
with ProfilingModes.CPU_SAMPLING the value is ignored (just pass an empty string).
For tracing, specify a string containing '\n'-separated list of
class name patterns to be filtered.
Prepend class name pattern with '+' to avoid its filtering.
Wildcards are accepted ('*').
More methods are profiled, bigger the overhead.
Pass null to read filter settings from <profiled application's user home>/.yjp/.filters.
Pass an empty string to use no filters, i.e. to trace all methods
(not recommended due to high overhead).
Pass DEFAULT_FILTERS to use default filters.wallTimeSpec - specify for which methods wall time should be measured instead of CPU time
(read about time measurement at http://www.yourkit.com/docs/90/help/times.jsp).
Pass null to read wall time settings from <profiled application's user home>/.yjp/.walltime.
Pass an empty string not to measure wall time for any methods.
Pass DEFAULT_WALLTIME_SPEC to use default settings.
java.lang.Exception - if failed. Possible reasons:
captureSnapshot(long),
stopCPUProfiling(),
clearCPUData(),
DEFAULT_FILTERS
public void stopCPUProfiling()
throws java.lang.Exception
java.lang.Exception - if failed. Possible reasons:
startCPUProfiling(long, String),
captureSnapshot(long),
clearCPUData()
public void clearCPUData()
throws java.lang.Exception
java.lang.Exception - if failed. Possible reasons:
startCPUProfiling(long, String),
stopCPUProfiling(),
captureSnapshot(long)
public void startMonitorProfiling()
throws java.lang.Exception
java.lang.Exception - if failed. Possible reasons:
captureSnapshot(long),
stopMonitorProfiling(),
clearMonitorData()
public void stopMonitorProfiling()
throws java.lang.Exception
java.lang.Exception - if failed. Possible reasons:
startMonitorProfiling(),
captureSnapshot(long),
clearCPUData()
public void clearMonitorData()
throws java.lang.Exception
java.lang.Exception - if failed. Possible reasons:
startMonitorProfiling(),
stopMonitorProfiling(),
captureSnapshot(long)
public void enableStackTelemetry()
throws java.lang.Exception
java.lang.Exception - if failed. Possible reasons:
captureSnapshot(long),
disableStackTelemetry()
public void disableStackTelemetry()
throws java.lang.Exception
java.lang.Exception - if failed. Possible reasons:
enableStackTelemetry(),
captureSnapshot(long)
public void enableExceptionTelemetry()
throws java.lang.Exception
java.lang.Exception - if failed. Possible reasons:
captureSnapshot(long),
disableExceptionTelemetry()
public void disableExceptionTelemetry()
throws java.lang.Exception
java.lang.Exception - if failed. Possible reasons:
enableExceptionTelemetry(),
captureSnapshot(long)
public void clearExceptions()
throws java.lang.Exception
java.lang.Exception - if failed. Possible reasons:
enableExceptionTelemetry(),
disableExceptionTelemetry(),
captureSnapshot(long)
public void advanceGeneration(java.lang.String description)
throws java.lang.Exception
Advance current object generation number.
Since that moment, all newly created objects will belong to the new generation.
Note that generations are also automatically advanced on capturing snapshots.
description - optional description associated with the generation
java.lang.Exception - if failed. Possible reasons:
public long[] forceGC()
throws java.lang.Exception
java.lang.Exception
public long getStatus()
throws java.lang.Exception
long status = controller.getStatus();
if ((status & ProfilingModes.ALLOCATION_RECORDING) != 0) {
System.out.println("Allocation recording is on");
}
else {
System.out.println("Allocation recording is off");
}
if ((status & ProfilingModes.CPU_TRACING) == ProfilingModes.CPU_TRACING) {
System.out.println("CPU profiling is on (tracing)");
}
else if ((status & ProfilingModes.CPU_SAMPLING) != 0) {
System.out.println("CPU profiling is on (sampling)");
}
else {
System.out.println("CPU profiling is off");
}
if ((status & ProfilingModes.MONITOR_PROFILING) != 0) {
System.out.println("Monitor profiling is on");
}
else {
System.out.println("Monitor profiling is off");
}
ProfilingModes
java.lang.Exception - if failed. Possible reasons:
public void setPeriodicSnapshotTrigger(int periodSec,
long snapshotFlags)
throws java.lang.Exception
periodSec - snapshot capture period in seconds; -1 to disable the triggersnapshotFlags - defines what kind of snapshot to capture:
ProfilingModes.SNAPSHOT_WITHOUT_HEAP - capture
snapshot with all the recorded information (CPU profiling, monitors, telemetry),
but without the heap dump.
ProfilingModes.SNAPSHOT_WITH_HEAP - capture
snapshot with all the recorded information (CPU profiling, monitors, telemetry, allocations),
as well as with the heap dump.
ProfilingModes.SNAPSHOT_HPROF - capture snapshot in HPROF format (heap dump only).
periodSec is -1),
pass 0 as the value of snapshotFlags.
java.lang.Exception - if failed. Possible reasons:
getPeriodicSnapshotTrigger()
public void setPeriodicSnapshotTrigger(int periodSec)
throws java.lang.Exception
setPeriodicSnapshotTrigger(int, long) instead
setPeriodicSnapshotTrigger(periodSec, ProfilingModes.SNAPSHOT_WITH_HEAP)
java.lang.Exception
public int[] getPeriodicSnapshotTrigger()
throws java.lang.Exception
getPeriodicSnapshotTriggerStatus()
java.lang.Exception - if failed. Possible reasons:
setPeriodicSnapshotTrigger(int)
public PeriodicSnapshotTriggerStatus getPeriodicSnapshotTriggerStatus()
throws java.lang.Exception
null
java.lang.Exception - if failed. Possible reasons:
setPeriodicSnapshotTrigger(int)
public void setUsedMemoryThreshold(int usedHeapPercent)
throws java.lang.Exception
usedHeapPercent - memory snapshot will be captured when usedHeapPercent%
of the heap memory is used. The value should not be bigger than 99%.
To disable the trigger, specify 0.
java.lang.Exception - if failed. Possible reasons:
getUsedMemoryThreshold()
public int getUsedMemoryThreshold()
throws java.lang.Exception
java.lang.Exception - if failed. Possible reasons:
setUsedMemoryThreshold(int)
public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||