Proactive insights, news and tips from Oracle WebLogic Server Support. Learn Oracle from Oracle.

  • November 20, 2015

WLS Replay Statistics

Stephen Felts

Starting in the Oracle thin driver, the
replay driver has statistics related to replay. This is useful to understand
how many connections are being replayed. It should be completely transparent to the application so you won’t know
if connection replays are occurring unless you check.

statistics are available on a per connection basis or on a datasource
basis. However, connections on a WLS
datasource don’t share a driver-level datasource object so the latter isn’t
useful in WLS. WLS 12.2.1 provides
another mechanism to get the statistics at the datasource level.

The following code sample shows how to print out the
available statistics for an individual connection using the oracle.jdbc.replay.ReplayableConnection
interface, which exposes the method to get a oracle.jdbc.replay.ReplayStatistics
object. See https://docs.oracle.com/database/121/JAJDB/oracle/jdbc/replay/ReplayStatistics.html
for a description of the statistics values.

if (conn instanceof ReplayableConnection) { ReplayableConnection rc = ((ReplayableConnection)conn); ReplayStatistics rs = rc.getReplayStatistics(
System.out.println("Individual Statistics"); System.out.println("TotalCalls="+rs.getTotalCalls()); System.out.println("TotalCompletedRequests="+rs.getTotalCompletedRequests()); System.out.println("FailedReplayCount="+rs.getFailedReplayCount()); System.out.println("TotalRequests="+rs.getTotalRequests()); System.out.println("TotalCallsTriggeringReplay="+rs.getTotalCallsTriggeringReplay()); System.out.println("TotalReplayAttempts="+rs.getTotalReplayAttempts()); System.out.println("TotalProtectedCalls="+rs.getTotalProtectedCalls()); System.out.println("SuccessfulReplayCount="+rs.getSuccessfulReplayCount()); System.out.println("TotalCallsAffectedByOutages="+rs.getTotalCallsAffectedByOutages());
rs.getTotalCallsAffectedByOutagesDuringReplay()); System.out.println("ReplayDisablingCount="+rs.getReplayDisablingCount());

Besides a getReplayStatistics() method, there is also a
clearReplayStatistics() method.

To provide for a consolidated view of all of the connections
associated with a WLS datasource, the information is available via a new operation on the associated
runtime MBean. You need to look-up the WLS
MBean server, get the JDBC service, then search for the datasource name in the
list of JDBC datasource runtime MBeans, and get the
JDBCReplayStatisticsRuntimeMBean. This
value will be null if the datasource is not using a replay driver, if the
driver is earlier than, or if it’s not a Generic or AGL datasource. To use the replay information, you need to
first call the refreshStatistics() operation that sets the MBean values, aggregating the values for
all connections on the datasource. Then
you can call the operations on the MBean to get the statistics values, as in
the following sample code. Note that
there is also a clearStatistics() operation to clear the statistics on all
connections on the datasource. The
following code shows an example of how to print the aggregated statistics from
the data source.

public void printReplayStats(String dsName) throws Exception { MBeanServer server = getMBeanServer(); ObjectName[] dsRTs = getJdbcDataSourceRuntimeMBeans(server); for (ObjectName dsRT : dsRTs) {   String name = (String)server.getAttribute(dsRT, "Name"); if (name.equals(dsName)) {     ObjectName mb =(ObjectName)server.getAttribute(dsRT,  "JDBCReplayStatisticsRuntimeMBean");     server.invoke(mb,"refreshStatistics", null, null);     MBeanAttributeInfo[] attributes = server.getMBeanInfo(mb).getAttributes();   System.out.println("Roll-up");     for (int i = 0; i <attributes.length; i++) {       if(attributes[i].getType().equals("java.lang.Long")) {     System.out.println(attributes[i].getName()+"="+     (Long)server.getAttribute(mb, attributes[i].getName()));     }     }

MBeanServer getMBeanServer() throws Exception { InitialContext ctx = new InitialContext(); MBeanServer server = (MBeanServer)ctx.lookup("java:comp/env/jmx/runtime"); return server;

ObjectName[] getJdbcDataSourceRuntimeMBeans(MBeanServer server)  throws Exception { ObjectName service = new ObjectName( "com.bea:Name=RuntimeService,Type=\
weblogic.management.mbeanservers.runtime.RuntimeServiceMBean"); ObjectName serverRT = (ObjectName)server.getAttribute(service, "ServerRuntime"); ObjectName jdbcRT = (ObjectName)server.getAttribute(serverRT, "JDBCServiceRuntime"); ObjectName[] dsRTs = (ObjectName[])server.getAttribute(jdbcRT, "JDBCDataSourceRuntimeMBeans"); return dsRTs;

Now run an application that gets a connection, does
some work, kills the session, replays, then gets a second connection and does
the same thing. Each connection successfully
replays once. That means that the
individual statistics show a single replay and the aggregated statistics will
show two replays. Here is what the
output might look like.

Individual Statistics
























Looking carefully at the numbers, you can see that the individual count was done before the connections were closed (TotalCompletedRequests=0) and the roll-up was done after both connections were closed. 

You can also use WLST to get the statistics values
for the datasource. The statistics are
not visible in the administration console or FMWC in WLS 12.2.1.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.