SourceForge.net Logo
Home

PerfUtil Java API: RtDriver class




connect()

     //
     // Connect to JProf on the local machine on the next available port.
     // Equivalent to: rtdriver -l
     //
     // Returns:
     // - non-zero: port number on which connection was made.
     // - zero:     failed to connect.
     //
     // Notes:
     // - You only need to connect() if you want to send
     //   commands to a JVM other than the one you are running on.
     // - To send commands to the JVM you are running on all you
     //   need to do is invoke the method that sends the command.
     //
     static int connect();

connect(int)

     //
     // Connect to JProf on the local machine on the requested port.
     // Equivalent to: rtdriver -l -p port
     //
     // Returns:
     // - non-zero: port number on which connection was made.
     // - zero:     failed to connect.
     //
     // Notes:
     // - You only need to connect() if you want to send
     //   commands to a JVM other than the one you are running on.
     // - To send commands to the JVM you are running on all you
     //   need to do is invoke the method that sends the command.
     //
     static int connect(int port);

connect(String)

     //
     // Connect to JProf on the requested machine on the next available port.
     // Equivalent to: rtdriver -n host
     //
     // Notes:
     // - You only need to connect() if you want to send
     //   commands to a JVM other than the one you are running on.
     // - To send commands to the JVM you are running on all you
     //   need to do is invoke the method that sends the command.
     //
     static int connect(String host);

connect(String, int)

     //
     // Connect to JProf on the requested machine on the requested port.
     // Equivalent to: rtdriver -n host -p port
     //
     // Notes:
     // - You only need to connect() if you want to send
     //   commands to a JVM other than the one you are running on.
     // - To send commands to the JVM you are running on all you
     //   need to do is invoke the method that sends the command.
     //
     static int connect(String host, int port);




disconnect

   //
   // Disconnect currently connected port from JProf.
   // Equivalent to: rtdriver exit_rtdriver command or Ctrl-C
   //
   static void disconnect();




setSynchronousCommandMode

   //
   // Causes JProf to respond to commands sent over a socket when the
   // command completes.
   // * Command methods (those making JNI calls) don't return until JProf
   //   completes the command.
   // * Some commands may take a long time to complete.
   // * Default is to not wait for responses.
   // * Ignored if not communicating over a socket.
   //
   static void setSynchronousCommandMode();




setAsynchronousCommandMode

   //
   // Causes JProf to respond to commands sent over a socket when the
   // command is accepted.
   // * Command methods (those making JNI calls) don't return until JProf
   //   completes the command.
   // * In this mode, there is no way to know when commands complete.
   // * Ignored if not communicating over a socket.
   //
   static void setAsynchronousCommandMode();




commandSuccessful

   //
   // Returns whether or not the last command issued was successful or not.
   // Successful/true:
   // * JProf completed the command successfully.
   // Unsuccessful/false
   // * JProf completed the command but encountered errors.
   // * JProf didn't successfully acknowledge command completion.
   //
   static boolean commandSuccessful();




begin

   //
   // Send "begin" to JProf
   //
   // * Begins collecting data.
   // * start is a synonym for begin.
   //
   static void begin();
   static void start();


startWithoutBase

   //
   // Send "start_wob" to JProf
   //
   // * Begins collecting data but does not update base times
   //   until a subsequent "base" command issued.
   //
   static void startWithoutBase();


shutdown

   //
   // Send "shutdown" to JProf
   //
   // * Produces final log-rt file and kills the process (JVM).
   // * stop is a synonym for shutdown.
   //
   static void shutdown();
   static void stop();


flush

   //
   // Send "flush" to JProf
   //
   // * Produces a snapshot log-rt file.
   //
   static void flush();


reset

   //
   // Send "reset" to JProf
   //
   // * Total reset of JProf. Can begin fresh data cycle with start command.
   //
   static void reset();


end

   //
   // Send "end" to JProf
   //
   // * Disable all events, flush, then reset.
   //
   static void end();


setLogFilesPath

   //
   // Send "logpath=" to JProf
   //
   // * Changes the destination path for log-* files written
   //   after the call. It does not change the path of log-*
   //   files currently open (ex. log-msg).
   // * For example, if you set the path to "C:\newpath" then newly
   //   written log-* files would be written to directory C:\newpath,
   //   instead of where they're currently being written.
   //
   static void setLogFilesPath(String path);


setLogFilesPrefix

   //
   // Send "logprefix=" to JProf
   //
   // * Changes the prefix (the "log" part) for log-* files written
   //   after the call. It does not change the prefix of log-*
   //   files currently open (ex. log-msg).
   // * For example, if you set the prefix to "test2" then newly
   //   written log-* files would be named "test-*" instead of "log-*".
   //
   static void setLogFilesPrefix(String prefix);


appendLogFilesComment

   //
   // Send "logcomment=" to JProf
   //
   // * Appends the given string to the end of log-* files written
   //   after the call. It does not append the string to log-* files
   //   files currently open (ex. log-msg).
   // * For example, if you set the comment to "test2-results" then newly
   //   written log-* files (ex. log-rt) would be named
   //   "log-rt.1_####-test2-results" instead of "log-rt.1_####".
   // * You should probably not send strings that contain blanks.
   //
   static void appendLogFilesComment(String comment);


zeroBase

   //
   // Send "zerobase" to JProf
   //
   // * Removes inactive thread trees. Zero all nodes of active trees.
   //   Continues tree building. Requires base command to resume metric
   //   accumulation.
   //
   static void zeroBase();


noUpdateBase

   //
   // Send "-base" to JProf
   //
   // * Stop updating base time.
   //
   static void noUpdateBase();


updateBase

   //
   // Send "+base" to JProf
   //
   // * Continue/begin updating base time.
   //
   static void updateBase();


forceGC

   //
   // Send "fgc" to JProf
   //
   // * Force Garbage Collection.
   //
   static void forceGC();


forceGCAndFlush

   //
   // Send "fgcf" to JProf
   //
   // * Force Garbage Collection followed by a flush.
   //
   static void forceGCAndFlush();


jlmStart

   //
   // Send "jlmstart" to JProf
   //
   // * Start Java Lock Monitor accounting with both time and counts.
   //
   static void jlmStart();


jlmStartLite

   //
   // Send "jlmstartlite" to JProf
   //
   // * Start Java Lock Monitor accounting with counts only.
   //
   static void jlmStartLite();


jlmStop

   //
   // Send "jlmstop" to JProf
   //
   // * Stop Java Lock Monitor accounting.
   //
   static void jlmStop();


jlmDump

   //
   // Send "jlmdump" to JProf
   //
   // * Dump Java Lock Monitor data to log-jlm file
   //
   static void jlmDump();


heapdumpSummary

   //
   // Send "heapdump=1" (summary) to JProf
   //
   // * Request a class summary of heap objects (creates log-hdcnm file)
   //
   static void heapdumpSummary();


heapdumpDetailed

   //
   // Send "heapdump=2" (detailed) to JProf
   //
   // * Request a detailed heap dump (creates log-hd and log-hdcnm files)
   //
   static void heapdumpDetailed();


heapdumpDetailedAndFlush

   //
   // Send "heapdump=5" (detailed+flush) to JProf
   //
   // * Request a detailed heap dump (creates log-hd and log-hdcnm files)
   //   followed by a flush.
   //
   static void heapdumpDetailedAndFlush();


threadDump

   //
   // Send "thread_dump" to JProf
   //
   // * Signal (request) a Java core dump (including thread stack dump)
   //
   static void threadDump();


threadStackDump

   //
   // Send "threadstackdump" to JProf
   //
   // * Dump callstacks for all threads
   //
   static void threadStackDump();


queryPid

   //
   // Query PID of process we're connected to
   //
   // * Only works if connected via socket (for now)
   //
   static String queryPid();


command

   //
   // Send ANY command to JProf
   //
   // * Use this method to send any valid command to JProf.
   // * If connected via socket you may want to prefix each command
   //   you send with a comma (ex. ",start" instead of "start"). Doing
   //   this avoids the problem of having commands concatenated together
   //   before being sent over the socket.
   //
   static void command(String cmd);