|
|||||||||
| 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
com.sun. |
| Constructor Summary | |
|---|---|
Controller()
Creates a contoller to profile application itself, i.e. to profile the JVM running the code that invokes this constructor. |
|
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: write profiling information to file. |
long[] |
forceGC()
|
java.lang.String |
getHost()
|
int |
getPort()
|
long |
getStatus()
Get current profiling status. |
static void |
main(java.lang.String[] args)
The Controller provides a command line interface to some of its functionality. |
void |
startAllocationRecording(long mode)
Start object allocation recording. |
void |
startCPUProfiling(long mode,
java.lang.String filters)
Start CPU profiling. |
void |
startMonitorProfiling()
Start monitor profiling (requires that the profiled application runs on Java 5 or newer) |
void |
stopAllocationRecording()
Stop allocation recording. |
void |
stopCPUProfiling()
Stop CPU profiling. |
void |
stopMonitorProfiling()
Stop monitor profiling (requires that the profiled application runs on Java 5 or newer). |
| 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
| 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 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 connect to the application failsController()| Method Detail |
|---|
public java.lang.String getHost()
null.public int getPort()
public java.lang.String captureSnapshot(long snapshotFlags)
throws java.lang.Exception
Captures snapshot: write profiling information to file.
If some profiling is being performed (e.g. started with startCPUProfiling(long, String),
startMonitorProfiling() or startAllocationRecording(long), or remotely),
it won't stop after the capture.
To stop it, explicitly call stopCPUProfiling(),
stopMonitorProfiling() or stopAllocationRecording().
snapshotFlags - defines how much information should be stored:
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.
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:
port at host
public java.lang.String captureMemorySnapshot()
throws java.lang.Exception
captureSnapshot(ProfilingModes.SNAPSHOT_WITH_HEAP)
java.lang.Exception
public void startAllocationRecording(long mode)
throws java.lang.Exception
mode - ProfilingModes.ALLOCATION_RECORDING_ALL orProfilingModes.ALLOCATION_RECORDING_ADAPTIVE
java.lang.Exception - if capture failed. The possible reasons are:
port at host
captureMemorySnapshot(),
stopCPUProfiling()
public void stopAllocationRecording()
throws java.lang.Exception
java.lang.Exception - if failed. The possible reasons are:
port at host
public void startCPUProfiling(long mode,
java.lang.String filters)
throws java.lang.Exception
mode - ProfilingModes.CPU_SAMPLING orProfilingModes.CPU_TRACING orProfilingModes.CPU_SAMPLING | ProfilingModes.CPU_J2EE orProfilingModes.CPU_TRACING | ProfilingModes.CPU_J2EEfilters - string containing '\n'-separated list of classes
whose methods should not be profiled.
Wildcards are accepted ('*').
More methods are profiled, bigger the overhead.
The filters are used with ProfilingModes.CPU_TRACING only; with ProfilingModes.CPU_SAMPLING
the value is ignored.
If null or empty string passed, all methods will be profiled (not recommended due to high overhead).
For example, you can pass DEFAULT_FILTERS.
java.lang.Exception - if capture failed. The possible reasons are:
port at host
captureSnapshot(long),
stopCPUProfiling(),
DEFAULT_FILTERS
public void stopCPUProfiling()
throws java.lang.Exception
java.lang.Exception - if failed. The possible reasons are:
port at host
startCPUProfiling(long, String),
captureSnapshot(long)
public void startMonitorProfiling()
throws java.lang.Exception
java.lang.Exception - if capture failed. The possible reasons are:
port at host
captureSnapshot(long),
stopMonitorProfiling()
public void stopMonitorProfiling()
throws java.lang.Exception
java.lang.Exception - if failed. The possible reasons are:
port at host
startMonitorProfiling(),
captureSnapshot(long)public void advanceGeneration(java.lang.String description)
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.
Generations are only available if the profiled application runs on Java 5 or newer.
description - optional description associated with the generation
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_ADAPTIVE) != 0) {
System.out.println("Allocation recording is on (adaptive)");
}
else if ((status & ProfilingModes.ALLOCATION_RECORDING_ALL) != 0) {
System.out.println("Allocation recording is on (all objects)");
}
else {
System.out.println("Allocation recording is off");
}
if ((status & ProfilingModes.CPU_TRACING) != 0) {
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
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 | ||||||||