@ManagedAttribute(id = "averageconnwaittime") public CountStatistic getAverageConnWaitTime() { // Time taken by all connection requests divided by total number of // connections acquired in the sampling period. long averageWaitTime = 0; if (numConnAcquired.getCount() != 0) { averageWaitTime = totalConnRequestWaitTime.getCount() / numConnAcquired.getCount(); } else { averageWaitTime = 0; } averageConnWaitTime.setCount(averageWaitTime); return averageConnWaitTime; }
/** When an object is added to wait queue, increment the waitQueueLength. */ @ProbeListener(JCA_PROBE_LISTENER + "connectionRequestQueuedEvent") public void connectionRequestQueuedEvent( @ProbeParam("poolName") String poolName, @ProbeParam("appName") String appName, @ProbeParam("moduleName") String moduleName) { PoolInfo poolInfo = new PoolInfo(poolName, appName, moduleName); if (this.poolInfo.equals(poolInfo)) { if (logger.isLoggable(Level.FINEST)) { logger.finest("Wait Queue length modified event received - " + "poolName = " + poolName); } waitQueueLength.increment(); } }
/** * When a connection under test does not match the current request, increment * numConnNotSuccessfullyMatched. */ @ProbeListener(JCA_PROBE_LISTENER + "connectionNotMatchedEvent") public void connectionNotMatchedEvent( @ProbeParam("poolName") String poolName, @ProbeParam("appName") String appName, @ProbeParam("moduleName") String moduleName) { PoolInfo poolInfo = new PoolInfo(poolName, appName, moduleName); if (this.poolInfo.equals(poolInfo)) { if (logger.isLoggable(Level.FINEST)) { logger.finest("Connection not matched event received - " + "poolName = " + poolName); } numConnNotSuccessfullyMatched.increment(); } }
/** * Whenever connection timed-out event occurs, increment numConnTimedOut * * @param pool JdbcConnectionPool that got a connTimedOutEvent */ @ProbeListener(JDBC_PROBE_LISTENER + "connectionTimedOutEvent") public void connectionTimedOutEvent( @ProbeParam("poolName") String poolName, @ProbeParam("appName") String appName, @ProbeParam("moduleName") String moduleName) { // handle the conn timed out probe event PoolInfo poolInfo = new PoolInfo(poolName, appName, moduleName); if (this.poolInfo.equals(poolInfo)) { if (logger.isLoggable(Level.FINEST)) { logger.finest("Connection Timed-out event received - poolName = " + poolName); } // Increment counter numConnTimedOut.increment(); } }
/** * Event that a connection request is served in timeTakenInMillis. * * @param poolName * @param timeTakenInMillis */ @ProbeListener(JDBC_PROBE_LISTENER + "connectionRequestServedEvent") public void connectionRequestServedEvent( @ProbeParam("poolName") String poolName, @ProbeParam("appName") String appName, @ProbeParam("moduleName") String moduleName, @ProbeParam("timeTakenInMillis") long timeTakenInMillis) { PoolInfo poolInfo = new PoolInfo(poolName, appName, moduleName); if (this.poolInfo.equals(poolInfo)) { if (logger.isLoggable(Level.FINEST)) { logger.finest("Connection request served event received - " + "poolName = " + poolName); } connRequestWaitTime.setCurrent(timeTakenInMillis); totalConnRequestWaitTime.increment(timeTakenInMillis); } }
/** * Whenever connection leak happens, increment numConnFailedValidation * * @param pool JdbcConnectionPool that got a failed validation event */ @ProbeListener(JDBC_PROBE_LISTENER + "connectionValidationFailedEvent") public void connectionValidationFailedEvent( @ProbeParam("poolName") String poolName, @ProbeParam("appName") String appName, @ProbeParam("moduleName") String moduleName, @ProbeParam("increment") int increment) { PoolInfo poolInfo = new PoolInfo(poolName, appName, moduleName); if (this.poolInfo.equals(poolInfo)) { if (logger.isLoggable(Level.FINEST)) { logger.finest("Connection Validation Failed event received - " + "poolName = " + poolName); } // TODO V3 : add support in CounterImpl for addAndGet(increment) numConnFailedValidation.increment(increment); } }
/** * Whenever connection leak happens, increment numPotentialConnLeak * * @param pool JdbcConnectionPool that got a connLeakEvent */ @ProbeListener(JDBC_PROBE_LISTENER + "potentialConnLeakEvent") public void potentialConnLeakEvent( @ProbeParam("poolName") String poolName, @ProbeParam("appName") String appName, @ProbeParam("moduleName") String moduleName) { // handle the conn leak probe event PoolInfo poolInfo = new PoolInfo(poolName, appName, moduleName); if (this.poolInfo.equals(poolInfo)) { if (logger.isLoggable(Level.FINEST)) { logger.finest("Connection Leak event received - poolName = " + poolName); } // TODO V3: Checking if this is a valid event // Increment counter numPotentialConnLeak.increment(); } }
/** * Reset pool statistics. When annotated with @Reset, this method is invoked whenever monitoring * is turned to HIGH from OFF, thereby setting the statistics to appropriate values. */ @Reset public void reset() { if (logger.isLoggable(Level.FINEST)) { logger.finest("Reset event received - poolInfo = " + poolInfo); } PoolStatus status = ConnectorRuntime.getRuntime().getPoolManager().getPoolStatus(poolInfo); numConnUsed.setCurrent(status.getNumConnUsed()); numConnFree.setCurrent(status.getNumConnFree()); numConnCreated.reset(); numConnDestroyed.reset(); numConnFailedValidation.reset(); numConnTimedOut.reset(); numConnAcquired.reset(); numConnReleased.reset(); connRequestWaitTime.reset(); numConnSuccessfullyMatched.reset(); numConnNotSuccessfullyMatched.reset(); numPotentialConnLeak.reset(); averageConnWaitTime.reset(); totalConnRequestWaitTime.reset(); waitQueueLength.reset(); }
@ProbeListener("fooblog:samples:ProbeServlet:myProbe") public void probe(String s) { servletRequestCount.increment(); System.out.println("PROBE LISTENER HERE. Called with this arg: " + s); }