ehcache

net.sf.ehcache.management.sampled
Class SampledCacheManager

java.lang.Object
  extended by javax.management.StandardMBean
      extended by net.sf.ehcache.hibernate.management.impl.BaseEmitterBean
          extended by net.sf.ehcache.management.sampled.SampledCacheManager
All Implemented Interfaces:
DynamicMBean, MBeanRegistration, NotificationBroadcaster, NotificationEmitter, SampledCacheManagerMBean

public class SampledCacheManager
extends BaseEmitterBean
implements SampledCacheManagerMBean

An implementation of SampledCacheManagerMBean

Since:
1.7
Author:
Abhishek Sanoujam

Field Summary
 
Fields inherited from class net.sf.ehcache.hibernate.management.impl.BaseEmitterBean
emitter, sequenceNumber
 
Fields inherited from interface net.sf.ehcache.management.sampled.SampledCacheManagerMBean
CACHES_CLEARED, CACHES_ENABLED, STATISTICS_ENABLED, STATISTICS_RESET
 
Constructor Summary
SampledCacheManager(CacheManager cacheManager)
          Constructor taking the backing CacheManager
 
Method Summary
 void clearAll()
          Clears the contents of all caches in the CacheManager, but without removing any caches.
 void clearStatistics()
          Clears statistics of all caches for the associated cacheManager
 void disableStatistics()
          Disable statistics for each cache contained by cacheManager
protected  void doDispose()
          Dispose callback of subclasses
 void enableStatistics()
          Enable statistics for each cache contained by cacheManager
 String generateActiveConfigDeclaration()
          generateActiveConfigDeclaration
 String generateActiveConfigDeclaration(String cacheName)
          generateActiveConfigDeclaration
 long getCacheAverageSearchTime()
           
 long getCacheEvictionRate()
           
 long getCacheExpirationRate()
           
 long getCacheHitRate()
           
 Map<String,long[]> getCacheMetrics()
          Get a map of cache name to performance metrics (hits, misses).
 long getCacheMissRate()
           
 String[] getCacheNames()
          Gets the cache names managed by the CacheManager
 long getCachePutRate()
           
 long getCacheSearchRate()
           
 long getCacheUpdateRate()
           
 boolean getHasWriteBehindWriter()
          Returns whether any caches are configured for write-behind
 String getMBeanRegisteredName()
          Gets the name used to register this mbean.
 String getName()
          Gets the actual name of the cache manager.
 MBeanNotificationInfo[] getNotificationInfo()
           
 boolean getSearchable()
          
 String getStatus()
          Gets the status attribute of the Ehcache
 boolean getTransactional()
          Are any of the caches transactional
 long getTransactionCommitRate()
          
 long getTransactionCommittedCount()
          Get the committed transactions count
 long getTransactionRollbackRate()
          
 long getTransactionRolledBackCount()
          Get the rolled back transactions count
 long getTransactionTimedOutCount()
          Get the timed out transactions count.
 int getWriterMaxQueueSize()
          Maximum elements that can be queued for processing by the write-behind writer
 long getWriterQueueLength()
          Returns the total length of all write-behind queues across all caches
 boolean isEnabled()
          Returns if each contained cache is enabled.
 boolean isStatisticsEnabled()
          Returns true iff each contained cache has statistics enabled
 void setEnabled(boolean enabled)
          Enables/disables each of the contained caches.
 void setStatisticsEnabled(boolean enabled)
          Enables/disables each contained cache
 void shutdown()
          Shuts down the CacheManager.
 
Methods inherited from class net.sf.ehcache.hibernate.management.impl.BaseEmitterBean
addNotificationListener, dispose, removeNotificationListener, removeNotificationListener, sendNotification, sendNotification, sendNotification
 
Methods inherited from class javax.management.StandardMBean
cacheMBeanInfo, getAttribute, getAttributes, getCachedMBeanInfo, getClassName, getConstructors, getDescription, getDescription, getDescription, getDescription, getDescription, getDescription, getDescription, getImpact, getImplementation, getImplementationClass, getMBeanInfo, getMBeanInterface, getParameterName, getParameterName, invoke, postDeregister, postRegister, preDeregister, preRegister, setAttribute, setAttributes, setImplementation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SampledCacheManager

public SampledCacheManager(CacheManager cacheManager)
                    throws NotCompliantMBeanException
Constructor taking the backing CacheManager

Parameters:
cacheManager -
Throws:
NotCompliantMBeanException
Method Detail

doDispose

protected void doDispose()
Dispose callback of subclasses

Specified by:
doDispose in class BaseEmitterBean

clearAll

public void clearAll()
Clears the contents of all caches in the CacheManager, but without removing any caches.

This method is not synchronized. It only guarantees to clear those elements in a cache at the time that the Ehcache.removeAll() mehod on each cache is called.

Specified by:
clearAll in interface SampledCacheManagerMBean

getCacheNames

public String[] getCacheNames()
                       throws IllegalStateException
Gets the cache names managed by the CacheManager

Specified by:
getCacheNames in interface SampledCacheManagerMBean
Throws:
IllegalStateException

getStatus

public String getStatus()
Gets the status attribute of the Ehcache

Specified by:
getStatus in interface SampledCacheManagerMBean
Returns:
The status value, as a String from the Status enum class

shutdown

public void shutdown()
Shuts down the CacheManager.

If the shutdown occurs on the singleton, then the singleton is removed, so that if a singleton access method is called, a new singleton will be created.

Specified by:
shutdown in interface SampledCacheManagerMBean

getCacheMetrics

public Map<String,long[]> getCacheMetrics()
Description copied from interface: SampledCacheManagerMBean
Get a map of cache name to performance metrics (hits, misses).

Specified by:
getCacheMetrics in interface SampledCacheManagerMBean
Returns:
map of cache metrics (hits, misses)

getCacheHitRate

public long getCacheHitRate()
Specified by:
getCacheHitRate in interface SampledCacheManagerMBean
Returns:
aggregate hit rate

getCacheMissRate

public long getCacheMissRate()
Specified by:
getCacheMissRate in interface SampledCacheManagerMBean
Returns:
aggregate miss rate

getCachePutRate

public long getCachePutRate()
Specified by:
getCachePutRate in interface SampledCacheManagerMBean
Returns:
aggregate put rate

getCacheUpdateRate

public long getCacheUpdateRate()
Specified by:
getCacheUpdateRate in interface SampledCacheManagerMBean
Returns:
aggregate update rate

getCacheEvictionRate

public long getCacheEvictionRate()
Specified by:
getCacheEvictionRate in interface SampledCacheManagerMBean
Returns:
aggregate eviction rate

getCacheExpirationRate

public long getCacheExpirationRate()
Specified by:
getCacheExpirationRate in interface SampledCacheManagerMBean
Returns:
aggregate expiration rate

getCacheSearchRate

public long getCacheSearchRate()
Specified by:
getCacheSearchRate in interface SampledCacheManagerMBean
Returns:
aggregate search rate

getCacheAverageSearchTime

public long getCacheAverageSearchTime()
Specified by:
getCacheAverageSearchTime in interface SampledCacheManagerMBean
Returns:
aggregate search time

getHasWriteBehindWriter

public boolean getHasWriteBehindWriter()
Returns whether any caches are configured for write-behind

Specified by:
getHasWriteBehindWriter in interface SampledCacheManagerMBean

getWriterQueueLength

public long getWriterQueueLength()
Description copied from interface: SampledCacheManagerMBean
Returns the total length of all write-behind queues across all caches

Specified by:
getWriterQueueLength in interface SampledCacheManagerMBean
Returns:
aggregate writer queue length

getWriterMaxQueueSize

public int getWriterMaxQueueSize()
Maximum elements that can be queued for processing by the write-behind writer

Specified by:
getWriterMaxQueueSize in interface SampledCacheManagerMBean
Returns:
aggregate of the maximum elements that can be waiting to be processed by the write-behind writer across all caches

getName

public String getName()
Gets the actual name of the cache manager. This may be different from the name used to register this mbean as there can potentially be multiple cache managers with same name

Specified by:
getName in interface SampledCacheManagerMBean
See Also:
SampledCacheManagerMBean.getName()

getMBeanRegisteredName

public String getMBeanRegisteredName()
Gets the name used to register this mbean.

Specified by:
getMBeanRegisteredName in interface SampledCacheManagerMBean
See Also:
SampledCacheManagerMBean.getName()

clearStatistics

public void clearStatistics()
Clears statistics of all caches for the associated cacheManager

Specified by:
clearStatistics in interface SampledCacheManagerMBean

enableStatistics

public void enableStatistics()
Enable statistics for each cache contained by cacheManager

Specified by:
enableStatistics in interface SampledCacheManagerMBean

disableStatistics

public void disableStatistics()
Disable statistics for each cache contained by cacheManager

Specified by:
disableStatistics in interface SampledCacheManagerMBean

setStatisticsEnabled

public void setStatisticsEnabled(boolean enabled)
Enables/disables each contained cache

Specified by:
setStatisticsEnabled in interface SampledCacheManagerMBean

isStatisticsEnabled

public boolean isStatisticsEnabled()
Returns true iff each contained cache has statistics enabled

Specified by:
isStatisticsEnabled in interface SampledCacheManagerMBean

generateActiveConfigDeclaration

public String generateActiveConfigDeclaration()
generateActiveConfigDeclaration

Specified by:
generateActiveConfigDeclaration in interface SampledCacheManagerMBean
Returns:
CacheManager configuration as String

generateActiveConfigDeclaration

public String generateActiveConfigDeclaration(String cacheName)
generateActiveConfigDeclaration

Specified by:
generateActiveConfigDeclaration in interface SampledCacheManagerMBean
Returns:
Cache configuration as String

getTransactional

public boolean getTransactional()
Are any of the caches transactional

Specified by:
getTransactional in interface SampledCacheManagerMBean
See Also:
CacheConfiguration.TransactionalMode

getSearchable

public boolean getSearchable()

Specified by:
getSearchable in interface SampledCacheManagerMBean
Returns:
if any contained caches are configured for search

getTransactionCommittedCount

public long getTransactionCommittedCount()
Get the committed transactions count

Specified by:
getTransactionCommittedCount in interface SampledCacheManagerMBean
Returns:
the committed transactions count

getTransactionCommitRate

public long getTransactionCommitRate()

Specified by:
getTransactionCommitRate in interface SampledCacheManagerMBean
Returns:
aggregate Xa commit rate

getTransactionRolledBackCount

public long getTransactionRolledBackCount()
Get the rolled back transactions count

Specified by:
getTransactionRolledBackCount in interface SampledCacheManagerMBean
Returns:
the rolled back transactions count

getTransactionRollbackRate

public long getTransactionRollbackRate()

Specified by:
getTransactionRollbackRate in interface SampledCacheManagerMBean
Returns:
aggregate Xa rollback rate

getTransactionTimedOutCount

public long getTransactionTimedOutCount()
Get the timed out transactions count. Note that only transactions which failed to commit due to a timeout are taken into account

Specified by:
getTransactionTimedOutCount in interface SampledCacheManagerMBean
Returns:
the timed out transactions count

isEnabled

public boolean isEnabled()
                  throws CacheException
Returns if each contained cache is enabled.

Specified by:
isEnabled in interface SampledCacheManagerMBean
Returns:
boolean indicating that each cache is enabled
Throws:
CacheException

setEnabled

public void setEnabled(boolean enabled)
Enables/disables each of the contained caches.

Specified by:
setEnabled in interface SampledCacheManagerMBean

getNotificationInfo

public MBeanNotificationInfo[] getNotificationInfo()
Specified by:
getNotificationInfo in interface NotificationBroadcaster
Specified by:
getNotificationInfo in class BaseEmitterBean
See Also:
BaseEmitterBean.getNotificationInfo()

ehcache

true