wt.util
Class CallRegistrar

java.lang.Object
  extended by wt.util.CallRegistrar

public final class CallRegistrar
extends Object

This class allows one body of code to quickly register the entry and exit of significant calls or states and another body of code to easily monitor the number and total duration of such occurrences on both a per thread and per CallRegistrar instance basis.

A single instance of this class should generally be created and held in a static for an entire category of call statistic. For instance, a single instance is held and exposed by RMICallRegistrar to enable monitor of all RMI calls and their duration for the whole JVM.

Supported API: true

Extendable: false


Constructor Summary
CallRegistrar()
          /** Public constructor

Supported API: true
 
Method Summary
 long endCall(long startMillis)
          Registers the completion of an call.
 int getActiveCalls()
          Returns the number of active (in progress) registered calls.
 long getCallsForThread()
          Returns the total number of calls which have been registered as having started by the current thread.
 long getCallsForThread(Thread thread)
          Returns the total number of calls which have been registered as having started by the specified thread.
 long getElapsedTimeForThread()
          Returns the elapsed time in milliseconds of calls which have been registered as having started by the current thread.
 long getElapsedTimeForThread(Thread thread)
          Returns the elapsed time in milliseconds of calls which have been registered as having started by the specified thread.
 long getTotalCalls()
          Returns the total number of calls (for all threads) which have been registered as having completed.
 long getTotalElapsedTime()
          Returns the elapsed time in milliseconds of calls (for all threads) which have been registered as having completed.
 boolean isInCall()
          Returns whether the current thread is in a registered call.
 boolean isInCall(Thread thread)
          Returns whether the specified thread is in a registered call.
 long startCall()
          Registers the start of an call.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CallRegistrar

public CallRegistrar()
/** Public constructor

Supported API: true

Method Detail

isInCall

public boolean isInCall()
Returns whether the current thread is in a registered call.

Supported API: true


isInCall

public boolean isInCall(Thread thread)
Returns whether the specified thread is in a registered call.

Supported API: true


getActiveCalls

public int getActiveCalls()
Returns the number of active (in progress) registered calls.

Supported API: true


getTotalCalls

public long getTotalCalls()
Returns the total number of calls (for all threads) which have been registered as having completed.

Supported API: true


getCallsForThread

public long getCallsForThread()
Returns the total number of calls which have been registered as having started by the current thread.

Supported API: true


getCallsForThread

public long getCallsForThread(Thread thread)
Returns the total number of calls which have been registered as having started by the specified thread.

Supported API: true

Parameters:
thread - the thread to get the call count for

getTotalElapsedTime

public long getTotalElapsedTime()
Returns the elapsed time in milliseconds of calls (for all threads) which have been registered as having completed.

Supported API: true


getElapsedTimeForThread

public long getElapsedTimeForThread()
Returns the elapsed time in milliseconds of calls which have been registered as having started by the current thread.

Supported API: true


getElapsedTimeForThread

public long getElapsedTimeForThread(Thread thread)
Returns the elapsed time in milliseconds of calls which have been registered as having started by the specified thread.

Supported API: true

Parameters:
thread - the thread to get the elapsed call time for

startCall

public long startCall()
Registers the start of an call.

Supported API: true

Returns:
the start time in milliseconds; must be passed to endCall()

endCall

public long endCall(long startMillis)
Registers the completion of an call.

Supported API: true

Parameters:
startMillis - the start time in milliseconds as returned by startCall()
Returns:
the elapsed time of the call in milliseconds