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:
javax.management.DynamicMBean, javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, javax.management.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
 void enableStatistics()
          Enable statistics for each cache contained by cacheManager
 java.lang.String generateActiveConfigDeclaration()
          generateActiveConfigDeclaration
 java.lang.String generateActiveConfigDeclaration(java.lang.String cacheName)
          generateActiveConfigDeclaration
 long getCacheEvictionRate()
           
 long getCacheExpirationRate()
           
 long getCacheHitRate()
           
 java.util.Map<java.lang.String,long[]> getCacheMetrics()
          Get a map of cache name to performance metrics (hits, misses).
 long getCacheMissRate()
           
 java.lang.String[] getCacheNames()
          Gets the cache names managed by the CacheManager
 long getCachePutRate()
           
 long getCacheUpdateRate()
           
 java.lang.String getMBeanRegisteredName()
          Gets the name used to register this mbean.
 java.lang.String getName()
          Gets the actual name of the cache manager.
 javax.management.MBeanNotificationInfo[] getNotificationInfo()
           
 java.lang.String getStatus()
          Gets the status attribute of the Ehcache
 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, 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 javax.management.NotCompliantMBeanException
Constructor taking the backing CacheManager

Parameters:
cacheManager -
Throws:
javax.management.NotCompliantMBeanException
Method Detail

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 java.lang.String[] getCacheNames()
                                 throws java.lang.IllegalStateException
Gets the cache names managed by the CacheManager

Specified by:
getCacheNames in interface SampledCacheManagerMBean
Throws:
java.lang.IllegalStateException

getStatus

public java.lang.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 java.util.Map<java.lang.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

getName

public java.lang.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 java.lang.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 java.lang.String generateActiveConfigDeclaration()
generateActiveConfigDeclaration

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

generateActiveConfigDeclaration

public java.lang.String generateActiveConfigDeclaration(java.lang.String cacheName)
generateActiveConfigDeclaration

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

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 javax.management.MBeanNotificationInfo[] getNotificationInfo()
Specified by:
getNotificationInfo in interface javax.management.NotificationBroadcaster
Specified by:
getNotificationInfo in class BaseEmitterBean
See Also:
BaseEmitterBean.getNotificationInfo()

ehcache

true