Class SampledCacheManager
- java.lang.Object
-
- javax.management.StandardMBean
-
- net.sf.ehcache.hibernate.management.impl.BaseEmitterBean
-
- net.sf.ehcache.management.sampled.SampledCacheManager
-
- All Implemented Interfaces:
javax.management.DynamicMBean,javax.management.MBeanRegistration,javax.management.NotificationBroadcaster,javax.management.NotificationEmitter,CacheManagerSampler,SampledCacheManagerMBean
public class SampledCacheManager extends BaseEmitterBean implements SampledCacheManagerMBean
An implementation ofSampledCacheManagerMBean- 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
Constructors Constructor Description SampledCacheManager(CacheManager cacheManager)Constructor taking the backingCacheManager
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearAll()Clears the contents of all caches in the CacheManager, but without removing any caches.protected voiddoDispose()Dispose callback of subclassesjava.lang.Object[][]executeQuery(java.lang.String queryString)Execute a BMSQL query against the CacheManager and return result grid.java.lang.StringgenerateActiveConfigDeclaration()generateActiveConfigDeclarationjava.lang.StringgenerateActiveConfigDeclaration(java.lang.String cacheName)generateActiveConfigDeclarationfloatgetCacheAverageGetTime()longgetCacheAverageSearchTime()longgetCacheEvictionRate()longgetCacheExpirationRate()longgetCacheHitRate()longgetCacheInMemoryHitRate()longgetCacheInMemoryMissRate()java.util.Map<java.lang.String,long[]>getCacheMetrics()Get a map of cache name to performance metrics (hits, misses).longgetCacheMissRate()java.lang.String[]getCacheNames()Gets the cache names managed by the CacheManagerlonggetCacheOffHeapHitRate()longgetCacheOffHeapMissRate()longgetCacheOnDiskHitRate()longgetCacheOnDiskMissRate()longgetCachePutRate()longgetCacheRemoveRate()longgetCacheSearchRate()longgetCacheUpdateRate()java.lang.StringgetClusterUUID()Gets the cluster uuid if applicable.booleangetHasWriteBehindWriter()Returns whether any caches are configured for write-behindlonggetMaxBytesLocalDisk()Maximum number of bytes of entries in the disk stores of all caches that did not declare their own max size.java.lang.StringgetMaxBytesLocalDiskAsString()longgetMaxBytesLocalHeap()Maximum number of bytes of entries in the heap memory stores of all caches that did not declare their own max size.java.lang.StringgetMaxBytesLocalHeapAsString()longgetMaxBytesLocalOffHeap()Maximum number of bytes of entries in the off-heap stores of all caches that did not declare their own max size.java.lang.StringgetMaxBytesLocalOffHeapAsString()java.lang.StringgetMBeanRegisteredName()Gets the name used to register this mbean.java.lang.StringgetName()Gets the actual name of the cache manager.javax.management.MBeanNotificationInfo[]getNotificationInfo()booleangetSearchable()java.lang.StringgetStatus()Gets the status attribute of the EhcachebooleangetTransactional()Are any of the caches transactionallonggetTransactionCommitRate()longgetTransactionCommittedCount()Get the committed transactions countlonggetTransactionRollbackRate()longgetTransactionRolledBackCount()Get the rolled back transactions countlonggetTransactionTimedOutCount()Get the timed out transactions count.intgetWriterMaxQueueSize()Maximum elements that can be queued for processing by the write-behind writerlonggetWriterQueueLength()Returns the total length of all write-behind queues across all cachesbooleanisEnabled()Returns if each contained cache is enabled.voidsetEnabled(boolean enabled)Enables/disables each of the contained caches.voidsetMaxBytesLocalDisk(long maxBytes)voidsetMaxBytesLocalDiskAsString(java.lang.String maxBytes)voidsetMaxBytesLocalHeap(long maxBytes)voidsetMaxBytesLocalHeapAsString(java.lang.String maxBytes)voidshutdown()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
-
-
-
-
Constructor Detail
-
SampledCacheManager
public SampledCacheManager(CacheManager cacheManager) throws javax.management.NotCompliantMBeanException
Constructor taking the backingCacheManager- Parameters:
cacheManager- the cacheManager to wrap- Throws:
javax.management.NotCompliantMBeanException- if invalid object is registered
-
-
Method Detail
-
doDispose
protected void doDispose()
Dispose callback of subclasses- Specified by:
doDisposein classBaseEmitterBean
-
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:
clearAllin interfaceCacheManagerSampler
-
getCacheNames
public java.lang.String[] getCacheNames() throws java.lang.IllegalStateExceptionGets the cache names managed by the CacheManager- Specified by:
getCacheNamesin interfaceCacheManagerSampler- Throws:
java.lang.IllegalStateException
-
getStatus
public java.lang.String getStatus()
Gets the status attribute of the Ehcache- Specified by:
getStatusin interfaceCacheManagerSampler- 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:
shutdownin interfaceCacheManagerSampler
-
getCacheMetrics
public java.util.Map<java.lang.String,long[]> getCacheMetrics()
Description copied from interface:CacheManagerSamplerGet a map of cache name to performance metrics (hits, misses).- Specified by:
getCacheMetricsin interfaceCacheManagerSampler- Returns:
- map of cache metrics (hits, misses)
-
getCacheHitRate
public long getCacheHitRate()
- Specified by:
getCacheHitRatein interfaceCacheManagerSampler- Returns:
- aggregate hit rate
-
getCacheInMemoryHitRate
public long getCacheInMemoryHitRate()
- Specified by:
getCacheInMemoryHitRatein interfaceCacheManagerSampler- Returns:
- aggregate in-memory hit rate
-
getCacheOffHeapHitRate
public long getCacheOffHeapHitRate()
- Specified by:
getCacheOffHeapHitRatein interfaceCacheManagerSampler- Returns:
- aggregate off-heap hit rate
-
getCacheOnDiskHitRate
public long getCacheOnDiskHitRate()
- Specified by:
getCacheOnDiskHitRatein interfaceCacheManagerSampler- Returns:
- aggregate on-disk hit rate
-
getCacheMissRate
public long getCacheMissRate()
- Specified by:
getCacheMissRatein interfaceCacheManagerSampler- Returns:
- aggregate miss rate
-
getCacheInMemoryMissRate
public long getCacheInMemoryMissRate()
- Specified by:
getCacheInMemoryMissRatein interfaceCacheManagerSampler- Returns:
- aggregate in-memory miss rate
-
getCacheOffHeapMissRate
public long getCacheOffHeapMissRate()
- Specified by:
getCacheOffHeapMissRatein interfaceCacheManagerSampler- Returns:
- aggregate off-heap miss rate
-
getCacheOnDiskMissRate
public long getCacheOnDiskMissRate()
- Specified by:
getCacheOnDiskMissRatein interfaceCacheManagerSampler- Returns:
- aggregate on-disk miss rate
-
getCachePutRate
public long getCachePutRate()
- Specified by:
getCachePutRatein interfaceCacheManagerSampler- Returns:
- aggregate put rate
-
getCacheUpdateRate
public long getCacheUpdateRate()
- Specified by:
getCacheUpdateRatein interfaceCacheManagerSampler- Returns:
- aggregate update rate
-
getCacheRemoveRate
public long getCacheRemoveRate()
- Specified by:
getCacheRemoveRatein interfaceCacheManagerSampler- Returns:
- aggregate remove rate
-
getCacheEvictionRate
public long getCacheEvictionRate()
- Specified by:
getCacheEvictionRatein interfaceCacheManagerSampler- Returns:
- aggregate eviction rate
-
getCacheExpirationRate
public long getCacheExpirationRate()
- Specified by:
getCacheExpirationRatein interfaceCacheManagerSampler- Returns:
- aggregate expiration rate
-
getCacheAverageGetTime
public float getCacheAverageGetTime()
- Specified by:
getCacheAverageGetTimein interfaceCacheManagerSampler- Returns:
- aggregate average get time (ms.)
-
getCacheSearchRate
public long getCacheSearchRate()
- Specified by:
getCacheSearchRatein interfaceCacheManagerSampler- Returns:
- aggregate search rate
-
getCacheAverageSearchTime
public long getCacheAverageSearchTime()
- Specified by:
getCacheAverageSearchTimein interfaceCacheManagerSampler- Returns:
- aggregate search time
-
getHasWriteBehindWriter
public boolean getHasWriteBehindWriter()
Returns whether any caches are configured for write-behind- Specified by:
getHasWriteBehindWriterin interfaceCacheManagerSampler
-
getWriterQueueLength
public long getWriterQueueLength()
Description copied from interface:CacheManagerSamplerReturns the total length of all write-behind queues across all caches- Specified by:
getWriterQueueLengthin interfaceCacheManagerSampler- Returns:
- aggregate writer queue length
-
getWriterMaxQueueSize
public int getWriterMaxQueueSize()
Maximum elements that can be queued for processing by the write-behind writer- Specified by:
getWriterMaxQueueSizein interfaceCacheManagerSampler- 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:
getMaxBytesLocalDiskin interfaceCacheManagerSampler- Returns:
- maximum number of bytes in the disk stores of all caches that did not declare their own max size.
-
getMaxBytesLocalDiskAsString
public java.lang.String getMaxBytesLocalDiskAsString()
- Specified by:
getMaxBytesLocalDiskAsStringin interfaceCacheManagerSampler- Returns:
- Original input for maxBytesLocalDisk
-
setMaxBytesLocalDisk
public void setMaxBytesLocalDisk(long maxBytes)
- Specified by:
setMaxBytesLocalDiskin interfaceCacheManagerSampler
-
setMaxBytesLocalDiskAsString
public void setMaxBytesLocalDiskAsString(java.lang.String maxBytes)
- Specified by:
setMaxBytesLocalDiskAsStringin interfaceCacheManagerSampler
-
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:
getMaxBytesLocalHeapin interfaceCacheManagerSampler- Returns:
- maximum number of bytes in the heap memory stores of all caches that did not declare their own max size.
-
getMaxBytesLocalHeapAsString
public java.lang.String getMaxBytesLocalHeapAsString()
- Specified by:
getMaxBytesLocalHeapAsStringin interfaceCacheManagerSampler- Returns:
- Original input for maxBytesLocalHeap
-
setMaxBytesLocalHeap
public void setMaxBytesLocalHeap(long maxBytes)
- Specified by:
setMaxBytesLocalHeapin interfaceCacheManagerSampler
-
setMaxBytesLocalHeapAsString
public void setMaxBytesLocalHeapAsString(java.lang.String maxBytes)
- Specified by:
setMaxBytesLocalHeapAsStringin interfaceCacheManagerSampler
-
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:
getMaxBytesLocalOffHeapin interfaceCacheManagerSampler- Returns:
- maximum number of bytes in the off-heap stores of all caches that did not declare their own max size.
-
getMaxBytesLocalOffHeapAsString
public java.lang.String getMaxBytesLocalOffHeapAsString()
- Specified by:
getMaxBytesLocalOffHeapAsStringin interfaceCacheManagerSampler- Returns:
- Original input for maxBytesLocalOffHeap
-
getName
public java.lang.String getName()
Gets the actual name of the cache manager.- Specified by:
getNamein interfaceCacheManagerSampler- See Also:
getName()
-
getClusterUUID
public java.lang.String getClusterUUID()
Description copied from interface:CacheManagerSamplerGets the cluster uuid if applicable.- Specified by:
getClusterUUIDin interfaceCacheManagerSampler- Returns:
- the cluster uuid
- See Also:
getClusterUUID()
-
getMBeanRegisteredName
public java.lang.String getMBeanRegisteredName()
Gets the name used to register this mbean.- Specified by:
getMBeanRegisteredNamein interfaceSampledCacheManagerMBean- See Also:
CacheManagerSampler.getName()
-
generateActiveConfigDeclaration
public java.lang.String generateActiveConfigDeclaration()
generateActiveConfigDeclaration- Specified by:
generateActiveConfigDeclarationin interfaceCacheManagerSampler- Returns:
- CacheManager configuration as String
-
generateActiveConfigDeclaration
public java.lang.String generateActiveConfigDeclaration(java.lang.String cacheName)
generateActiveConfigDeclaration- Specified by:
generateActiveConfigDeclarationin interfaceCacheManagerSampler- Returns:
- Cache configuration as String
-
getTransactional
public boolean getTransactional()
Are any of the caches transactional- Specified by:
getTransactionalin interfaceCacheManagerSampler- See Also:
CacheConfiguration.TransactionalMode
-
getSearchable
public boolean getSearchable()
- Specified by:
getSearchablein interfaceCacheManagerSampler- Returns:
- if any contained caches are configured for search
-
getTransactionCommittedCount
public long getTransactionCommittedCount()
Get the committed transactions count- Specified by:
getTransactionCommittedCountin interfaceCacheManagerSampler- Returns:
- the committed transactions count
-
getTransactionCommitRate
public long getTransactionCommitRate()
- Specified by:
getTransactionCommitRatein interfaceCacheManagerSampler- Returns:
- aggregate Xa commit rate
-
getTransactionRolledBackCount
public long getTransactionRolledBackCount()
Get the rolled back transactions count- Specified by:
getTransactionRolledBackCountin interfaceCacheManagerSampler- Returns:
- the rolled back transactions count
-
getTransactionRollbackRate
public long getTransactionRollbackRate()
- Specified by:
getTransactionRollbackRatein interfaceCacheManagerSampler- 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:
getTransactionTimedOutCountin interfaceCacheManagerSampler- Returns:
- the timed out transactions count
-
isEnabled
public boolean isEnabled() throws CacheExceptionReturns if each contained cache is enabled.- Specified by:
isEnabledin interfaceCacheManagerSampler- 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:
setEnabledin interfaceCacheManagerSampler
-
getNotificationInfo
public javax.management.MBeanNotificationInfo[] getNotificationInfo()
- Specified by:
getNotificationInfoin interfacejavax.management.NotificationBroadcaster- Specified by:
getNotificationInfoin classBaseEmitterBean- See Also:
BaseEmitterBean.getNotificationInfo()
-
executeQuery
public java.lang.Object[][] executeQuery(java.lang.String queryString)
Description copied from interface:CacheManagerSamplerExecute a BMSQL query against the CacheManager and return result grid.- Specified by:
executeQueryin interfaceCacheManagerSampler- Returns:
- query result grid
-
-