public class WSSystemMonitor
extends java.lang.Object
getSystemMonitor() on the
com.ibm.websphere.rsadapter.WSConnectionExample:
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();
com.ibm.websphere.rsadapter.WSConnection documentation.| Modifier and Type | Field and Description |
|---|---|
static int |
ACCUMULATE_TIMES
This constant causes the counter not to get reset when start() is called.
|
static int |
RESET_TIMES
This constant causes the counter to get reset when start() is called.
|
| Constructor and Description |
|---|
WSSystemMonitor(java.lang.Object sysMonitor,
com.ibm.ws.rsadapter.spi.InternalDataStoreHelper internalHelper,
com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl mc) |
| Modifier and Type | Method and Description |
|---|---|
void |
enable(boolean flag)
This method enables the system monitor associated with a connection.
|
long |
getApplicationTimeMillis()
This method returns the total time in milliseconds that has been monitored.
|
long |
getCoreDriverTimeMicros()
This method returns the sum of elapsed monitored API times in microseconds collected
while time monitoring is enabled.
|
long |
getNetworkIOTimeMicros()
This method returns the sum of elapsed network I/O times in microseconds collected while
time monitoring is enabled.
|
long |
getServerTimeMicros()
This method returns the sum of all reported database server elapsed times in microseconds collected
while time monitoring is enabled.
|
void |
start(int lapMode)
This method starts collecting system monitoring data for the connection
associated with it if the monitor is enabled.
|
void |
stop()
This method stops collecting system monitoring data for the connection
associated with it if the monitor is enabled.
|
public static final int RESET_TIMES
public static final int ACCUMULATE_TIMES
public WSSystemMonitor(java.lang.Object sysMonitor,
com.ibm.ws.rsadapter.spi.InternalDataStoreHelper internalHelper,
com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl mc)
public void enable(boolean flag)
throws java.sql.SQLException
flag - boolean true to enable, false to disablejava.sql.SQLException - if the backend database throws an exceptionpublic void start(int lapMode)
throws java.sql.SQLException
lapMode - indicates whether or not to zero out the time counters before monitoring is started.
Possible values are:
java.sql.SQLException - if this method is called twice in a row without an intervening stop()public void stop()
throws java.sql.SQLException
java.sql.SQLException - if this method is called twice in a row without an intervening start()public long getServerTimeMicros()
throws java.sql.SQLException
java.sql.SQLException - if the stop method has not been called, i.e. monitoring is occurring.public long getNetworkIOTimeMicros()
throws java.sql.SQLException
java.sql.SQLException - if the stop method has not been called, i.e monitoring is occurring.public long getCoreDriverTimeMicros()
throws java.sql.SQLException
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.public long getApplicationTimeMillis()
throws java.sql.SQLException
java.sql.SQLException - if the stop method has not been called, i.e monitoring is occuring.