diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/internal/regions/EhcacheTransactionalDataRegion.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/internal/regions/EhcacheTransactionalDataRegion.java index d46513cbe6..fdd4c1f375 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/internal/regions/EhcacheTransactionalDataRegion.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/internal/regions/EhcacheTransactionalDataRegion.java @@ -217,7 +217,7 @@ public class EhcacheTransactionalDataRegion extends EhcacheDataRegion implements * * @throws CacheException Indicates a problem accessing the cache */ - public final void writeLock(Object key) { + public final void writeLock(Object key) throws CacheException { try { lockProvider.getSyncForKey( key ).lock( LockType.WRITE ); } @@ -239,7 +239,7 @@ public class EhcacheTransactionalDataRegion extends EhcacheDataRegion implements * * @throws CacheException Indicates a problem accessing the cache */ - public final void writeUnlock(Object key) { + public final void writeUnlock(Object key) throws CacheException { try { lockProvider.getSyncForKey( key ).unlock( LockType.WRITE ); } @@ -261,7 +261,7 @@ public class EhcacheTransactionalDataRegion extends EhcacheDataRegion implements * * @throws CacheException Indicates a problem accessing the cache */ - public final void readLock(Object key) { + public final void readLock(Object key) throws CacheException { try { lockProvider.getSyncForKey( key ).lock( LockType.WRITE ); } @@ -283,7 +283,7 @@ public class EhcacheTransactionalDataRegion extends EhcacheDataRegion implements * * @throws CacheException Indicates a problem accessing the cache */ - public final void readUnlock(Object key) { + public final void readUnlock(Object key) throws CacheException { try { lockProvider.getSyncForKey( key ).unlock( LockType.WRITE ); } diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/AbstractEmitterBean.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/AbstractEmitterBean.java index 5d3f3abc31..d3e4245abe 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/AbstractEmitterBean.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/AbstractEmitterBean.java @@ -138,6 +138,9 @@ public abstract class AbstractEmitterBean extends StandardMBean implements Notif notificationListeners.clear(); } + /** + * {@inheritDoc} + */ @Override public abstract MBeanNotificationInfo[] getNotificationInfo(); diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/CacheRegionUtils.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/CacheRegionUtils.java index 267486a6a2..8ce621b7e5 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/CacheRegionUtils.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/CacheRegionUtils.java @@ -95,7 +95,7 @@ public abstract class CacheRegionUtils { } boolean truncate = true; for ( int i = 0; i < comps.length; i++ ) { - String comp = comps[i]; + final String comp = comps[i]; final char c = comp.charAt( 0 ); if ( truncate && Character.isUpperCase( c ) ) { truncate = false; diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheHibernate.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheHibernate.java index a978ff6140..f03788cb75 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheHibernate.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheHibernate.java @@ -63,7 +63,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe * * @param manager the backing {@link CacheManager} * - * @throws NotCompliantMBeanException + * @throws NotCompliantMBeanException if bean doesn't comply */ public EhcacheHibernate(CacheManager manager) throws NotCompliantMBeanException { super( EhcacheHibernateMBean.class ); @@ -72,12 +72,13 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * Enable hibernate statistics with the input session factory + * @param sessionFactory the session factory to enable stats for */ public void enableHibernateStatistics(SessionFactory sessionFactory) { try { hibernateStats = new HibernateStatsImpl( sessionFactory ); } - catch (Exception e) { + catch ( Exception e ) { throw new RuntimeException( e ); } } @@ -85,6 +86,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public boolean isHibernateStatisticsSupported() { return hibernateStats instanceof HibernateStatsImpl; } @@ -92,6 +94,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public void setStatisticsEnabled(boolean flag) { if ( flag ) { ehcacheStats.enableStats(); @@ -108,6 +111,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public boolean isStatisticsEnabled() { return statsEnabled.get(); } @@ -115,6 +119,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public void clearStats() { ehcacheStats.clearStats(); hibernateStats.clearStats(); @@ -123,6 +128,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public void disableStats() { setStatisticsEnabled( false ); } @@ -130,6 +136,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public void enableStats() { setStatisticsEnabled( true ); } @@ -137,6 +144,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public void flushRegionCache(String region) { ehcacheStats.flushRegionCache( region ); sendNotification( HibernateStats.CACHE_REGION_FLUSHED, region ); @@ -145,6 +153,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public void flushRegionCaches() { ehcacheStats.flushRegionCaches(); sendNotification( HibernateStats.CACHE_FLUSHED ); @@ -153,6 +162,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public String generateActiveConfigDeclaration() { return ehcacheStats.generateActiveConfigDeclaration(); } @@ -160,6 +170,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public String generateActiveConfigDeclaration(String region) { return ehcacheStats.generateActiveConfigDeclaration( region ); } @@ -167,6 +178,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public long getCacheHitCount() { return ehcacheStats.getCacheHitCount(); } @@ -174,6 +186,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public double getCacheHitRate() { return ehcacheStats.getCacheHitRate(); } @@ -181,6 +194,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public long getCacheHitSample() { return ehcacheStats.getCacheHitSample(); } @@ -188,6 +202,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public long getCacheMissCount() { return ehcacheStats.getCacheMissCount(); } @@ -195,6 +210,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public double getCacheMissRate() { return ehcacheStats.getCacheMissRate(); } @@ -202,6 +218,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public long getCacheMissSample() { return ehcacheStats.getCacheMissSample(); } @@ -209,6 +226,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public long getCachePutCount() { return ehcacheStats.getCachePutCount(); } @@ -216,6 +234,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public double getCachePutRate() { return ehcacheStats.getCachePutRate(); } @@ -223,6 +242,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public long getCachePutSample() { return ehcacheStats.getCachePutSample(); } @@ -230,6 +250,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public TabularData getCacheRegionStats() { return hibernateStats.getCacheRegionStats(); } @@ -237,6 +258,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public long getCloseStatementCount() { return hibernateStats.getCloseStatementCount(); } @@ -244,6 +266,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public TabularData getCollectionStats() { return hibernateStats.getCollectionStats(); } @@ -251,6 +274,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public long getConnectCount() { return hibernateStats.getConnectCount(); } @@ -258,6 +282,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public TabularData getEntityStats() { return hibernateStats.getEntityStats(); } @@ -265,6 +290,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public long getFlushCount() { return hibernateStats.getFlushCount(); } @@ -272,6 +298,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public long getOptimisticFailureCount() { return hibernateStats.getOptimisticFailureCount(); } @@ -279,6 +306,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public String getOriginalConfigDeclaration() { return ehcacheStats.getOriginalConfigDeclaration(); } @@ -286,6 +314,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public String getOriginalConfigDeclaration(String region) { return ehcacheStats.getOriginalConfigDeclaration( region ); } @@ -293,6 +322,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public long getPrepareStatementCount() { return hibernateStats.getPrepareStatementCount(); } @@ -300,6 +330,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public long getQueryExecutionCount() { return hibernateStats.getQueryExecutionCount(); } @@ -307,6 +338,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public double getQueryExecutionRate() { return hibernateStats.getQueryExecutionRate(); } @@ -314,6 +346,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public long getQueryExecutionSample() { return hibernateStats.getQueryExecutionSample(); } @@ -321,6 +354,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public TabularData getQueryStats() { return hibernateStats.getQueryStats(); } @@ -328,6 +362,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public Map> getRegionCacheAttributes() { return ehcacheStats.getRegionCacheAttributes(); } @@ -335,6 +370,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public Map getRegionCacheAttributes(String regionName) { return ehcacheStats.getRegionCacheAttributes( regionName ); } @@ -342,6 +378,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public int getRegionCacheMaxTTISeconds(String region) { return ehcacheStats.getRegionCacheMaxTTISeconds( region ); } @@ -349,6 +386,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public int getRegionCacheMaxTTLSeconds(String region) { return ehcacheStats.getRegionCacheMaxTTLSeconds( region ); } @@ -356,6 +394,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public int getRegionCacheOrphanEvictionPeriod(String region) { return ehcacheStats.getRegionCacheOrphanEvictionPeriod( region ); } @@ -363,6 +402,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public Map getRegionCacheSamples() { return ehcacheStats.getRegionCacheSamples(); } @@ -370,6 +410,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public int getRegionCacheTargetMaxInMemoryCount(String region) { return ehcacheStats.getRegionCacheTargetMaxInMemoryCount( region ); } @@ -377,6 +418,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public int getRegionCacheTargetMaxTotalCount(String region) { return ehcacheStats.getRegionCacheTargetMaxTotalCount( region ); } @@ -384,6 +426,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public long getSessionCloseCount() { return hibernateStats.getSessionCloseCount(); } @@ -391,6 +434,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public long getSessionOpenCount() { return hibernateStats.getSessionOpenCount(); } @@ -398,6 +442,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public long getSuccessfulTransactionCount() { return hibernateStats.getSuccessfulTransactionCount(); } @@ -405,6 +450,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public String[] getTerracottaHibernateCacheRegionNames() { return ehcacheStats.getTerracottaHibernateCacheRegionNames(); } @@ -412,6 +458,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public long getTransactionCount() { return hibernateStats.getTransactionCount(); } @@ -419,6 +466,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public boolean isRegionCacheEnabled(String region) { return ehcacheStats.isRegionCacheEnabled( region ); } @@ -426,6 +474,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public void setRegionCachesEnabled(boolean enabled) { ehcacheStats.setRegionCachesEnabled( enabled ); sendNotification( HibernateStats.CACHE_ENABLED, enabled ); @@ -434,6 +483,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public void setRegionCacheEnabled(String region, boolean enabled) { ehcacheStats.setRegionCacheEnabled( region, enabled ); sendNotification( HibernateStats.CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region ); @@ -442,6 +492,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public boolean isRegionCacheLoggingEnabled(String region) { return ehcacheStats.isRegionCacheLoggingEnabled( region ); } @@ -449,6 +500,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public boolean isRegionCacheOrphanEvictionEnabled(String region) { return ehcacheStats.isRegionCacheOrphanEvictionEnabled( region ); } @@ -456,6 +508,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public boolean isRegionCachesEnabled() { return ehcacheStats.isRegionCachesEnabled(); } @@ -463,6 +516,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public boolean isTerracottaHibernateCache(String region) { return ehcacheStats.isTerracottaHibernateCache( region ); } @@ -470,6 +524,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public void setRegionCacheLoggingEnabled(String region, boolean loggingEnabled) { ehcacheStats.setRegionCacheLoggingEnabled( region, loggingEnabled ); sendNotification( HibernateStats.CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region ); @@ -478,6 +533,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public void setRegionCacheMaxTTISeconds(String region, int maxTTISeconds) { ehcacheStats.setRegionCacheMaxTTISeconds( region, maxTTISeconds ); sendNotification( HibernateStats.CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region ); @@ -486,6 +542,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public void setRegionCacheMaxTTLSeconds(String region, int maxTTLSeconds) { ehcacheStats.setRegionCacheMaxTTLSeconds( region, maxTTLSeconds ); sendNotification( HibernateStats.CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region ); @@ -494,6 +551,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public void setRegionCacheTargetMaxInMemoryCount(String region, int targetMaxInMemoryCount) { ehcacheStats.setRegionCacheTargetMaxInMemoryCount( region, targetMaxInMemoryCount ); sendNotification( HibernateStats.CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region ); @@ -502,6 +560,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe /** * {@inheritDoc} */ + @Override public void setRegionCacheTargetMaxTotalCount(String region, int targetMaxTotalCount) { ehcacheStats.setRegionCacheTargetMaxTotalCount( region, targetMaxTotalCount ); sendNotification( HibernateStats.CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region ); @@ -512,6 +571,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe * * @see EhcacheStats#getNumberOfElementsInMemory(java.lang.String) */ + @Override public int getNumberOfElementsInMemory(String region) { return ehcacheStats.getNumberOfElementsInMemory( region ); } @@ -521,6 +581,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe * * @see EhcacheStats#getNumberOfElementsInMemory(java.lang.String) */ + @Override public int getNumberOfElementsOffHeap(String region) { return ehcacheStats.getNumberOfElementsOffHeap( region ); } @@ -530,6 +591,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe * * @see EhcacheStats#getNumberOfElementsOnDisk(java.lang.String) */ + @Override public int getNumberOfElementsOnDisk(String region) { return ehcacheStats.getNumberOfElementsOnDisk( region ); } @@ -539,6 +601,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe * * @see EhcacheStats#getMaxGetTimeMillis() */ + @Override public long getMaxGetTimeMillis() { return ehcacheStats.getMaxGetTimeMillis(); } @@ -548,6 +611,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe * * @see EhcacheStats#getMaxGetTimeMillis(java.lang.String) */ + @Override public long getMaxGetTimeMillis(String cacheName) { return ehcacheStats.getMaxGetTimeMillis( cacheName ); } @@ -557,6 +621,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe * * @see EhcacheStats#getMinGetTimeMillis() */ + @Override public long getMinGetTimeMillis() { return ehcacheStats.getMinGetTimeMillis(); } @@ -566,6 +631,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe * * @see EhcacheStats#getMinGetTimeMillis(java.lang.String) */ + @Override public long getMinGetTimeMillis(String cacheName) { return ehcacheStats.getMinGetTimeMillis( cacheName ); } @@ -575,6 +641,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe * * @see EhcacheStats#getAverageGetTimeMillis(java.lang.String) */ + @Override public float getAverageGetTimeMillis(String region) { return ehcacheStats.getAverageGetTimeMillis( region ); } @@ -588,10 +655,12 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe } /** + * {@inheritDoc} + * * @see AbstractEmitterBean#getNotificationInfo() */ @Override public MBeanNotificationInfo[] getNotificationInfo() { - return new MBeanNotificationInfo[] {NOTIFICATION_INFO}; + return new MBeanNotificationInfo[] { NOTIFICATION_INFO }; } } diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheHibernateMBeanRegistration.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheHibernateMBeanRegistration.java index 2fdeba973d..6f3a646d62 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheHibernateMBeanRegistration.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheHibernateMBeanRegistration.java @@ -44,17 +44,17 @@ public interface EhcacheHibernateMBeanRegistration { * MBeans will be registered based on the input session factory name. If the input name is null or blank, the name of the cache-manager * is used * - * @param manager - * @param properties + * @param manager the {@link CacheManager} to register the MBean for + * @param properties properties to used to create the associated {@link SessionFactory} * - * @throws Exception + * @throws Exception reflecting the source of the problem registering the MBean */ public void registerMBeanForCacheManager(CacheManager manager, Properties properties) throws Exception; /** * Enable hibernate statistics in the mbean. * - * @param sessionFactory + * @param sessionFactory the {@link SessionFactory} to enable stats for */ public void enableHibernateStatisticsSupport(SessionFactory sessionFactory); diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheHibernateMBeanRegistrationImpl.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheHibernateMBeanRegistrationImpl.java index 738bca7e05..38c0e1409a 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheHibernateMBeanRegistrationImpl.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheHibernateMBeanRegistrationImpl.java @@ -65,9 +65,10 @@ public class EhcacheHibernateMBeanRegistrationImpl /** * {@inheritDoc} */ + @Override public synchronized void registerMBeanForCacheManager(final CacheManager manager, final Properties properties) throws Exception { - String sessionFactoryName = properties.getProperty( Environment.SESSION_FACTORY_NAME ); + final String sessionFactoryName = properties.getProperty( Environment.SESSION_FACTORY_NAME ); String name = null; if ( sessionFactoryName == null ) { name = manager.getName(); @@ -91,7 +92,7 @@ public class EhcacheHibernateMBeanRegistrationImpl } try { // register the CacheManager MBean - MBeanServer mBeanServer = getMBeanServer(); + final MBeanServer mBeanServer = getMBeanServer(); cacheManagerObjectName = EhcacheHibernateMbeanNames.getCacheManagerObjectName( cacheManagerClusterUUID, registeredCacheManagerName @@ -123,6 +124,7 @@ public class EhcacheHibernateMBeanRegistrationImpl /** * {@inheritDoc} */ + @Override public void enableHibernateStatisticsSupport(SessionFactory sessionFactory) { ehcacheHibernate.enableHibernateStatistics( sessionFactory ); } @@ -130,6 +132,7 @@ public class EhcacheHibernateMBeanRegistrationImpl /** * {@inheritDoc} */ + @Override public synchronized void dispose() throws CacheException { if ( status == Status.STATUS_SHUTDOWN ) { return; @@ -152,27 +155,39 @@ public class EhcacheHibernateMBeanRegistrationImpl /** * {@inheritDoc} */ + @Override public synchronized Status getStatus() { return status; } /** + * + * {@inheritDoc} + * * No-op in this case */ + @Override public void init() throws CacheException { // no-op } /** + * + * {@inheritDoc} + * * No-op in this case */ + @Override public void notifyCacheAdded(String cacheName) { // no-op } /** + * {@inheritDoc} + * * No-op in this case */ + @Override public void notifyCacheRemoved(String cacheName) { // no-op } diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheHibernateMbeanNames.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheHibernateMbeanNames.java index 46fd1c2176..02362916aa 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheHibernateMbeanNames.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheHibernateMbeanNames.java @@ -49,7 +49,7 @@ public abstract class EhcacheHibernateMbeanNames { /** * Filter out invalid ObjectName characters from s. * - * @param s + * @param s the name to be filtered out * * @return A valid JMX ObjectName attribute value. */ @@ -60,15 +60,16 @@ public abstract class EhcacheHibernateMbeanNames { /** * Returns an ObjectName for the passed name * - * @param name + * @param cacheManagerClusterUUID the UUID of the cacheManager within the cluster + * @param name the name to use, which should be made "mbean safe" * * @return An {@link javax.management.ObjectName} using the input name of cache manager * - * @throws javax.management.MalformedObjectNameException + * @throws javax.management.MalformedObjectNameException The name derived from the params does not correspond to a valid ObjectName */ public static ObjectName getCacheManagerObjectName(String cacheManagerClusterUUID, String name) throws MalformedObjectNameException { - ObjectName objectName = new ObjectName( + final ObjectName objectName = new ObjectName( GROUP_ID + ":type=" + EHCACHE_HIBERNATE_TYPE + ",name=" + mbeanSafe( name ) + getBeanNameSuffix( cacheManagerClusterUUID ) ); diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheStatsImpl.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheStatsImpl.java index b3c90f2727..36d9f4c123 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheStatsImpl.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EhcacheStatsImpl.java @@ -63,7 +63,8 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * Constructor accepting the backing {@link CacheManager} * - * @throws javax.management.NotCompliantMBeanException + * @param manager The {@link CacheManager} to expose stats for + * @throws javax.management.NotCompliantMBeanException should registering the MBean fail */ public EhcacheStatsImpl(CacheManager manager) throws NotCompliantMBeanException { super( EhcacheStats.class ); @@ -74,6 +75,7 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public boolean isStatisticsEnabled() { return false; } @@ -81,6 +83,7 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public void clearStats() { sampledCacheManager.clearStatistics(); statsSince = System.currentTimeMillis(); @@ -89,6 +92,7 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public void disableStats() { setStatisticsEnabled( false ); } @@ -96,6 +100,7 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public void enableStats() { setStatisticsEnabled( true ); } @@ -103,8 +108,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public void flushRegionCache(String region) { - Cache cache = this.cacheManager.getCache( region ); + final Cache cache = this.cacheManager.getCache( region ); if ( cache != null ) { cache.flush(); } @@ -113,9 +119,10 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public void flushRegionCaches() { for ( String name : cacheManager.getCacheNames() ) { - Cache cache = this.cacheManager.getCache( name ); + final Cache cache = this.cacheManager.getCache( name ); if ( cache != null ) { cache.flush(); } @@ -126,6 +133,7 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public String generateActiveConfigDeclaration() { return this.cacheManager.getActiveConfigurationText(); } @@ -133,6 +141,7 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public String generateActiveConfigDeclaration(String region) { return this.cacheManager.getActiveConfigurationText( region ); } @@ -140,10 +149,11 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public long getCacheHitCount() { long count = 0; for ( String name : cacheManager.getCacheNames() ) { - Cache cache = cacheManager.getCache( name ); + final Cache cache = cacheManager.getCache( name ); if ( cache != null ) { count += cache.getLiveCacheStatistics().getCacheHitCount(); } @@ -154,19 +164,21 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public double getCacheHitRate() { - long now = System.currentTimeMillis(); - double deltaSecs = (double) (now - statsSince) / MILLIS_PER_SECOND; + final long now = System.currentTimeMillis(); + final double deltaSecs = (double) (now - statsSince) / MILLIS_PER_SECOND; return getCacheHitCount() / deltaSecs; } /** * {@inheritDoc} */ + @Override public long getCacheHitSample() { long count = 0; for ( String name : cacheManager.getCacheNames() ) { - Cache cache = cacheManager.getCache( name ); + final Cache cache = cacheManager.getCache( name ); if ( cache != null ) { count += cache.getSampledCacheStatistics().getCacheHitMostRecentSample(); } @@ -177,10 +189,11 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public long getCacheMissCount() { long count = 0; for ( String name : cacheManager.getCacheNames() ) { - Cache cache = cacheManager.getCache( name ); + final Cache cache = cacheManager.getCache( name ); if ( cache != null ) { count += cache.getLiveCacheStatistics().getCacheMissCount(); } @@ -191,19 +204,21 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public double getCacheMissRate() { - long now = System.currentTimeMillis(); - double deltaSecs = (double) (now - statsSince) / MILLIS_PER_SECOND; + final long now = System.currentTimeMillis(); + final double deltaSecs = (double) (now - statsSince) / MILLIS_PER_SECOND; return getCacheMissCount() / deltaSecs; } /** * {@inheritDoc} */ + @Override public long getCacheMissSample() { long count = 0; for ( String name : cacheManager.getCacheNames() ) { - Cache cache = cacheManager.getCache( name ); + final Cache cache = cacheManager.getCache( name ); if ( cache != null ) { count += cache.getSampledCacheStatistics().getCacheMissMostRecentSample(); } @@ -214,10 +229,11 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public long getCachePutCount() { long count = 0; for ( String name : cacheManager.getCacheNames() ) { - Cache cache = cacheManager.getCache( name ); + final Cache cache = cacheManager.getCache( name ); if ( cache != null ) { count += cache.getLiveCacheStatistics().getPutCount(); } @@ -228,19 +244,21 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public double getCachePutRate() { - long now = System.currentTimeMillis(); - double deltaSecs = (double) (now - statsSince) / MILLIS_PER_SECOND; + final long now = System.currentTimeMillis(); + final double deltaSecs = (double) (now - statsSince) / MILLIS_PER_SECOND; return getCachePutCount() / deltaSecs; } /** * {@inheritDoc} */ + @Override public long getCachePutSample() { long count = 0; for ( String name : cacheManager.getCacheNames() ) { - Cache cache = cacheManager.getCache( name ); + final Cache cache = cacheManager.getCache( name ); if ( cache != null ) { count += cache.getSampledCacheStatistics().getCacheElementPutMostRecentSample(); } @@ -251,6 +269,7 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public String getOriginalConfigDeclaration() { return this.cacheManager.getOriginalConfigurationText(); } @@ -258,6 +277,7 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public String getOriginalConfigDeclaration(String region) { return this.cacheManager.getOriginalConfigurationText( region ); } @@ -265,8 +285,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public Map> getRegionCacheAttributes() { - Map> result = new HashMap>(); + final Map> result = new HashMap>(); for ( String regionName : this.cacheManager.getCacheNames() ) { result.put( regionName, getRegionCacheAttributes( regionName ) ); } @@ -276,8 +297,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public Map getRegionCacheAttributes(String regionName) { - Map result = new HashMap(); + final Map result = new HashMap(); result.put( "Enabled", isRegionCacheEnabled( regionName ) ); result.put( "LoggingEnabled", isRegionCacheLoggingEnabled( regionName ) ); result.put( "MaxTTISeconds", getRegionCacheMaxTTISeconds( regionName ) ); @@ -292,8 +314,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public int getRegionCacheMaxTTISeconds(String region) { - Cache cache = cacheManager.getCache( region ); + final Cache cache = cacheManager.getCache( region ); if ( cache != null ) { return (int) cache.getCacheConfiguration().getTimeToIdleSeconds(); } @@ -305,8 +328,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public int getRegionCacheMaxTTLSeconds(String region) { - Cache cache = cacheManager.getCache( region ); + final Cache cache = cacheManager.getCache( region ); if ( cache != null ) { return (int) cache.getCacheConfiguration().getTimeToLiveSeconds(); } @@ -318,8 +342,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public int getRegionCacheOrphanEvictionPeriod(String region) { - Cache cache = this.cacheManager.getCache( region ); + final Cache cache = this.cacheManager.getCache( region ); if ( cache != null && cache.isTerracottaClustered() ) { return cache.getCacheConfiguration().getTerracottaConfiguration().getOrphanEvictionPeriod(); } @@ -331,10 +356,11 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public Map getRegionCacheSamples() { - Map rv = new HashMap(); + final Map rv = new HashMap(); for ( String name : cacheManager.getCacheNames() ) { - Cache cache = cacheManager.getCache( name ); + final Cache cache = cacheManager.getCache( name ); if ( cache != null ) { rv.put( name, new int[] { @@ -352,8 +378,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public int getRegionCacheTargetMaxInMemoryCount(String region) { - Cache cache = cacheManager.getCache( region ); + final Cache cache = cacheManager.getCache( region ); if ( cache != null ) { return cache.getCacheConfiguration().getMaxElementsInMemory(); } @@ -365,8 +392,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public int getRegionCacheTargetMaxTotalCount(String region) { - Cache cache = cacheManager.getCache( region ); + final Cache cache = cacheManager.getCache( region ); if ( cache != null ) { return cache.getCacheConfiguration().getMaxElementsOnDisk(); } @@ -378,10 +406,11 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public String[] getTerracottaHibernateCacheRegionNames() { - ArrayList rv = new ArrayList(); + final ArrayList rv = new ArrayList(); for ( String name : cacheManager.getCacheNames() ) { - Cache cache = cacheManager.getCache( name ); + final Cache cache = cacheManager.getCache( name ); if ( cache != null ) { if ( cache.getCacheConfiguration().isTerracottaClustered() ) { rv.add( name ); @@ -394,8 +423,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public boolean isRegionCacheEnabled(String region) { - Cache cache = this.cacheManager.getCache( region ); + final Cache cache = this.cacheManager.getCache( region ); if ( cache != null ) { return !cache.isDisabled(); } @@ -407,8 +437,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public void setRegionCacheEnabled(String region, boolean enabled) { - Cache cache = this.cacheManager.getCache( region ); + final Cache cache = this.cacheManager.getCache( region ); if ( cache != null ) { cache.setDisabled( !enabled ); } @@ -418,9 +449,10 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public boolean isRegionCachesEnabled() { for ( String name : this.cacheManager.getCacheNames() ) { - Cache cache = this.cacheManager.getCache( name ); + final Cache cache = this.cacheManager.getCache( name ); if ( cache != null ) { if ( cache.isDisabled() ) { return false; @@ -431,11 +463,13 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat } /** + * {@inheritDoc} * @see EhcacheStats#setRegionCachesEnabled(boolean) */ + @Override public void setRegionCachesEnabled(final boolean flag) { for ( String name : this.cacheManager.getCacheNames() ) { - Cache cache = this.cacheManager.getCache( name ); + final Cache cache = this.cacheManager.getCache( name ); if ( cache != null ) { cache.setDisabled( !flag ); } @@ -446,8 +480,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public boolean isRegionCacheLoggingEnabled(String region) { - Cache cache = this.cacheManager.getCache( region ); + final Cache cache = this.cacheManager.getCache( region ); if ( cache != null ) { return cache.getCacheConfiguration().getLogging(); } @@ -459,8 +494,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public boolean isRegionCacheOrphanEvictionEnabled(String region) { - Cache cache = this.cacheManager.getCache( region ); + final Cache cache = this.cacheManager.getCache( region ); if ( cache != null && cache.isTerracottaClustered() ) { return cache.getCacheConfiguration().getTerracottaConfiguration().getOrphanEviction(); } @@ -472,8 +508,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public boolean isTerracottaHibernateCache(String region) { - Cache cache = cacheManager.getCache( region ); + final Cache cache = cacheManager.getCache( region ); if ( cache != null ) { return cache.getCacheConfiguration().isTerracottaClustered(); } @@ -485,8 +522,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public void setRegionCacheLoggingEnabled(String region, boolean loggingEnabled) { - Cache cache = this.cacheManager.getCache( region ); + final Cache cache = this.cacheManager.getCache( region ); if ( cache != null ) { cache.getCacheConfiguration().setLogging( loggingEnabled ); sendNotification( CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region ); @@ -496,8 +534,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public void setRegionCacheMaxTTISeconds(String region, int maxTTISeconds) { - Cache cache = this.cacheManager.getCache( region ); + final Cache cache = this.cacheManager.getCache( region ); if ( cache != null ) { cache.getCacheConfiguration().setTimeToIdleSeconds( maxTTISeconds ); sendNotification( CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region ); @@ -507,8 +546,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public void setRegionCacheMaxTTLSeconds(String region, int maxTTLSeconds) { - Cache cache = this.cacheManager.getCache( region ); + final Cache cache = this.cacheManager.getCache( region ); if ( cache != null ) { cache.getCacheConfiguration().setTimeToLiveSeconds( maxTTLSeconds ); sendNotification( CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region ); @@ -518,8 +558,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public void setRegionCacheTargetMaxInMemoryCount(String region, int targetMaxInMemoryCount) { - Cache cache = this.cacheManager.getCache( region ); + final Cache cache = this.cacheManager.getCache( region ); if ( cache != null ) { cache.getCacheConfiguration().setMaxElementsInMemory( targetMaxInMemoryCount ); sendNotification( CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region ); @@ -529,8 +570,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public void setRegionCacheTargetMaxTotalCount(String region, int targetMaxTotalCount) { - Cache cache = this.cacheManager.getCache( region ); + final Cache cache = this.cacheManager.getCache( region ); if ( cache != null ) { cache.getCacheConfiguration().setMaxElementsOnDisk( targetMaxTotalCount ); sendNotification( CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region ); @@ -542,8 +584,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat * * @see EhcacheStats#getNumberOfElementsInMemory(java.lang.String) */ + @Override public int getNumberOfElementsInMemory(String region) { - Cache cache = this.cacheManager.getCache( region ); + final Cache cache = this.cacheManager.getCache( region ); if ( cache != null ) { return (int) cache.getMemoryStoreSize(); } @@ -557,8 +600,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat * * @see EhcacheStats#getNumberOfElementsOffHeap(java.lang.String) */ + @Override public int getNumberOfElementsOffHeap(String region) { - Cache cache = this.cacheManager.getCache( region ); + final Cache cache = this.cacheManager.getCache( region ); if ( cache != null ) { return (int) cache.getOffHeapStoreSize(); } @@ -572,8 +616,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat * * @see EhcacheStats#getNumberOfElementsOnDisk(java.lang.String) */ + @Override public int getNumberOfElementsOnDisk(String region) { - Cache cache = this.cacheManager.getCache( region ); + final Cache cache = this.cacheManager.getCache( region ); if ( cache != null ) { return cache.getDiskStoreSize(); } @@ -585,9 +630,10 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public void setStatisticsEnabled(boolean flag) { for ( String cacheName : cacheManager.getCacheNames() ) { - Cache cache = cacheManager.getCache( cacheName ); + final Cache cache = cacheManager.getCache( cacheName ); if ( cache != null ) { cache.setStatisticsEnabled( flag ); } @@ -601,10 +647,11 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public long getMaxGetTimeMillis() { long rv = 0; for ( String cacheName : cacheManager.getCacheNames() ) { - Cache cache = cacheManager.getCache( cacheName ); + final Cache cache = cacheManager.getCache( cacheName ); if ( cache != null ) { rv = Math.max( rv, cache.getLiveCacheStatistics().getMaxGetTimeMillis() ); } @@ -615,10 +662,11 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat /** * {@inheritDoc} */ + @Override public long getMinGetTimeMillis() { long rv = 0; for ( String cacheName : cacheManager.getCacheNames() ) { - Cache cache = cacheManager.getCache( cacheName ); + final Cache cache = cacheManager.getCache( cacheName ); if ( cache != null ) { rv = Math.max( rv, cache.getLiveCacheStatistics().getMinGetTimeMillis() ); } @@ -631,8 +679,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat * * @see EhcacheStats#getMaxGetTimeMillis(java.lang.String) */ + @Override public long getMaxGetTimeMillis(String cacheName) { - Cache cache = cacheManager.getCache( cacheName ); + final Cache cache = cacheManager.getCache( cacheName ); if ( cache != null ) { return cache.getLiveCacheStatistics().getMaxGetTimeMillis(); } @@ -646,8 +695,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat * * @see EhcacheStats#getMinGetTimeMillis(java.lang.String) */ + @Override public long getMinGetTimeMillis(String cacheName) { - Cache cache = cacheManager.getCache( cacheName ); + final Cache cache = cacheManager.getCache( cacheName ); if ( cache != null ) { return cache.getLiveCacheStatistics().getMinGetTimeMillis(); } @@ -661,8 +711,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat * * @see EhcacheStats#getAverageGetTimeMillis(java.lang.String) */ + @Override public float getAverageGetTimeMillis(String region) { - Cache cache = this.cacheManager.getCache( region ); + final Cache cache = this.cacheManager.getCache( region ); if ( cache != null ) { return cache.getLiveCacheStatistics().getAverageGetTimeMillis(); } @@ -680,6 +731,7 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat } /** + * {@inheritDoc} * @see AbstractEmitterBean#getNotificationInfo() */ @Override diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EntityStats.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EntityStats.java index a121801db3..19faf860c1 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EntityStats.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/EntityStats.java @@ -120,7 +120,8 @@ public class EntityStats implements Serializable { protected long optimisticFailureCount; /** - * @param name + * Constructor only naming the stat + * @param name the name of the entity */ public EntityStats(String name) { this.name = name; @@ -128,8 +129,9 @@ public class EntityStats implements Serializable { } /** - * @param name - * @param src + * Constructor naming the stat and sourcing stats + * @param name the name of the entity + * @param src its source for the stats to expose */ public EntityStats(String name, EntityStatistics src) { this( name ); @@ -149,7 +151,8 @@ public class EntityStats implements Serializable { } /** - * @param cData + * Constructor from compositeDate + * @param cData CompositeData of the stats */ public EntityStats(final CompositeData cData) { int i = 0; @@ -173,7 +176,8 @@ public class EntityStats implements Serializable { } /** - * @param stats + * Adds the counters of this instance up with the ones passed in + * @param stats the stats to add to this one */ public void add(EntityStats stats) { loadCount += stats.getLoadCount(); @@ -185,7 +189,7 @@ public class EntityStats implements Serializable { } /** - * toString + * {@inheritDoc} */ @Override public String toString() { @@ -195,63 +199,72 @@ public class EntityStats implements Serializable { } /** - * getName + * The name of the entity those stats are about + * @return the entity name */ public String getName() { return name; } /** - * getShortName + * The short name of the entity those stats are about + * @return the shortName of the entity */ public String getShortName() { return shortName; } /** - * getLoadCount + * Amount of load ops on the entity + * @return the load count */ public long getLoadCount() { return loadCount; } /** - * getUpdateCount + * Amount of update ops on the entity + * @return the update count */ public long getUpdateCount() { return updateCount; } /** - * getInsertCount + * Amount of insert ops on the entity + * @return the insert count */ public long getInsertCount() { return insertCount; } /** - * getDeleteCount + * Amount of delete ops on the entity + * @return the delete count */ public long getDeleteCount() { return deleteCount; } /** - * getFetchCount + * Amount of fetch ops on the entity + * @return the fetch count */ public long getFetchCount() { return fetchCount; } /** - * getOptimisticFailureCount + * Amount of optimistic failures on the entity + * @return the optimistic failure count */ public long getOptimisticFailureCount() { return optimisticFailureCount; } /** - * toCompositeData + * Creates a CompositeData instance of this instance + * @return the compositeData representation of this instance */ public CompositeData toCompositeData() { try { @@ -268,14 +281,17 @@ public class EntityStats implements Serializable { } /** - * newTabularDataInstance + * Creates a new TabularData + * @return a new TabularData instance */ public static TabularData newTabularDataInstance() { return new TabularDataSupport( TABULAR_TYPE ); } /** - * fromTabularData + * Reads an array of entityStats from TabularData + * @param tabularData the tabularData with the {@link CompositeData} of stats to extract + * @return all entityStats as an array */ public static EntityStats[] fromTabularData(final TabularData tabularData) { final List countList = new ArrayList( tabularData.size() ); diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/HibernateStatsImpl.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/HibernateStatsImpl.java index 85eed55b05..35bc4e0ea2 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/HibernateStatsImpl.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/HibernateStatsImpl.java @@ -59,9 +59,9 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate /** * Constructor accepting the backing {@link SessionFactory} * - * @param sessionFactory + * @param sessionFactory the {@link SessionFactory} to source stats from * - * @throws javax.management.NotCompliantMBeanException + * @throws javax.management.NotCompliantMBeanException thrown from JMX super ctor */ public HibernateStatsImpl(SessionFactory sessionFactory) throws NotCompliantMBeanException { super( HibernateStats.class ); @@ -80,6 +80,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate * * @see HibernateStats#clearStats() */ + @Override public void clearStats() { getStatistics().clear(); sendNotification( CACHE_STATISTICS_RESET ); @@ -90,6 +91,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate * * @see HibernateStats#disableStats() */ + @Override public void disableStats() { setStatisticsEnabled( false ); } @@ -99,6 +101,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate * * @see HibernateStats#enableStats() */ + @Override public void enableStats() { setStatisticsEnabled( true ); } @@ -108,6 +111,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate * * @see HibernateStats#getCloseStatementCount() */ + @Override public long getCloseStatementCount() { return getStatistics().getCloseStatementCount(); } @@ -117,13 +121,18 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate * * @see HibernateStats#getConnectCount() */ + @Override public long getConnectCount() { return getStatistics().getConnectCount(); } /** - * Not supported right now + * Unsupported operation + * @return nothing ever, this only throws! + * @throws UnsupportedOperationException + * @deprecated DO NOT USE, WILL ONLY THROW AT YOU! */ + @Deprecated public long getDBSQLExecutionSample() { throw new UnsupportedOperationException( "Use getQueryExecutionCount() instead" ); } @@ -133,6 +142,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate * * @see HibernateStats#getFlushCount() */ + @Override public long getFlushCount() { return getStatistics().getFlushCount(); } @@ -142,6 +152,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate * * @see HibernateStats#getOptimisticFailureCount() */ + @Override public long getOptimisticFailureCount() { return getStatistics().getOptimisticFailureCount(); } @@ -151,6 +162,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate * * @see HibernateStats#getPrepareStatementCount() */ + @Override public long getPrepareStatementCount() { return getStatistics().getPrepareStatementCount(); } @@ -160,6 +172,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate * * @see HibernateStats#getQueryExecutionCount() */ + @Override public long getQueryExecutionCount() { return getStatistics().getQueryExecutionCount(); } @@ -169,10 +182,11 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate * * @see HibernateStats#getQueryExecutionRate() */ + @Override public double getQueryExecutionRate() { - long startTime = getStatistics().getStartTime(); - long now = System.currentTimeMillis(); - double deltaSecs = (now - startTime) / MILLIS_PER_SECOND; + final long startTime = getStatistics().getStartTime(); + final long now = System.currentTimeMillis(); + final double deltaSecs = (now - startTime) / MILLIS_PER_SECOND; return getQueryExecutionCount() / deltaSecs; } @@ -181,6 +195,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate * * @see HibernateStats#getQueryExecutionSample() */ + @Override public long getQueryExecutionSample() { throw new UnsupportedOperationException( "TODO: need to impl. rates for query execution" ); } @@ -190,6 +205,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate * * @see HibernateStats#getSessionCloseCount() */ + @Override public long getSessionCloseCount() { return getStatistics().getSessionCloseCount(); } @@ -199,6 +215,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate * * @see HibernateStats#getSessionOpenCount() */ + @Override public long getSessionOpenCount() { return getStatistics().getSessionOpenCount(); } @@ -208,6 +225,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate * * @see HibernateStats#getSuccessfulTransactionCount() */ + @Override public long getSuccessfulTransactionCount() { return getStatistics().getSuccessfulTransactionCount(); } @@ -217,6 +235,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate * * @see HibernateStats#getTransactionCount() */ + @Override public long getTransactionCount() { return getStatistics().getTransactionCount(); } @@ -226,6 +245,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate * * @see HibernateStats#isStatisticsEnabled() */ + @Override public boolean isStatisticsEnabled() { return getStatistics().isStatisticsEnabled(); } @@ -235,6 +255,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate * * @see HibernateStats#setStatisticsEnabled(boolean) */ + @Override public void setStatisticsEnabled(boolean flag) { getStatistics().setStatisticsEnabled( flag ); sendNotification( CACHE_STATISTICS_ENABLED, flag ); @@ -245,14 +266,15 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate * * @see HibernateStats#getEntityStats() */ + @Override public TabularData getEntityStats() { - List result = new ArrayList(); - Statistics statistics = getStatistics(); + final List result = new ArrayList(); + final Statistics statistics = getStatistics(); for ( String entity : statistics.getEntityNames() ) { - EntityStats entityStats = new EntityStats( entity, statistics.getEntityStatistics( entity ) ); + final EntityStats entityStats = new EntityStats( entity, statistics.getEntityStatistics( entity ) ); result.add( entityStats.toCompositeData() ); } - TabularData td = EntityStats.newTabularDataInstance(); + final TabularData td = EntityStats.newTabularDataInstance(); td.putAll( result.toArray( new CompositeData[result.size()] ) ); return td; } @@ -262,17 +284,18 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate * * @see HibernateStats#getCollectionStats() */ + @Override public TabularData getCollectionStats() { - List result = new ArrayList(); - Statistics statistics = getStatistics(); + final List result = new ArrayList(); + final Statistics statistics = getStatistics(); for ( String roleName : statistics.getCollectionRoleNames() ) { - CollectionStats collectionStats = new CollectionStats( + final CollectionStats collectionStats = new CollectionStats( roleName, statistics.getCollectionStatistics( roleName ) ); result.add( collectionStats.toCompositeData() ); } - TabularData td = CollectionStats.newTabularDataInstance(); + final TabularData td = CollectionStats.newTabularDataInstance(); td.putAll( result.toArray( new CompositeData[result.size()] ) ); return td; } @@ -282,14 +305,15 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate * * @see HibernateStats#getQueryStats() */ + @Override public TabularData getQueryStats() { - List result = new ArrayList(); - Statistics statistics = getStatistics(); + final List result = new ArrayList(); + final Statistics statistics = getStatistics(); for ( String query : statistics.getQueries() ) { - QueryStats queryStats = new QueryStats( query, statistics.getQueryStatistics( query ) ); + final QueryStats queryStats = new QueryStats( query, statistics.getQueryStatistics( query ) ); result.add( queryStats.toCompositeData() ); } - TabularData td = QueryStats.newTabularDataInstance(); + final TabularData td = QueryStats.newTabularDataInstance(); td.putAll( result.toArray( new CompositeData[result.size()] ) ); return td; } @@ -297,17 +321,18 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate /** * {@inheritDoc} */ + @Override public TabularData getCacheRegionStats() { - List list = new ArrayList(); - Statistics statistics = getStatistics(); + final List list = new ArrayList(); + final Statistics statistics = getStatistics(); for ( String region : statistics.getSecondLevelCacheRegionNames() ) { - CacheRegionStats l2CacheStats = new CacheRegionStats( + final CacheRegionStats l2CacheStats = new CacheRegionStats( region, statistics.getSecondLevelCacheStatistics( region ) ); list.add( l2CacheStats.toCompositeData() ); } - TabularData td = CacheRegionStats.newTabularDataInstance(); + final TabularData td = CacheRegionStats.newTabularDataInstance(); td.putAll( list.toArray( new CompositeData[list.size()] ) ); return td; } @@ -321,6 +346,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate } /** + * {@inheritDoc} * @see AbstractEmitterBean#getNotificationInfo() */ @Override diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/NullHibernateStats.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/NullHibernateStats.java index b7712a71c1..56c66c0e90 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/NullHibernateStats.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/NullHibernateStats.java @@ -59,6 +59,7 @@ public final class NullHibernateStats implements HibernateStats { * * @see HibernateStats#clearStats() */ + @Override public void clearStats() { // no-op @@ -69,6 +70,7 @@ public final class NullHibernateStats implements HibernateStats { * * @see HibernateStats#disableStats() */ + @Override public void disableStats() { // no-op @@ -79,6 +81,7 @@ public final class NullHibernateStats implements HibernateStats { * * @see HibernateStats#enableStats() */ + @Override public void enableStats() { // no-op @@ -89,6 +92,7 @@ public final class NullHibernateStats implements HibernateStats { * * @see HibernateStats#getCloseStatementCount() */ + @Override public long getCloseStatementCount() { // no-op return 0; @@ -99,6 +103,7 @@ public final class NullHibernateStats implements HibernateStats { * * @see HibernateStats#getCollectionStats() */ + @Override public TabularData getCollectionStats() { // no-op return null; @@ -109,6 +114,7 @@ public final class NullHibernateStats implements HibernateStats { * * @see HibernateStats#getConnectCount() */ + @Override public long getConnectCount() { // no-op return 0; @@ -116,6 +122,7 @@ public final class NullHibernateStats implements HibernateStats { /** * Not supported right now + * @return 0 always */ public long getDBSQLExecutionSample() { // no-op @@ -127,6 +134,7 @@ public final class NullHibernateStats implements HibernateStats { * * @see HibernateStats#getEntityStats() */ + @Override public TabularData getEntityStats() { // no-op return null; @@ -137,6 +145,7 @@ public final class NullHibernateStats implements HibernateStats { * * @see HibernateStats#getFlushCount() */ + @Override public long getFlushCount() { // no-op return 0; @@ -147,6 +156,7 @@ public final class NullHibernateStats implements HibernateStats { * * @see HibernateStats#getOptimisticFailureCount() */ + @Override public long getOptimisticFailureCount() { // no-op return 0; @@ -157,6 +167,7 @@ public final class NullHibernateStats implements HibernateStats { * * @see HibernateStats#getPrepareStatementCount() */ + @Override public long getPrepareStatementCount() { // no-op return 0; @@ -167,6 +178,7 @@ public final class NullHibernateStats implements HibernateStats { * * @see HibernateStats#getQueryExecutionCount() */ + @Override public long getQueryExecutionCount() { // no-op return 0; @@ -177,6 +189,7 @@ public final class NullHibernateStats implements HibernateStats { * * @see HibernateStats#getQueryExecutionRate() */ + @Override public double getQueryExecutionRate() { // no-op return 0; @@ -187,6 +200,7 @@ public final class NullHibernateStats implements HibernateStats { * * @see HibernateStats#getQueryExecutionSample() */ + @Override public long getQueryExecutionSample() { // no-op return 0; @@ -197,6 +211,7 @@ public final class NullHibernateStats implements HibernateStats { * * @see HibernateStats#getQueryStats() */ + @Override public TabularData getQueryStats() { // no-op return null; @@ -207,6 +222,7 @@ public final class NullHibernateStats implements HibernateStats { * * @see HibernateStats#getSessionCloseCount() */ + @Override public long getSessionCloseCount() { // no-op return 0; @@ -217,6 +233,7 @@ public final class NullHibernateStats implements HibernateStats { * * @see HibernateStats#getSessionOpenCount() */ + @Override public long getSessionOpenCount() { // no-op return 0; @@ -227,6 +244,7 @@ public final class NullHibernateStats implements HibernateStats { * * @see HibernateStats#getSuccessfulTransactionCount() */ + @Override public long getSuccessfulTransactionCount() { // no-op return 0; @@ -237,6 +255,7 @@ public final class NullHibernateStats implements HibernateStats { * * @see HibernateStats#getTransactionCount() */ + @Override public long getTransactionCount() { // no-op return 0; @@ -247,6 +266,7 @@ public final class NullHibernateStats implements HibernateStats { * * @see HibernateStats#isStatisticsEnabled() */ + @Override public boolean isStatisticsEnabled() { // no-op return false; @@ -257,43 +277,54 @@ public final class NullHibernateStats implements HibernateStats { * * @see HibernateStats#setStatisticsEnabled(boolean) */ + @Override public void setStatisticsEnabled(boolean flag) { // no-op } /** + * {@inheritDoc} * @see HibernateStats#getCacheRegionStats() */ + @Override public TabularData getCacheRegionStats() { return null; } /** + * {@inheritDoc} * @see javax.management.NotificationEmitter#removeNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object) */ + @Override public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException { /**/ } /** + * {@inheritDoc} * @see javax.management.NotificationBroadcaster#addNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object) */ + @Override public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException { /**/ } /** + * {@inheritDoc} * @see javax.management.NotificationBroadcaster#getNotificationInfo() */ + @Override public MBeanNotificationInfo[] getNotificationInfo() { return null; } /** + * {@inheritDoc} * @see javax.management.NotificationBroadcaster#removeNotificationListener(javax.management.NotificationListener) */ + @Override public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException { /**/ } diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/ProviderMBeanRegistrationHelper.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/ProviderMBeanRegistrationHelper.java index 648cc17cf6..2a081f12e0 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/ProviderMBeanRegistrationHelper.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/ProviderMBeanRegistrationHelper.java @@ -116,7 +116,7 @@ public class ProviderMBeanRegistrationHelper { throw new CacheException( e ); } } - SessionFactory sessionFactory = locateSessionFactory(); + final SessionFactory sessionFactory = locateSessionFactory(); if ( sessionFactory == null ) { LOG.debug( "SessionFactory is probably still being initialized..." @@ -140,29 +140,29 @@ public class ProviderMBeanRegistrationHelper { } private SessionFactory locateSessionFactory() { - String jndiName = properties.getProperty( Environment.SESSION_FACTORY_NAME ); + final String jndiName = properties.getProperty( Environment.SESSION_FACTORY_NAME ); if ( jndiName != null ) { return SessionFactoryRegistry.INSTANCE.getNamedSessionFactory( jndiName ); } try { - Class factoryType = SessionFactoryRegistry.class; - Field instancesField = getField( factoryType, "sessionFactoryMap" ); + final Class factoryType = SessionFactoryRegistry.class; + final Field instancesField = getField( factoryType, "sessionFactoryMap" ); if ( instancesField == null ) { throw new RuntimeException( "Expected 'sessionFactoryMap' field on " + SessionFactoryRegistry.class.getName() ); } instancesField.setAccessible( true ); - Map map = (Map) instancesField.get( SessionFactoryRegistry.INSTANCE ); + final Map map = (Map) instancesField.get( SessionFactoryRegistry.INSTANCE ); if ( map == null ) { return null; } - Iterator values = map.values().iterator(); + final Iterator values = map.values().iterator(); while ( values.hasNext() ) { - SessionFactory sessionFactory = (SessionFactory) values.next(); - Class sessionFactoryType = sessionFactory.getClass(); - Field propertiesField = getField( sessionFactoryType, "properties" ); + final SessionFactory sessionFactory = (SessionFactory) values.next(); + final Class sessionFactoryType = sessionFactory.getClass(); + final Field propertiesField = getField( sessionFactoryType, "properties" ); if ( propertiesField != null ) { propertiesField.setAccessible( true ); - Properties props = (Properties) propertiesField.get( sessionFactory ); + final Properties props = (Properties) propertiesField.get( sessionFactory ); if ( props != null && props.equals( properties ) ) { return sessionFactory; } @@ -187,4 +187,4 @@ public class ProviderMBeanRegistrationHelper { } throw new NoSuchFieldError( "Type '" + c + "' has no field '" + fieldName + "'" ); } -} \ No newline at end of file +} diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/QueryStats.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/QueryStats.java index 27c33bea14..4eba0d82e7 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/QueryStats.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/QueryStats.java @@ -41,6 +41,8 @@ import org.hibernate.stat.QueryStatistics; /** + * Represent point in time state of the query stats of a given query + * * @author gkeim * @author Alex Snaps */ @@ -137,15 +139,17 @@ public class QueryStats implements Serializable { protected long executionMinTime; /** - * @param name + * Constructor + * @param name the query string */ public QueryStats(String name) { this.query = name; } /** - * @param name - * @param src + * Constructor + * @param name the query string + * @param src the source of the stats to this query */ public QueryStats(String name, QueryStatistics src) { this( name ); @@ -168,7 +172,8 @@ public class QueryStats implements Serializable { } /** - * @param cData + * Constructor + * @param cData CompositeDate to construct an instance from */ public QueryStats(final CompositeData cData) { int i = 0; @@ -183,17 +188,9 @@ public class QueryStats implements Serializable { executionMinTime = (Long) cData.get( ITEM_NAMES[i++] ); } - private static int safeParseInt(String s) { - try { - return Integer.parseInt( s ); - } - catch (Exception e) { - return -1; - } - } - /** - * @param stats + * Adds to the counter of this instance + * @param stats the counters to add to these ones */ public void add(QueryStats stats) { cacheHitCount += stats.getCacheHitCount(); @@ -207,7 +204,7 @@ public class QueryStats implements Serializable { } /** - * toString + * {@inheritDoc} */ @Override public String toString() { @@ -218,70 +215,80 @@ public class QueryStats implements Serializable { } /** - * getQuery + * Accessor to the queryString + * @return the query string */ public String getQuery() { return query; } /** - * getCacheHitCount + * The amount of hits for this query + * @return the hit count */ public long getCacheHitCount() { return cacheHitCount; } /** - * getCacheMissCount + * The amount of misses for this query + * @return the miss count */ public long getCacheMissCount() { return cacheMissCount; } /** - * getCachePutCount + * The amount of puts for this query + * @return the put count */ public long getCachePutCount() { return cachePutCount; } /** - * getExecutionCount + * The amount of execution of this query + * @return the execution count */ public long getExecutionCount() { return executionCount; } /** - * getExecutionRowCount + * The amount of rows returned for this query + * @return the row count */ public long getExecutionRowCount() { return executionRowCount; } /** - * getExecutionAvgTime + * The avg time to execute this query + * @return the avg time in ms */ public long getExecutionAvgTime() { return executionAvgTime; } /** - * getExecutionMaxTime + * The max time to execute this query + * @return the max time in ms */ public long getExecutionMaxTime() { return executionMaxTime; } /** - * getExecutionMinTime + * The minimum time to execute this query + * @return the min time in ms */ public long getExecutionMinTime() { return executionMinTime; } /** - * toCompositeData + * Creates a CompositeData instance of this instance + * @return the compositeData representation of this instance */ public CompositeData toCompositeData() { try { @@ -303,14 +310,17 @@ public class QueryStats implements Serializable { } /** - * newTabularDataInstance + * Creates a new TabularData + * @return a new TabularData instance */ public static TabularData newTabularDataInstance() { return new TabularDataSupport( TABULAR_TYPE ); } /** - * fromTabularData + * Reads an array of queryStats from TabularData + * @param tabularData the tabularData with the {@link CompositeData} of stats to extract + * @return all queryStats as an array */ public static QueryStats[] fromTabularData(final TabularData tabularData) { final List countList = new ArrayList( tabularData.size() );