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, CacheManagerSampler, SampledCacheManagerMBean

public class SampledCacheManager
extends BaseEmitterBean
implements SampledCacheManagerMBean

An implementation of SampledCacheManagerMBean

Author:
Abhishek Sanoujam, byoukste

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
CACHE_MANAGER_CHANGED, 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.
protected  void doDispose()
          Dispose callback of subclasses
 Object[][] executeQuery(String queryString)
          Execute a BMSQL query against the CacheManager and return result grid.
 String generateActiveConfigDeclaration()
          generateActiveConfigDeclaration
 String generateActiveConfigDeclaration(String cacheName)
          generateActiveConfigDeclaration
 float getCacheAverageGetTime()
           
 long getCacheAverageSearchTime()
           
 long getCacheEvictionRate()
           
 long getCacheExpirationRate()
           
 long getCacheHitRate()
           
 long getCacheInMemoryHitRate()
           
 long getCacheInMemoryMissRate()
           
 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 getCacheOffHeapHitRate()
           
 long getCacheOffHeapMissRate()
           
 long getCacheOnDiskHitRate()
           
 long getCacheOnDiskMissRate()
           
 long getCachePutRate()
           
 long getCacheRemoveRate()
           
 long getCacheSearchRate()
           
 long getCacheUpdateRate()
           
 String getClusterUUID()
          Gets the cluster uuid if applicable.
 boolean getHasWriteBehindWriter()
          Returns whether any caches are configured for write-behind
 long getMaxBytesLocalDisk()
          Maximum number of bytes of entries in the disk stores of all caches that did not declare their own max size.
 String getMaxBytesLocalDiskAsString()
          
 long getMaxBytesLocalHeap()
          Maximum number of bytes of entries in the heap memory stores of all caches that did not declare their own max size.
 String getMaxBytesLocalHeapAsString()
          
 long getMaxBytesLocalOffHeap()
          Maximum number of bytes of entries in the off-heap stores of all caches that did not declare their own max size.
 String getMaxBytesLocalOffHeapAsString()
          
 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.
 void setEnabled(boolean enabled)
          Enables/disables each of the contained caches.
 void setMaxBytesLocalDisk(long maxBytes)
          
 void setMaxBytesLocalDiskAsString(String maxBytes)
          
 void setMaxBytesLocalHeap(long maxBytes)
          
 void setMaxBytesLocalHeapAsString(String maxBytes)
          
 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 - the cacheManager to wrap
Throws:
NotCompliantMBeanException - if invalid object is registered
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 CacheManagerSampler

getCacheNames

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

Specified by:
getCacheNames in interface CacheManagerSampler
Throws:
IllegalStateException

getStatus

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

Specified by:
getStatus in interface CacheManagerSampler
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 CacheManagerSampler

getCacheMetrics

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

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

getCacheHitRate

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

getCacheInMemoryHitRate

public long getCacheInMemoryHitRate()
Specified by:
getCacheInMemoryHitRate in interface CacheManagerSampler
Returns:
aggregate in-memory hit rate

getCacheOffHeapHitRate

public long getCacheOffHeapHitRate()
Specified by:
getCacheOffHeapHitRate in interface CacheManagerSampler
Returns:
aggregate off-heap hit rate

getCacheOnDiskHitRate

public long getCacheOnDiskHitRate()
Specified by:
getCacheOnDiskHitRate in interface CacheManagerSampler
Returns:
aggregate on-disk hit rate

getCacheMissRate

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

getCacheInMemoryMissRate

public long getCacheInMemoryMissRate()
Specified by:
getCacheInMemoryMissRate in interface CacheManagerSampler
Returns:
aggregate in-memory miss rate

getCacheOffHeapMissRate

public long getCacheOffHeapMissRate()
Specified by:
getCacheOffHeapMissRate in interface CacheManagerSampler
Returns:
aggregate off-heap miss rate

getCacheOnDiskMissRate

public long getCacheOnDiskMissRate()
Specified by:
getCacheOnDiskMissRate in interface CacheManagerSampler
Returns:
aggregate on-disk miss rate

getCachePutRate

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

getCacheUpdateRate

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

getCacheRemoveRate

public long getCacheRemoveRate()
Specified by:
getCacheRemoveRate in interface CacheManagerSampler
Returns:
aggregate remove rate

getCacheEvictionRate

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

getCacheExpirationRate

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

getCacheAverageGetTime

public float getCacheAverageGetTime()
Specified by:
getCacheAverageGetTime in interface CacheManagerSampler
Returns:
aggregate average get time (ms.)

getCacheSearchRate

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

getCacheAverageSearchTime

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

getHasWriteBehindWriter

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

Specified by:
getHasWriteBehindWriter in interface CacheManagerSampler

getWriterQueueLength

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

Specified by:
getWriterQueueLength in interface CacheManagerSampler
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 CacheManagerSampler
Returns:
aggregate of the maximum elements that can be waiting to be processed by the write-behind writer across all caches

getMaxBytesLocalDisk

public long getMaxBytesLocalDisk()
Maximum number of bytes of entries in the disk stores of all caches that did not declare their own max size.

Specified by:
getMaxBytesLocalDisk in interface CacheManagerSampler
Returns:
maximum number of bytes in the disk stores of all caches that did not declare their own max size.

getMaxBytesLocalDiskAsString

public String getMaxBytesLocalDiskAsString()

Specified by:
getMaxBytesLocalDiskAsString in interface CacheManagerSampler
Returns:
Original input for maxBytesLocalDisk

setMaxBytesLocalDisk

public void setMaxBytesLocalDisk(long maxBytes)

Specified by:
setMaxBytesLocalDisk in interface CacheManagerSampler

setMaxBytesLocalDiskAsString

public void setMaxBytesLocalDiskAsString(String maxBytes)

Specified by:
setMaxBytesLocalDiskAsString in interface CacheManagerSampler

getMaxBytesLocalHeap

public long getMaxBytesLocalHeap()
Maximum number of bytes of entries in the heap memory stores of all caches that did not declare their own max size.

Specified by:
getMaxBytesLocalHeap in interface CacheManagerSampler
Returns:
maximum number of bytes in the heap memory stores of all caches that did not declare their own max size.

getMaxBytesLocalHeapAsString

public String getMaxBytesLocalHeapAsString()

Specified by:
getMaxBytesLocalHeapAsString in interface CacheManagerSampler
Returns:
Original input for maxBytesLocalHeap

setMaxBytesLocalHeap

public void setMaxBytesLocalHeap(long maxBytes)

Specified by:
setMaxBytesLocalHeap in interface CacheManagerSampler

setMaxBytesLocalHeapAsString

public void setMaxBytesLocalHeapAsString(String maxBytes)

Specified by:
setMaxBytesLocalHeapAsString in interface CacheManagerSampler

getMaxBytesLocalOffHeap

public long getMaxBytesLocalOffHeap()
Maximum number of bytes of entries in the off-heap stores of all caches that did not declare their own max size.

Specified by:
getMaxBytesLocalOffHeap in interface CacheManagerSampler
Returns:
maximum number of bytes in the off-heap stores of all caches that did not declare their own max size.

getMaxBytesLocalOffHeapAsString

public String getMaxBytesLocalOffHeapAsString()

Specified by:
getMaxBytesLocalOffHeapAsString in interface CacheManagerSampler
Returns:
Original input for maxBytesLocalOffHeap

getName

public String getName()
Gets the actual name of the cache manager.

Specified by:
getName in interface CacheManagerSampler
See Also:
getName()

getClusterUUID

public String getClusterUUID()
Description copied from interface: CacheManagerSampler
Gets the cluster uuid if applicable.

Specified by:
getClusterUUID in interface CacheManagerSampler
Returns:
the cluster uuid
See Also:
getClusterUUID()

getMBeanRegisteredName

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

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

generateActiveConfigDeclaration

public String generateActiveConfigDeclaration()
generateActiveConfigDeclaration

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

generateActiveConfigDeclaration

public String generateActiveConfigDeclaration(String cacheName)
generateActiveConfigDeclaration

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

getTransactional

public boolean getTransactional()
Are any of the caches transactional

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

getSearchable

public boolean getSearchable()

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

getTransactionCommittedCount

public long getTransactionCommittedCount()
Get the committed transactions count

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

getTransactionCommitRate

public long getTransactionCommitRate()

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

getTransactionRolledBackCount

public long getTransactionRolledBackCount()
Get the rolled back transactions count

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

getTransactionRollbackRate

public long getTransactionRollbackRate()

Specified by:
getTransactionRollbackRate in interface CacheManagerSampler
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 CacheManagerSampler
Returns:
the timed out transactions count

isEnabled

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

Specified by:
isEnabled in interface CacheManagerSampler
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 CacheManagerSampler

getNotificationInfo

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

executeQuery

public Object[][] executeQuery(String queryString)
Description copied from interface: CacheManagerSampler
Execute a BMSQL query against the CacheManager and return result grid.

Specified by:
executeQuery in interface CacheManagerSampler
Returns:
query result grid

ehcache

Copyright 2001-2017, Terracotta, Inc.