com.ibm.websphere.rsadapter

Class WSSystemMonitor

  • java.lang.Object
    • com.ibm.websphere.rsadapter.WSSystemMonitor


  • public class WSSystemMonitor
    extends java.lang.Object
    This class allows users to collect system monitoring data for a datbase connection. WebSphere users can have access to this object by calling 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

      Fields 
      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 Summary

      Constructors 
      Constructor and Description
      WSSystemMonitor(java.lang.Object sysMonitor, com.ibm.ws.rsadapter.spi.InternalDataStoreHelper internalHelper, com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl mc) 
    • Method Summary

      Methods 
      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.
      • 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:
        Constant Field Values
      • ACCUMULATE_TIMES

        public static final int ACCUMULATE_TIMES
        This constant causes the counter not to get reset when start() is called.
        See Also:
        Constant Field Values
    • 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.
        Parameters:
        lapMode - indicates whether or not to zero out the time counters before monitoring is started. Possible values are:
      • WSSystemMonitor.RESET_TIMES zeros out the time counters before monitoring is started.
      • WSSystemMonitor.ACCUMULATE_TIMES will not zero out counters.
      • 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.
        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
        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
        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
        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.
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