ehcache

net.sf.ehcache.hibernate.management.impl
Class EhcacheHibernate

java.lang.Object
  extended by javax.management.StandardMBean
      extended by net.sf.ehcache.hibernate.management.impl.BaseEmitterBean
          extended by net.sf.ehcache.hibernate.management.impl.EhcacheHibernate
All Implemented Interfaces:
DynamicMBean, MBeanRegistration, NotificationBroadcaster, NotificationEmitter, EhcacheHibernateMBean, EhcacheStats, HibernateStats

public class EhcacheHibernate
extends BaseEmitterBean
implements EhcacheHibernateMBean

Implementation of the EhcacheHibernateMBean

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.hibernate.management.api.EhcacheStats
CACHE_ENABLED, CACHE_FLUSHED, CACHE_REGION_CHANGED, CACHE_REGION_FLUSHED, CACHE_STATISTICS_ENABLED, CACHE_STATISTICS_RESET
 
Fields inherited from interface net.sf.ehcache.hibernate.management.api.HibernateStats
CACHE_ENABLED, CACHE_FLUSHED, CACHE_REGION_CHANGED, CACHE_REGION_FLUSHED, CACHE_STATISTICS_ENABLED, CACHE_STATISTICS_RESET
 
Constructor Summary
EhcacheHibernate(CacheManager manager)
          Constructor accepting the backing CacheManager
 
Method Summary
 void clearStats()
          Clears statistics, resets all counters to zero
 void disableStats()
          Disables statistics collection
protected  void doDispose()
          Dispose callback of subclasses
 void enableHibernateStatistics(SessionFactory sessionFactory)
          Enable hibernate statistics with the input session factory
 void enableStats()
          Enables statistics collection
 void flushRegionCache(String region)
          Flushes the cache for the input region
 void flushRegionCaches()
          Flushes all the caches for all the regions
 String generateActiveConfigDeclaration()
          Returns the currently active cache configuration
 String generateActiveConfigDeclaration(String region)
          Returns the currently active cache configuration for the supplied region
 float getAverageGetTimeMillis(String region)
          Return average time taken in milliseconds for a get operation for the input cache name
 long getCacheHitCount()
          Returns hit count for all the caches
 double getCacheHitRate()
          Returns hit rate for all the caches
 long getCacheHitSample()
          Returns hit count sample for all the caches
 long getCacheMissCount()
          Returns miss count for all the caches
 double getCacheMissRate()
          Returns miss rate for all the caches
 long getCacheMissSample()
          Returns miss count sample for all the caches
 long getCachePutCount()
          Returns put count for all the caches
 double getCachePutRate()
          Returns put rate for all the caches
 long getCachePutSample()
          Returns put count sample for all the caches
 TabularData getCacheRegionStats()
          Returns TabularData of cache region stats
 long getCloseStatementCount()
          Returns the count of close statements
 TabularData getCollectionStats()
          Returns TabularData of collection stats
 long getConnectCount()
          Return connect counts
 TabularData getEntityStats()
          Returns TabularData of entity stats
 long getFlushCount()
          Returns flush count
 long getMaxGetTimeMillis()
          Return maximum time taken in milliseconds for a get operation
 long getMaxGetTimeMillis(String cacheName)
          Return maximum time taken in milliseconds for a get operation for the input cache name
 long getMinGetTimeMillis()
          Return minimum time taken for a get operation in the cache in milliseconds
 long getMinGetTimeMillis(String cacheName)
          Return minimum time taken in milliseconds for a get operation for the input cache name
 MBeanNotificationInfo[] getNotificationInfo()
           
 int getNumberOfElementsInMemory(String region)
          Returns number of elements in-memory in the cache for the input region
 int getNumberOfElementsOffHeap(String region)
          Returns number of elements off-heap in the cache for the input region
 int getNumberOfElementsOnDisk(String region)
          Returns number of elements on-disk in the cache for the input region
 long getOptimisticFailureCount()
          Returns Optimistic failure count
 String getOriginalConfigDeclaration()
          Get the original cache configuration
 String getOriginalConfigDeclaration(String region)
          Returns the original cache configuration for the supplied region
 long getPrepareStatementCount()
          Returns prepare statement count
 long getQueryExecutionCount()
          Returns the query execution count.
 double getQueryExecutionRate()
          Returns rate of HQL query executed in the DB
 long getQueryExecutionSample()
          Returns last count sample of HQL's getting executed in the DB.
 TabularData getQueryStats()
          Returns TabularData of query stats
 Map<String,Map<String,Object>> getRegionCacheAttributes()
          Returns a map containing mapping of all cache region names to their attributes
 Map<String,Object> getRegionCacheAttributes(String regionName)
          Returns a map containing attributes of the cache for the input cache region name
 int getRegionCacheMaxTTISeconds(String region)
          Returns the time to idle for the input cache region
 int getRegionCacheMaxTTLSeconds(String region)
          Returns the time to live for the input cache region
 int getRegionCacheOrphanEvictionPeriod(String region)
          Returns the orphan eviction period for the input cache region.
 Map<String,int[]> getRegionCacheSamples()
          Returns a map containing mapping between cache names and an array containing hit, miss and put count samples
 int getRegionCacheTargetMaxInMemoryCount(String region)
          Returns the maxElementsInMemory of the input cache region
 int getRegionCacheTargetMaxTotalCount(String region)
          Returns the maxElementsOnDisk of the input cache region
 long getSessionCloseCount()
          Returns session close count
 long getSessionOpenCount()
          Returns session open count
 long getSuccessfulTransactionCount()
          Returns successful transaction count
 String[] getTerracottaHibernateCacheRegionNames()
          Returns the region names which are clustered with terracotta
 long getTransactionCount()
          Returns transaction count
 boolean isHibernateStatisticsSupported()
          Returns true if hibernate statistics is supported.
 boolean isRegionCacheEnabled(String region)
          Returns true if cache is enabled for the input region
 boolean isRegionCacheLoggingEnabled(String region)
          Returns true if logging is enabled for the input cache region
 boolean isRegionCacheOrphanEvictionEnabled(String region)
          Returns true if orphan eviction is enabled for the region otherwise false
 boolean isRegionCachesEnabled()
          Returns true if all the cache regions are enabled.
 boolean isStatisticsEnabled()
          Returns true if statistics collection is enabled otherwise false
 boolean isTerracottaHibernateCache(String region)
          Returns true if the input region is clustered with terracotta
 void setRegionCacheEnabled(String region, boolean enabled)
          Enables/disables a particular region
 void setRegionCacheLoggingEnabled(String region, boolean loggingEnabled)
          Enable/Disable logging for the input cache region
 void setRegionCacheMaxTTISeconds(String region, int maxTTISeconds)
          Sets the time to idle for the input cache region
 void setRegionCacheMaxTTLSeconds(String region, int maxTTLSeconds)
          Sets the time to live for the input cache region
 void setRegionCachesEnabled(boolean enabled)
          Enable/disable all the cache regions.
 void setRegionCacheTargetMaxInMemoryCount(String region, int targetMaxInMemoryCount)
          Sets the maxElementsInMemory of the input cache region
 void setRegionCacheTargetMaxTotalCount(String region, int targetMaxTotalCount)
          Sets the maxElementsOnDisk of the input cache region
 void setStatisticsEnabled(boolean flag)
          Enable/Disable statistics collection
 
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
 
Methods inherited from interface javax.management.NotificationEmitter
removeNotificationListener
 
Methods inherited from interface javax.management.NotificationBroadcaster
addNotificationListener, removeNotificationListener
 

Constructor Detail

EhcacheHibernate

public EhcacheHibernate(CacheManager manager)
                 throws NotCompliantMBeanException
Constructor accepting the backing CacheManager

Parameters:
manager - the backing CacheManager
Throws:
NotCompliantMBeanException
Method Detail

enableHibernateStatistics

public void enableHibernateStatistics(SessionFactory sessionFactory)
Enable hibernate statistics with the input session factory


isHibernateStatisticsSupported

public boolean isHibernateStatisticsSupported()
Returns true if hibernate statistics is supported.

It depends on whether the property hibernate.session_factory_name has been specified in the hibernate configuration for the hibernate statistics to be enabled

Specified by:
isHibernateStatisticsSupported in interface EhcacheHibernateMBean
Returns:
true if hibernate statistics is supported

setStatisticsEnabled

public void setStatisticsEnabled(boolean flag)
Enable/Disable statistics collection

Specified by:
setStatisticsEnabled in interface HibernateStats

isStatisticsEnabled

public boolean isStatisticsEnabled()
Returns true if statistics collection is enabled otherwise false

Specified by:
isStatisticsEnabled in interface HibernateStats
Returns:
Returns true if statistics collection is enabled otherwise false

clearStats

public void clearStats()
Clears statistics, resets all counters to zero

Specified by:
clearStats in interface HibernateStats

disableStats

public void disableStats()
Disables statistics collection

Specified by:
disableStats in interface HibernateStats

enableStats

public void enableStats()
Enables statistics collection

Specified by:
enableStats in interface HibernateStats

flushRegionCache

public void flushRegionCache(String region)
Flushes the cache for the input region

Specified by:
flushRegionCache in interface EhcacheStats

flushRegionCaches

public void flushRegionCaches()
Flushes all the caches for all the regions

Specified by:
flushRegionCaches in interface EhcacheStats

generateActiveConfigDeclaration

public String generateActiveConfigDeclaration()
Returns the currently active cache configuration

Specified by:
generateActiveConfigDeclaration in interface EhcacheStats
Returns:
the currently active cache configuration

generateActiveConfigDeclaration

public String generateActiveConfigDeclaration(String region)
Returns the currently active cache configuration for the supplied region

Specified by:
generateActiveConfigDeclaration in interface EhcacheStats
Returns:
Returns the currently active cache configuration for the supplied region

getCacheHitCount

public long getCacheHitCount()
Returns hit count for all the caches

Specified by:
getCacheHitCount in interface EhcacheStats
Returns:
Returns hit count for all the caches

getCacheHitRate

public double getCacheHitRate()
Returns hit rate for all the caches

Specified by:
getCacheHitRate in interface EhcacheStats
Returns:
Returns hit rate for all the caches

getCacheHitSample

public long getCacheHitSample()
Returns hit count sample for all the caches

Specified by:
getCacheHitSample in interface EhcacheStats
Returns:
Returns hit count sample for all the caches

getCacheMissCount

public long getCacheMissCount()
Returns miss count for all the caches

Specified by:
getCacheMissCount in interface EhcacheStats
Returns:
Returns miss count for all the caches

getCacheMissRate

public double getCacheMissRate()
Returns miss rate for all the caches

Specified by:
getCacheMissRate in interface EhcacheStats
Returns:
Returns miss rate for all the caches

getCacheMissSample

public long getCacheMissSample()
Returns miss count sample for all the caches

Specified by:
getCacheMissSample in interface EhcacheStats
Returns:
Returns miss count sample for all the caches

getCachePutCount

public long getCachePutCount()
Returns put count for all the caches

Specified by:
getCachePutCount in interface EhcacheStats
Returns:
Returns put count for all the caches

getCachePutRate

public double getCachePutRate()
Returns put rate for all the caches

Specified by:
getCachePutRate in interface EhcacheStats
Returns:
Returns put rate for all the caches

getCachePutSample

public long getCachePutSample()
Returns put count sample for all the caches

Specified by:
getCachePutSample in interface EhcacheStats
Returns:
Returns put count sample for all the caches

getCacheRegionStats

public TabularData getCacheRegionStats()
Returns TabularData of cache region stats

Specified by:
getCacheRegionStats in interface HibernateStats
Returns:
Returns TabularData of cache region stats

getCloseStatementCount

public long getCloseStatementCount()
Returns the count of close statements

Specified by:
getCloseStatementCount in interface HibernateStats
Returns:
Returns the count of close statementss

getCollectionStats

public TabularData getCollectionStats()
Returns TabularData of collection stats

Specified by:
getCollectionStats in interface HibernateStats
Returns:
Returns TabularData of collection stats

getConnectCount

public long getConnectCount()
Return connect counts

Specified by:
getConnectCount in interface HibernateStats
Returns:
Return connect counts

getEntityStats

public TabularData getEntityStats()
Returns TabularData of entity stats

Specified by:
getEntityStats in interface HibernateStats
Returns:
Returns TabularData of entity stats

getFlushCount

public long getFlushCount()
Returns flush count

Specified by:
getFlushCount in interface HibernateStats
Returns:
Returns flush count

getOptimisticFailureCount

public long getOptimisticFailureCount()
Returns Optimistic failure count

Specified by:
getOptimisticFailureCount in interface HibernateStats
Returns:
Returns Optimistic failure count

getOriginalConfigDeclaration

public String getOriginalConfigDeclaration()
Get the original cache configuration

Specified by:
getOriginalConfigDeclaration in interface EhcacheStats
Returns:
the original cache configuration

getOriginalConfigDeclaration

public String getOriginalConfigDeclaration(String region)
Returns the original cache configuration for the supplied region

Specified by:
getOriginalConfigDeclaration in interface EhcacheStats
Parameters:
region - for which the configuration is required
Returns:
the original cache configuration for the supplied region

getPrepareStatementCount

public long getPrepareStatementCount()
Returns prepare statement count

Specified by:
getPrepareStatementCount in interface HibernateStats
Returns:
Returns prepare statement count

getQueryExecutionCount

public long getQueryExecutionCount()
Returns the query execution count. This includes only HQL's

Specified by:
getQueryExecutionCount in interface HibernateStats
Returns:
Returns the query execution count. This includes only HQL's

getQueryExecutionRate

public double getQueryExecutionRate()
Returns rate of HQL query executed in the DB

Specified by:
getQueryExecutionRate in interface HibernateStats
Returns:
Returns rate of HQL query executed in the DB

getQueryExecutionSample

public long getQueryExecutionSample()
Returns last count sample of HQL's getting executed in the DB.

Specified by:
getQueryExecutionSample in interface HibernateStats
Returns:
Returns last count sample of HQL's getting executed in the DB.

getQueryStats

public TabularData getQueryStats()
Returns TabularData of query stats

Specified by:
getQueryStats in interface HibernateStats
Returns:
Returns TabularData of query stats

getRegionCacheAttributes

public Map<String,Map<String,Object>> getRegionCacheAttributes()
Returns a map containing mapping of all cache region names to their attributes

Specified by:
getRegionCacheAttributes in interface EhcacheStats
Returns:
Returns a map containing mapping of all cache region names to their attributes

getRegionCacheAttributes

public Map<String,Object> getRegionCacheAttributes(String regionName)
Returns a map containing attributes of the cache for the input cache region name

Specified by:
getRegionCacheAttributes in interface EhcacheStats
Returns:
Returns a map containing attributes of the cache for the input cache region name

getRegionCacheMaxTTISeconds

public int getRegionCacheMaxTTISeconds(String region)
Returns the time to idle for the input cache region

Specified by:
getRegionCacheMaxTTISeconds in interface EhcacheStats
Returns:
Returns the time to live for the input cache region

getRegionCacheMaxTTLSeconds

public int getRegionCacheMaxTTLSeconds(String region)
Returns the time to live for the input cache region

Specified by:
getRegionCacheMaxTTLSeconds in interface EhcacheStats
Returns:
Returns the time to live for the input cache region

getRegionCacheOrphanEvictionPeriod

public int getRegionCacheOrphanEvictionPeriod(String region)
Returns the orphan eviction period for the input cache region.

Specified by:
getRegionCacheOrphanEvictionPeriod in interface EhcacheStats
Returns:
Returns the orphan eviction period for the input cache region.

getRegionCacheSamples

public Map<String,int[]> getRegionCacheSamples()
Returns a map containing mapping between cache names and an array containing hit, miss and put count samples

Specified by:
getRegionCacheSamples in interface EhcacheStats
Returns:
Returns a map containing mapping between cache names and an array containing hit, miss and put count samples

getRegionCacheTargetMaxInMemoryCount

public int getRegionCacheTargetMaxInMemoryCount(String region)
Returns the maxElementsInMemory of the input cache region

Specified by:
getRegionCacheTargetMaxInMemoryCount in interface EhcacheStats
Returns:
Returns the maxElementsInMemory of the input cache region

getRegionCacheTargetMaxTotalCount

public int getRegionCacheTargetMaxTotalCount(String region)
Returns the maxElementsOnDisk of the input cache region

Specified by:
getRegionCacheTargetMaxTotalCount in interface EhcacheStats
Returns:
Returns the maxElementsOnDisk of the input cache region

getSessionCloseCount

public long getSessionCloseCount()
Returns session close count

Specified by:
getSessionCloseCount in interface HibernateStats
Returns:
Returns session close count

getSessionOpenCount

public long getSessionOpenCount()
Returns session open count

Specified by:
getSessionOpenCount in interface HibernateStats
Returns:
Returns session open count

getSuccessfulTransactionCount

public long getSuccessfulTransactionCount()
Returns successful transaction count

Specified by:
getSuccessfulTransactionCount in interface HibernateStats
Returns:
Returns successful transaction count

getTerracottaHibernateCacheRegionNames

public String[] getTerracottaHibernateCacheRegionNames()
Returns the region names which are clustered with terracotta

Specified by:
getTerracottaHibernateCacheRegionNames in interface EhcacheStats
Returns:
Returns the region names which are clustered with terracotta

getTransactionCount

public long getTransactionCount()
Returns transaction count

Specified by:
getTransactionCount in interface HibernateStats
Returns:
Returns transaction count

isRegionCacheEnabled

public boolean isRegionCacheEnabled(String region)
Returns true if cache is enabled for the input region

Specified by:
isRegionCacheEnabled in interface EhcacheStats
Returns:
Returns true if cache is enabled for the input region

setRegionCachesEnabled

public void setRegionCachesEnabled(boolean enabled)
Enable/disable all the cache regions.

Specified by:
setRegionCachesEnabled in interface EhcacheStats

setRegionCacheEnabled

public void setRegionCacheEnabled(String region,
                                  boolean enabled)
Enables/disables a particular region

Specified by:
setRegionCacheEnabled in interface EhcacheStats

isRegionCacheLoggingEnabled

public boolean isRegionCacheLoggingEnabled(String region)
Returns true if logging is enabled for the input cache region

Specified by:
isRegionCacheLoggingEnabled in interface EhcacheStats
Returns:
Returns true if logging is enabled for the input cache region

isRegionCacheOrphanEvictionEnabled

public boolean isRegionCacheOrphanEvictionEnabled(String region)
Returns true if orphan eviction is enabled for the region otherwise false

Specified by:
isRegionCacheOrphanEvictionEnabled in interface EhcacheStats
Returns:
Returns true if orphan eviction is enabled for the region otherwise false

isRegionCachesEnabled

public boolean isRegionCachesEnabled()
Returns true if all the cache regions are enabled. If even one cache is disabled, it will return false

Specified by:
isRegionCachesEnabled in interface EhcacheStats
Returns:
Returns true if all the cache regions are enabled. If even one cache is disabled, it will return false

isTerracottaHibernateCache

public boolean isTerracottaHibernateCache(String region)
Returns true if the input region is clustered with terracotta

Specified by:
isTerracottaHibernateCache in interface EhcacheStats
Returns:
Returns true if the input region is clustered with terracotta

setRegionCacheLoggingEnabled

public void setRegionCacheLoggingEnabled(String region,
                                         boolean loggingEnabled)
Enable/Disable logging for the input cache region

Specified by:
setRegionCacheLoggingEnabled in interface EhcacheStats

setRegionCacheMaxTTISeconds

public void setRegionCacheMaxTTISeconds(String region,
                                        int maxTTISeconds)
Sets the time to idle for the input cache region

Specified by:
setRegionCacheMaxTTISeconds in interface EhcacheStats
maxTTISeconds - Returns the time to idle for the input cache region

setRegionCacheMaxTTLSeconds

public void setRegionCacheMaxTTLSeconds(String region,
                                        int maxTTLSeconds)
Sets the time to live for the input cache region

Specified by:
setRegionCacheMaxTTLSeconds in interface EhcacheStats

setRegionCacheTargetMaxInMemoryCount

public void setRegionCacheTargetMaxInMemoryCount(String region,
                                                 int targetMaxInMemoryCount)
Sets the maxElementsInMemory of the input cache region

Specified by:
setRegionCacheTargetMaxInMemoryCount in interface EhcacheStats

setRegionCacheTargetMaxTotalCount

public void setRegionCacheTargetMaxTotalCount(String region,
                                              int targetMaxTotalCount)
Sets the maxElementsOnDisk of the input cache region

Specified by:
setRegionCacheTargetMaxTotalCount in interface EhcacheStats

getNumberOfElementsInMemory

public int getNumberOfElementsInMemory(String region)
Returns number of elements in-memory in the cache for the input region

Specified by:
getNumberOfElementsInMemory in interface EhcacheStats
Returns:
Returns number of elements in-memory in the cache for the input region
See Also:
EhcacheStats.getNumberOfElementsInMemory(java.lang.String)

getNumberOfElementsOffHeap

public int getNumberOfElementsOffHeap(String region)
Returns number of elements off-heap in the cache for the input region

Specified by:
getNumberOfElementsOffHeap in interface EhcacheStats
Returns:
Returns number of elements off-heap in the cache for the input region
See Also:
EhcacheStats.getNumberOfElementsInMemory(java.lang.String)

getNumberOfElementsOnDisk

public int getNumberOfElementsOnDisk(String region)
Returns number of elements on-disk in the cache for the input region

Specified by:
getNumberOfElementsOnDisk in interface EhcacheStats
Returns:
Returns number of elements on-disk in the cache for the input region
See Also:
EhcacheStats.getNumberOfElementsOnDisk(java.lang.String)

getMaxGetTimeMillis

public long getMaxGetTimeMillis()
Return maximum time taken in milliseconds for a get operation

Specified by:
getMaxGetTimeMillis in interface EhcacheStats
Returns:
Return maximum time taken in milliseconds for a get operation
See Also:
EhcacheStats.getMaxGetTimeMillis()

getMaxGetTimeMillis

public long getMaxGetTimeMillis(String cacheName)
Return maximum time taken in milliseconds for a get operation for the input cache name

Specified by:
getMaxGetTimeMillis in interface EhcacheStats
Returns:
Return maximum time taken in milliseconds for a get operation for the input cache name
See Also:
EhcacheStats.getMaxGetTimeMillis(java.lang.String)

getMinGetTimeMillis

public long getMinGetTimeMillis()
Return minimum time taken for a get operation in the cache in milliseconds

Specified by:
getMinGetTimeMillis in interface EhcacheStats
Returns:
minimum time taken for a get operation in the cache in milliseconds
See Also:
EhcacheStats.getMinGetTimeMillis()

getMinGetTimeMillis

public long getMinGetTimeMillis(String cacheName)
Return minimum time taken in milliseconds for a get operation for the input cache name

Specified by:
getMinGetTimeMillis in interface EhcacheStats
Returns:
Return minimum time taken in milliseconds for a get operation for the input cache name
See Also:
EhcacheStats.getMinGetTimeMillis(java.lang.String)

getAverageGetTimeMillis

public float getAverageGetTimeMillis(String region)
Return average time taken in milliseconds for a get operation for the input cache name

Specified by:
getAverageGetTimeMillis in interface EhcacheStats
Returns:
Return average time taken in milliseconds for a get operation for the input cache name
See Also:
EhcacheStats.getAverageGetTimeMillis(java.lang.String)

doDispose

protected void doDispose()
Dispose callback of subclasses

Specified by:
doDispose in class BaseEmitterBean

getNotificationInfo

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

ehcache

Copyright 2001-2016, Terracotta, Inc.