org.jboss.cache.interceptors
Class CacheMgmtInterceptor

java.lang.Object
  extended by org.jboss.cache.interceptors.Interceptor
      extended by org.jboss.cache.interceptors.MethodDispacherInterceptor
          extended by org.jboss.cache.interceptors.CacheMgmtInterceptor
All Implemented Interfaces:
CacheMgmtInterceptorMBean, InterceptorMBean

public class CacheMgmtInterceptor
extends MethodDispacherInterceptor
implements CacheMgmtInterceptorMBean

Captures cache management statistics

Version:
$Id: CacheMgmtInterceptor.java 4968 2008-01-03 19:17:09Z manik.surtani@jboss.com $
Author:
Jerry Gauthier

Field Summary
 
Fields inherited from class org.jboss.cache.interceptors.Interceptor
cache, configuration, last, log, next, trace
 
Constructor Summary
CacheMgmtInterceptor()
           
 
Method Summary
 Map<String,Object> dumpStatistics()
          This implementation returns an empty Map.
 long getAverageReadTime()
          Returns average milliseconds for an attribute read operation This includes both hits and misses.
 long getAverageWriteTime()
          Returns average milliseconds for an attribute write operation
 long getElapsedTime()
          Returns seconds since cache started
 long getEvictions()
          Returns the number of cache eviction operations
 double getHitMissRatio()
          Returns the hit/miss ratio for the cache This ratio is defined as hits/(hits + misses)
 long getHits()
          Returns the number of cache attribute hits
 long getMisses()
          Returns the number of cache attribute misses
 int getNumberOfAttributes()
           
 int getNumberOfNodes()
           
 double getReadWriteRatio()
          Returns the read/write ratio for the cache This ratio is defined as (hits + misses)/stores
 long getStores()
          Returns the number of cache attribute put operations
 long getTimeSinceReset()
          Returns seconds since cache statistics reset If statistics haven't been reset, this will be the same as ElapsedTime
protected  Object handleEvictMethod(InvocationContext ctx, Fqn fqn)
          Handles evict()
protected  Object handleEvictVersionedNodeMethod(InvocationContext ctx, Fqn fqn, DataVersion dataVersion)
          Handles CacheImpl._evict(org.jboss.cache.Fqn, org.jboss.cache.optimistic.DataVersion)
protected  Object handleGetKeyValueMethod(InvocationContext ctx, Fqn fqn, Object key, boolean sendNodeEvent)
          Handles CacheImpl._get(org.jboss.cache.Fqn, Object, boolean)
protected  Object handlePutDataEraseMethod(InvocationContext ctx, GlobalTransaction gt, Fqn fqn, Map newData, boolean createUndoOps, boolean eraseContents)
          Handles CacheImpl._put(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, java.util.Map, boolean, boolean)
protected  Object handlePutDataMethod(InvocationContext ctx, GlobalTransaction tx, Fqn fqn, Map data, boolean createUndoOps)
          Handles CacheImpl._put(org.jboss.cache.transaction.GlobalTransaction, String, java.util.Map, boolean)
protected  Object handlePutForExternalReadMethod(InvocationContext ctx, GlobalTransaction tx, Fqn fqn, Object key, Object value)
          Handles CacheImpl._putForExternalRead(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, Object, Object)
protected  Object handlePutKeyValueMethod(InvocationContext ctx, GlobalTransaction gtx, Fqn fqn, Object key, Object value, boolean createUndoOps)
          Handles CacheImpl._put(org.jboss.cache.transaction.GlobalTransaction, String, Object, Object, boolean)
 void resetStatistics()
          This implementation is a no-op.
protected  boolean skipMethodCall(InvocationContext ctx)
          Each interceptor should extend this if it does not need any processing for current call.
 
Methods inherited from class org.jboss.cache.interceptors.MethodDispacherInterceptor
handleAddChildMethod, handleBlockChannelMethod, handleCommitMethod, handleDataGravitationCleanupMethod, handleExistsMethod, handleGetDataMapMethod, handleGetChildrenNamesMethod, handleGetKeysMethod, handleGetNodeMethod, handleLockMethod, handleMoveMethod, handleOptimisticPrepareMethod, handlePrepareMethod, handlePrintMethod, handlePutDataEraseVersionedMethod, handlePutDataVersionedMethod, handlePutForExternalReadVersionedMethod, handlePutKeyValueVersionedMethod, handleReleaseAllLocksMethod, handleRemoveDataMethod, handleRemoveDataVersionedMethod, handleRemoveKeyMethod, handleRemoveKeyVersionedMethod, handleRemoveNodeMethod, handleRemoveNodeVersionedMethod, handleRollbackMethod, handleUnblockChannelMethod, invoke
 
Methods inherited from class org.jboss.cache.interceptors.Interceptor
assertTransactionValid, getLast, getNext, getStatisticsEnabled, initLogger, isActive, isPreparing, isValid, nextInterceptor, peekNode, setCache, setLast, setNext, setStatisticsEnabled, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.cache.interceptors.InterceptorMBean
getStatisticsEnabled, setStatisticsEnabled
 

Constructor Detail

CacheMgmtInterceptor

public CacheMgmtInterceptor()
Method Detail

skipMethodCall

protected boolean skipMethodCall(InvocationContext ctx)
Description copied from class: MethodDispacherInterceptor
Each interceptor should extend this if it does not need any processing for current call. An sample usage would be: this interceptor is only interested if thre is one transaction going on. If so all handleXYZ would know that we have a transaction going and would not check its state.

Overrides:
skipMethodCall in class MethodDispacherInterceptor

handleEvictMethod

protected Object handleEvictMethod(InvocationContext ctx,
                                   Fqn fqn)
                            throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles evict()

Overrides:
handleEvictMethod in class MethodDispacherInterceptor
Throws:
Throwable

handleEvictVersionedNodeMethod

protected Object handleEvictVersionedNodeMethod(InvocationContext ctx,
                                                Fqn fqn,
                                                DataVersion dataVersion)
                                         throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl._evict(org.jboss.cache.Fqn, org.jboss.cache.optimistic.DataVersion)

Overrides:
handleEvictVersionedNodeMethod in class MethodDispacherInterceptor
Throws:
Throwable

handleGetKeyValueMethod

protected Object handleGetKeyValueMethod(InvocationContext ctx,
                                         Fqn fqn,
                                         Object key,
                                         boolean sendNodeEvent)
                                  throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl._get(org.jboss.cache.Fqn, Object, boolean)

Overrides:
handleGetKeyValueMethod in class MethodDispacherInterceptor
Throws:
Throwable

handlePutDataMethod

protected Object handlePutDataMethod(InvocationContext ctx,
                                     GlobalTransaction tx,
                                     Fqn fqn,
                                     Map data,
                                     boolean createUndoOps)
                              throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl._put(org.jboss.cache.transaction.GlobalTransaction, String, java.util.Map, boolean)

Overrides:
handlePutDataMethod in class MethodDispacherInterceptor
Throws:
Throwable

handlePutDataEraseMethod

protected Object handlePutDataEraseMethod(InvocationContext ctx,
                                          GlobalTransaction gt,
                                          Fqn fqn,
                                          Map newData,
                                          boolean createUndoOps,
                                          boolean eraseContents)
                                   throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl._put(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, java.util.Map, boolean, boolean)

Overrides:
handlePutDataEraseMethod in class MethodDispacherInterceptor
Throws:
Throwable

handlePutForExternalReadMethod

protected Object handlePutForExternalReadMethod(InvocationContext ctx,
                                                GlobalTransaction tx,
                                                Fqn fqn,
                                                Object key,
                                                Object value)
                                         throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl._putForExternalRead(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, Object, Object)

Overrides:
handlePutForExternalReadMethod in class MethodDispacherInterceptor
Throws:
Throwable

handlePutKeyValueMethod

protected Object handlePutKeyValueMethod(InvocationContext ctx,
                                         GlobalTransaction gtx,
                                         Fqn fqn,
                                         Object key,
                                         Object value,
                                         boolean createUndoOps)
                                  throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl._put(org.jboss.cache.transaction.GlobalTransaction, String, Object, Object, boolean)

Overrides:
handlePutKeyValueMethod in class MethodDispacherInterceptor
Throws:
Throwable

getHits

public long getHits()
Description copied from interface: CacheMgmtInterceptorMBean
Returns the number of cache attribute hits

Specified by:
getHits in interface CacheMgmtInterceptorMBean
Returns:
the number of cache hits

getMisses

public long getMisses()
Description copied from interface: CacheMgmtInterceptorMBean
Returns the number of cache attribute misses

Specified by:
getMisses in interface CacheMgmtInterceptorMBean
Returns:
the number of cache misses

getStores

public long getStores()
Description copied from interface: CacheMgmtInterceptorMBean
Returns the number of cache attribute put operations

Specified by:
getStores in interface CacheMgmtInterceptorMBean
Returns:
the number of cache put operations

getEvictions

public long getEvictions()
Description copied from interface: CacheMgmtInterceptorMBean
Returns the number of cache eviction operations

Specified by:
getEvictions in interface CacheMgmtInterceptorMBean
Returns:
the number of cache eviction operations

getHitMissRatio

public double getHitMissRatio()
Description copied from interface: CacheMgmtInterceptorMBean
Returns the hit/miss ratio for the cache This ratio is defined as hits/(hits + misses)

Specified by:
getHitMissRatio in interface CacheMgmtInterceptorMBean
Returns:
the hit/miss ratio for the cache

getReadWriteRatio

public double getReadWriteRatio()
Description copied from interface: CacheMgmtInterceptorMBean
Returns the read/write ratio for the cache This ratio is defined as (hits + misses)/stores

Specified by:
getReadWriteRatio in interface CacheMgmtInterceptorMBean
Returns:
the read/writes ratio for the cache

getAverageReadTime

public long getAverageReadTime()
Description copied from interface: CacheMgmtInterceptorMBean
Returns average milliseconds for an attribute read operation This includes both hits and misses.

Specified by:
getAverageReadTime in interface CacheMgmtInterceptorMBean
Returns:
the average number of milliseconds for a read operation

getAverageWriteTime

public long getAverageWriteTime()
Description copied from interface: CacheMgmtInterceptorMBean
Returns average milliseconds for an attribute write operation

Specified by:
getAverageWriteTime in interface CacheMgmtInterceptorMBean
Returns:
the average number of milliseconds for a write operation

getNumberOfAttributes

public int getNumberOfAttributes()
Specified by:
getNumberOfAttributes in interface CacheMgmtInterceptorMBean

getNumberOfNodes

public int getNumberOfNodes()
Specified by:
getNumberOfNodes in interface CacheMgmtInterceptorMBean

getElapsedTime

public long getElapsedTime()
Description copied from interface: CacheMgmtInterceptorMBean
Returns seconds since cache started

Specified by:
getElapsedTime in interface CacheMgmtInterceptorMBean
Returns:
the number of seconds since the cache was started

getTimeSinceReset

public long getTimeSinceReset()
Description copied from interface: CacheMgmtInterceptorMBean
Returns seconds since cache statistics reset If statistics haven't been reset, this will be the same as ElapsedTime

Specified by:
getTimeSinceReset in interface CacheMgmtInterceptorMBean
Returns:
the number of seconds since the cache statistics were last reset

dumpStatistics

public Map<String,Object> dumpStatistics()
Description copied from class: Interceptor
This implementation returns an empty Map. If individual Interceptors wish to expose statistics, they can override this method.

Specified by:
dumpStatistics in interface InterceptorMBean
Overrides:
dumpStatistics in class Interceptor
Returns:
a map containing statistics

resetStatistics

public void resetStatistics()
Description copied from class: Interceptor
This implementation is a no-op. If individual Interceptors wish to expose statistics, they can override this method.

Specified by:
resetStatistics in interface InterceptorMBean
Overrides:
resetStatistics in class Interceptor


Copyright © 2008 JBoss, a division of Red Hat. All Rights Reserved.