com.ibm.websphere.rsadapter
Class WSSystemMonitor
- java.lang.Object
com.ibm.websphere.rsadapter.WSSystemMonitor
- public class WSSystemMonitor
- extends java.lang.Object
getSystemMonitor()
on the
com.ibm.websphere.rsadapter.WSConnection
Example:
import com.ibm.websphere.rsadapter.WSConnection;
.....
try {
InitialContext ctx = new InitialContext();
// Perform a naming service lookup to get the DataSource object.
DataSource ds = (javax.sql.DataSource)ctx.lookup("java:comp/jdbc/myDS");
} catch (Exception e) {;}
WSConnection conn = (WSConnection) ds.getConnection();
WSSystemMonitor sysMon = conn.getSystemMonitor();
if (sysMon != null) // indicates that system monitoring is supported on the current backend database
{
sysMon.enable(true);
sysMon.start(WSSystemMonitor.RESET_TIMES);
// ......interact with the database
sysMon.stop();
...... collect data from the sysMon object
}
conn.close();
Currently, only DB2 supports system monitor. Refer to the
com.ibm.websphere.rsadapter.WSConnection
documentation.
Field Summary
Modifier and Type | Field and Description |
---|---|
|
ACCUMULATE_TIMES
This constant causes the counter not to get reset when start() is called.
|
|
RESET_TIMES
This constant causes the counter to get reset when start() is called.
|
Constructor Summary
Constructor and Description |
---|
WSSystemMonitor(java.lang.Object sysMonitor,com.ibm.ws.rsadapter.spi.InternalDataStoreHelper internalHelper,com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl mc)
|
Method Summary
Modifier and Type | Method and Description |
---|---|
|
enable(boolean flag)
This method enables the system monitor associated with a connection.
|
|
getApplicationTimeMillis()
This method returns the total time in milliseconds that has been monitored.
|
|
getCoreDriverTimeMicros()
This method returns the sum of elapsed monitored API times in microseconds collected
while time monitoring is enabled.
|
|
getNetworkIOTimeMicros()
This method returns the sum of elapsed network I/O times in microseconds collected while
time monitoring is enabled.
|
|
getServerTimeMicros()
This method returns the sum of all reported database server elapsed times in microseconds collected
while time monitoring is enabled.
|
|
start(int lapMode)
This method starts collecting system monitoring data for the connection
associated with it if the monitor is enabled.
|
|
stop()
This method stops collecting system monitoring data for the connection
associated with it if the monitor is enabled.
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail
RESET_TIMES
- public static final int RESET_TIMES
This constant causes the counter to get reset when start() is called.
See Also:
ACCUMULATE_TIMES
- public static final int ACCUMULATE_TIMES
This constant causes the counter not to get reset when start() is called.
See Also:
Constructor Detail
WSSystemMonitor
- public WSSystemMonitor(java.lang.Object sysMonitor,
- com.ibm.ws.rsadapter.spi.InternalDataStoreHelper internalHelper,
- com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl mc)
Method Detail
enable
- public void enable(boolean flag)
- throws java.sql.SQLException
This method enables the system monitor associated with a connection.
This method may not be called while monitoring.
All times are reset when the monitor is enabled.
Parameters:
flag
- boolean true to enable, false to disable Throws:
java.sql.SQLException
- if the backend database throws an exception Since:
WebSphere Application Server 6.0
start
- public void start(int lapMode)
- throws java.sql.SQLException
This method starts collecting system monitoring data for the connection
associated with it if the monitor is enabled.
Calling this method with system monitoring disabled is a no-op. In other words, you must not be monitoring when this method is called.
Calling this method with system monitoring disabled is a no-op. In other words, you must not be monitoring when this method is called.
Parameters:
lapMode
- indicates whether or not to zero out the time counters before monitoring is started.
Possible values are:
Throws:
java.sql.SQLException
- if this method is called twice in a row without an intervening stop() Since:
WebSphere Application Server 6.0
stop
- public void stop()
- throws java.sql.SQLException
This method stops collecting system monitoring data for the connection
associated with it if the monitor is enabled.
After monitoring is stopped by calling this method, monitored times can be obtained by calling the getter methods of this interface.
Calling this method with system monitoring disabled is a no-op.
In other words, you must be monitoring before calling this method.
After monitoring is stopped by calling this method, monitored times can be obtained by calling the getter methods of this interface.
Calling this method with system monitoring disabled is a no-op.
In other words, you must be monitoring before calling this method.
Throws:
java.sql.SQLException
- if this method is called twice in a row without an intervening start()if this method is called without first calling start()
Since:
WebSphere Application Server 6.0
getServerTimeMicros
- public long getServerTimeMicros( )
- throws java.sql.SQLException
This method returns the sum of all reported database server elapsed times in microseconds collected
while time monitoring is enabled.
See the specific database documentation for system monitors
See the specific database documentation for system monitors
Returns:
0 if called with system monitoring disabled.
Throws:
java.sql.SQLException
- if the stop method has not been called, i.e. monitoring is occurring. Since:
WebSphere Application Server 6.0
getNetworkIOTimeMicros
- public long getNetworkIOTimeMicros( )
- throws java.sql.SQLException
This method returns the sum of elapsed network I/O times in microseconds collected while
time monitoring is enabled.
See the specific database documentation for system monitors
See the specific database documentation for system monitors
Returns:
0 if called with system monitoring disabled.
Throws:
java.sql.SQLException
- if the stop method has not been called, i.e monitoring is occurring.if the underlying JVM does not support reporting times in microseconds.
Since:
WebSphere Application Server 6.0
getCoreDriverTimeMicros
- public long getCoreDriverTimeMicros( )
- throws java.sql.SQLException
This method returns the sum of elapsed monitored API times in microseconds collected
while time monitoring is enabled.
See the specific database documentation for system monitors
See the specific database documentation for system monitors
Returns:
0 if called with system monitoring disabled.
Throws:
java.sql.SQLException
- if the stop method has not been called, i.e monitoring is currently occuring.>br>
if the underlying JVM does not support reporting times in microseconds. Since:
WebSphere Application Server 6.0
getApplicationTimeMillis
- public long getApplicationTimeMillis( )
- throws java.sql.SQLException
This method returns the total time in milliseconds that has been monitored.
The monitored elapsed time interval is calculated as the delta in
microseconds between these points in the Java driver.
See the specific database documentation for system monitors The interval begins when start() is called.
The interval ends when stop() is called.
The value contains application, driver, network I/O, and server elapsed times.
See the specific database documentation for system monitors
Returns:
0 if called with system monitoring disabled.
Throws:
java.sql.SQLException
- if the stop method has not been called, i.e monitoring is occuring. Since:
WebSphere Application Server 6.0