HHH-8211 Fixed checkstyle issues in hibernate-ehcache module

This commit is contained in:
Alex Snaps 2013-05-08 16:18:42 -04:00 committed by Steve Ebersole
parent 0ff155d065
commit ab47eae5b9
13 changed files with 365 additions and 142 deletions

View File

@ -217,7 +217,7 @@ public class EhcacheTransactionalDataRegion extends EhcacheDataRegion implements
* *
* @throws CacheException Indicates a problem accessing the cache * @throws CacheException Indicates a problem accessing the cache
*/ */
public final void writeLock(Object key) { public final void writeLock(Object key) throws CacheException {
try { try {
lockProvider.getSyncForKey( key ).lock( LockType.WRITE ); lockProvider.getSyncForKey( key ).lock( LockType.WRITE );
} }
@ -239,7 +239,7 @@ public class EhcacheTransactionalDataRegion extends EhcacheDataRegion implements
* *
* @throws CacheException Indicates a problem accessing the cache * @throws CacheException Indicates a problem accessing the cache
*/ */
public final void writeUnlock(Object key) { public final void writeUnlock(Object key) throws CacheException {
try { try {
lockProvider.getSyncForKey( key ).unlock( LockType.WRITE ); lockProvider.getSyncForKey( key ).unlock( LockType.WRITE );
} }
@ -261,7 +261,7 @@ public class EhcacheTransactionalDataRegion extends EhcacheDataRegion implements
* *
* @throws CacheException Indicates a problem accessing the cache * @throws CacheException Indicates a problem accessing the cache
*/ */
public final void readLock(Object key) { public final void readLock(Object key) throws CacheException {
try { try {
lockProvider.getSyncForKey( key ).lock( LockType.WRITE ); lockProvider.getSyncForKey( key ).lock( LockType.WRITE );
} }
@ -283,7 +283,7 @@ public class EhcacheTransactionalDataRegion extends EhcacheDataRegion implements
* *
* @throws CacheException Indicates a problem accessing the cache * @throws CacheException Indicates a problem accessing the cache
*/ */
public final void readUnlock(Object key) { public final void readUnlock(Object key) throws CacheException {
try { try {
lockProvider.getSyncForKey( key ).unlock( LockType.WRITE ); lockProvider.getSyncForKey( key ).unlock( LockType.WRITE );
} }

View File

@ -138,6 +138,9 @@ public abstract class AbstractEmitterBean extends StandardMBean implements Notif
notificationListeners.clear(); notificationListeners.clear();
} }
/**
* {@inheritDoc}
*/
@Override @Override
public abstract MBeanNotificationInfo[] getNotificationInfo(); public abstract MBeanNotificationInfo[] getNotificationInfo();

View File

@ -95,7 +95,7 @@ public abstract class CacheRegionUtils {
} }
boolean truncate = true; boolean truncate = true;
for ( int i = 0; i < comps.length; i++ ) { for ( int i = 0; i < comps.length; i++ ) {
String comp = comps[i]; final String comp = comps[i];
final char c = comp.charAt( 0 ); final char c = comp.charAt( 0 );
if ( truncate && Character.isUpperCase( c ) ) { if ( truncate && Character.isUpperCase( c ) ) {
truncate = false; truncate = false;

View File

@ -63,7 +63,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
* *
* @param manager the backing {@link CacheManager} * @param manager the backing {@link CacheManager}
* *
* @throws NotCompliantMBeanException * @throws NotCompliantMBeanException if bean doesn't comply
*/ */
public EhcacheHibernate(CacheManager manager) throws NotCompliantMBeanException { public EhcacheHibernate(CacheManager manager) throws NotCompliantMBeanException {
super( EhcacheHibernateMBean.class ); super( EhcacheHibernateMBean.class );
@ -72,12 +72,13 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* Enable hibernate statistics with the input session factory * Enable hibernate statistics with the input session factory
* @param sessionFactory the session factory to enable stats for
*/ */
public void enableHibernateStatistics(SessionFactory sessionFactory) { public void enableHibernateStatistics(SessionFactory sessionFactory) {
try { try {
hibernateStats = new HibernateStatsImpl( sessionFactory ); hibernateStats = new HibernateStatsImpl( sessionFactory );
} }
catch (Exception e) { catch ( Exception e ) {
throw new RuntimeException( e ); throw new RuntimeException( e );
} }
} }
@ -85,6 +86,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public boolean isHibernateStatisticsSupported() { public boolean isHibernateStatisticsSupported() {
return hibernateStats instanceof HibernateStatsImpl; return hibernateStats instanceof HibernateStatsImpl;
} }
@ -92,6 +94,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void setStatisticsEnabled(boolean flag) { public void setStatisticsEnabled(boolean flag) {
if ( flag ) { if ( flag ) {
ehcacheStats.enableStats(); ehcacheStats.enableStats();
@ -108,6 +111,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public boolean isStatisticsEnabled() { public boolean isStatisticsEnabled() {
return statsEnabled.get(); return statsEnabled.get();
} }
@ -115,6 +119,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void clearStats() { public void clearStats() {
ehcacheStats.clearStats(); ehcacheStats.clearStats();
hibernateStats.clearStats(); hibernateStats.clearStats();
@ -123,6 +128,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void disableStats() { public void disableStats() {
setStatisticsEnabled( false ); setStatisticsEnabled( false );
} }
@ -130,6 +136,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void enableStats() { public void enableStats() {
setStatisticsEnabled( true ); setStatisticsEnabled( true );
} }
@ -137,6 +144,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void flushRegionCache(String region) { public void flushRegionCache(String region) {
ehcacheStats.flushRegionCache( region ); ehcacheStats.flushRegionCache( region );
sendNotification( HibernateStats.CACHE_REGION_FLUSHED, region ); sendNotification( HibernateStats.CACHE_REGION_FLUSHED, region );
@ -145,6 +153,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void flushRegionCaches() { public void flushRegionCaches() {
ehcacheStats.flushRegionCaches(); ehcacheStats.flushRegionCaches();
sendNotification( HibernateStats.CACHE_FLUSHED ); sendNotification( HibernateStats.CACHE_FLUSHED );
@ -153,6 +162,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public String generateActiveConfigDeclaration() { public String generateActiveConfigDeclaration() {
return ehcacheStats.generateActiveConfigDeclaration(); return ehcacheStats.generateActiveConfigDeclaration();
} }
@ -160,6 +170,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public String generateActiveConfigDeclaration(String region) { public String generateActiveConfigDeclaration(String region) {
return ehcacheStats.generateActiveConfigDeclaration( region ); return ehcacheStats.generateActiveConfigDeclaration( region );
} }
@ -167,6 +178,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getCacheHitCount() { public long getCacheHitCount() {
return ehcacheStats.getCacheHitCount(); return ehcacheStats.getCacheHitCount();
} }
@ -174,6 +186,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public double getCacheHitRate() { public double getCacheHitRate() {
return ehcacheStats.getCacheHitRate(); return ehcacheStats.getCacheHitRate();
} }
@ -181,6 +194,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getCacheHitSample() { public long getCacheHitSample() {
return ehcacheStats.getCacheHitSample(); return ehcacheStats.getCacheHitSample();
} }
@ -188,6 +202,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getCacheMissCount() { public long getCacheMissCount() {
return ehcacheStats.getCacheMissCount(); return ehcacheStats.getCacheMissCount();
} }
@ -195,6 +210,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public double getCacheMissRate() { public double getCacheMissRate() {
return ehcacheStats.getCacheMissRate(); return ehcacheStats.getCacheMissRate();
} }
@ -202,6 +218,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getCacheMissSample() { public long getCacheMissSample() {
return ehcacheStats.getCacheMissSample(); return ehcacheStats.getCacheMissSample();
} }
@ -209,6 +226,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getCachePutCount() { public long getCachePutCount() {
return ehcacheStats.getCachePutCount(); return ehcacheStats.getCachePutCount();
} }
@ -216,6 +234,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public double getCachePutRate() { public double getCachePutRate() {
return ehcacheStats.getCachePutRate(); return ehcacheStats.getCachePutRate();
} }
@ -223,6 +242,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getCachePutSample() { public long getCachePutSample() {
return ehcacheStats.getCachePutSample(); return ehcacheStats.getCachePutSample();
} }
@ -230,6 +250,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public TabularData getCacheRegionStats() { public TabularData getCacheRegionStats() {
return hibernateStats.getCacheRegionStats(); return hibernateStats.getCacheRegionStats();
} }
@ -237,6 +258,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getCloseStatementCount() { public long getCloseStatementCount() {
return hibernateStats.getCloseStatementCount(); return hibernateStats.getCloseStatementCount();
} }
@ -244,6 +266,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public TabularData getCollectionStats() { public TabularData getCollectionStats() {
return hibernateStats.getCollectionStats(); return hibernateStats.getCollectionStats();
} }
@ -251,6 +274,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getConnectCount() { public long getConnectCount() {
return hibernateStats.getConnectCount(); return hibernateStats.getConnectCount();
} }
@ -258,6 +282,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public TabularData getEntityStats() { public TabularData getEntityStats() {
return hibernateStats.getEntityStats(); return hibernateStats.getEntityStats();
} }
@ -265,6 +290,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getFlushCount() { public long getFlushCount() {
return hibernateStats.getFlushCount(); return hibernateStats.getFlushCount();
} }
@ -272,6 +298,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getOptimisticFailureCount() { public long getOptimisticFailureCount() {
return hibernateStats.getOptimisticFailureCount(); return hibernateStats.getOptimisticFailureCount();
} }
@ -279,6 +306,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public String getOriginalConfigDeclaration() { public String getOriginalConfigDeclaration() {
return ehcacheStats.getOriginalConfigDeclaration(); return ehcacheStats.getOriginalConfigDeclaration();
} }
@ -286,6 +314,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public String getOriginalConfigDeclaration(String region) { public String getOriginalConfigDeclaration(String region) {
return ehcacheStats.getOriginalConfigDeclaration( region ); return ehcacheStats.getOriginalConfigDeclaration( region );
} }
@ -293,6 +322,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getPrepareStatementCount() { public long getPrepareStatementCount() {
return hibernateStats.getPrepareStatementCount(); return hibernateStats.getPrepareStatementCount();
} }
@ -300,6 +330,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getQueryExecutionCount() { public long getQueryExecutionCount() {
return hibernateStats.getQueryExecutionCount(); return hibernateStats.getQueryExecutionCount();
} }
@ -307,6 +338,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public double getQueryExecutionRate() { public double getQueryExecutionRate() {
return hibernateStats.getQueryExecutionRate(); return hibernateStats.getQueryExecutionRate();
} }
@ -314,6 +346,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getQueryExecutionSample() { public long getQueryExecutionSample() {
return hibernateStats.getQueryExecutionSample(); return hibernateStats.getQueryExecutionSample();
} }
@ -321,6 +354,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public TabularData getQueryStats() { public TabularData getQueryStats() {
return hibernateStats.getQueryStats(); return hibernateStats.getQueryStats();
} }
@ -328,6 +362,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public Map<String, Map<String, Object>> getRegionCacheAttributes() { public Map<String, Map<String, Object>> getRegionCacheAttributes() {
return ehcacheStats.getRegionCacheAttributes(); return ehcacheStats.getRegionCacheAttributes();
} }
@ -335,6 +370,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public Map<String, Object> getRegionCacheAttributes(String regionName) { public Map<String, Object> getRegionCacheAttributes(String regionName) {
return ehcacheStats.getRegionCacheAttributes( regionName ); return ehcacheStats.getRegionCacheAttributes( regionName );
} }
@ -342,6 +378,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public int getRegionCacheMaxTTISeconds(String region) { public int getRegionCacheMaxTTISeconds(String region) {
return ehcacheStats.getRegionCacheMaxTTISeconds( region ); return ehcacheStats.getRegionCacheMaxTTISeconds( region );
} }
@ -349,6 +386,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public int getRegionCacheMaxTTLSeconds(String region) { public int getRegionCacheMaxTTLSeconds(String region) {
return ehcacheStats.getRegionCacheMaxTTLSeconds( region ); return ehcacheStats.getRegionCacheMaxTTLSeconds( region );
} }
@ -356,6 +394,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public int getRegionCacheOrphanEvictionPeriod(String region) { public int getRegionCacheOrphanEvictionPeriod(String region) {
return ehcacheStats.getRegionCacheOrphanEvictionPeriod( region ); return ehcacheStats.getRegionCacheOrphanEvictionPeriod( region );
} }
@ -363,6 +402,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public Map<String, int[]> getRegionCacheSamples() { public Map<String, int[]> getRegionCacheSamples() {
return ehcacheStats.getRegionCacheSamples(); return ehcacheStats.getRegionCacheSamples();
} }
@ -370,6 +410,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public int getRegionCacheTargetMaxInMemoryCount(String region) { public int getRegionCacheTargetMaxInMemoryCount(String region) {
return ehcacheStats.getRegionCacheTargetMaxInMemoryCount( region ); return ehcacheStats.getRegionCacheTargetMaxInMemoryCount( region );
} }
@ -377,6 +418,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public int getRegionCacheTargetMaxTotalCount(String region) { public int getRegionCacheTargetMaxTotalCount(String region) {
return ehcacheStats.getRegionCacheTargetMaxTotalCount( region ); return ehcacheStats.getRegionCacheTargetMaxTotalCount( region );
} }
@ -384,6 +426,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getSessionCloseCount() { public long getSessionCloseCount() {
return hibernateStats.getSessionCloseCount(); return hibernateStats.getSessionCloseCount();
} }
@ -391,6 +434,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getSessionOpenCount() { public long getSessionOpenCount() {
return hibernateStats.getSessionOpenCount(); return hibernateStats.getSessionOpenCount();
} }
@ -398,6 +442,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getSuccessfulTransactionCount() { public long getSuccessfulTransactionCount() {
return hibernateStats.getSuccessfulTransactionCount(); return hibernateStats.getSuccessfulTransactionCount();
} }
@ -405,6 +450,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public String[] getTerracottaHibernateCacheRegionNames() { public String[] getTerracottaHibernateCacheRegionNames() {
return ehcacheStats.getTerracottaHibernateCacheRegionNames(); return ehcacheStats.getTerracottaHibernateCacheRegionNames();
} }
@ -412,6 +458,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getTransactionCount() { public long getTransactionCount() {
return hibernateStats.getTransactionCount(); return hibernateStats.getTransactionCount();
} }
@ -419,6 +466,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public boolean isRegionCacheEnabled(String region) { public boolean isRegionCacheEnabled(String region) {
return ehcacheStats.isRegionCacheEnabled( region ); return ehcacheStats.isRegionCacheEnabled( region );
} }
@ -426,6 +474,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void setRegionCachesEnabled(boolean enabled) { public void setRegionCachesEnabled(boolean enabled) {
ehcacheStats.setRegionCachesEnabled( enabled ); ehcacheStats.setRegionCachesEnabled( enabled );
sendNotification( HibernateStats.CACHE_ENABLED, enabled ); sendNotification( HibernateStats.CACHE_ENABLED, enabled );
@ -434,6 +483,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void setRegionCacheEnabled(String region, boolean enabled) { public void setRegionCacheEnabled(String region, boolean enabled) {
ehcacheStats.setRegionCacheEnabled( region, enabled ); ehcacheStats.setRegionCacheEnabled( region, enabled );
sendNotification( HibernateStats.CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region ); sendNotification( HibernateStats.CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region );
@ -442,6 +492,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public boolean isRegionCacheLoggingEnabled(String region) { public boolean isRegionCacheLoggingEnabled(String region) {
return ehcacheStats.isRegionCacheLoggingEnabled( region ); return ehcacheStats.isRegionCacheLoggingEnabled( region );
} }
@ -449,6 +500,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public boolean isRegionCacheOrphanEvictionEnabled(String region) { public boolean isRegionCacheOrphanEvictionEnabled(String region) {
return ehcacheStats.isRegionCacheOrphanEvictionEnabled( region ); return ehcacheStats.isRegionCacheOrphanEvictionEnabled( region );
} }
@ -456,6 +508,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public boolean isRegionCachesEnabled() { public boolean isRegionCachesEnabled() {
return ehcacheStats.isRegionCachesEnabled(); return ehcacheStats.isRegionCachesEnabled();
} }
@ -463,6 +516,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public boolean isTerracottaHibernateCache(String region) { public boolean isTerracottaHibernateCache(String region) {
return ehcacheStats.isTerracottaHibernateCache( region ); return ehcacheStats.isTerracottaHibernateCache( region );
} }
@ -470,6 +524,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void setRegionCacheLoggingEnabled(String region, boolean loggingEnabled) { public void setRegionCacheLoggingEnabled(String region, boolean loggingEnabled) {
ehcacheStats.setRegionCacheLoggingEnabled( region, loggingEnabled ); ehcacheStats.setRegionCacheLoggingEnabled( region, loggingEnabled );
sendNotification( HibernateStats.CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region ); sendNotification( HibernateStats.CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region );
@ -478,6 +533,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void setRegionCacheMaxTTISeconds(String region, int maxTTISeconds) { public void setRegionCacheMaxTTISeconds(String region, int maxTTISeconds) {
ehcacheStats.setRegionCacheMaxTTISeconds( region, maxTTISeconds ); ehcacheStats.setRegionCacheMaxTTISeconds( region, maxTTISeconds );
sendNotification( HibernateStats.CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region ); sendNotification( HibernateStats.CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region );
@ -486,6 +542,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void setRegionCacheMaxTTLSeconds(String region, int maxTTLSeconds) { public void setRegionCacheMaxTTLSeconds(String region, int maxTTLSeconds) {
ehcacheStats.setRegionCacheMaxTTLSeconds( region, maxTTLSeconds ); ehcacheStats.setRegionCacheMaxTTLSeconds( region, maxTTLSeconds );
sendNotification( HibernateStats.CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region ); sendNotification( HibernateStats.CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region );
@ -494,6 +551,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void setRegionCacheTargetMaxInMemoryCount(String region, int targetMaxInMemoryCount) { public void setRegionCacheTargetMaxInMemoryCount(String region, int targetMaxInMemoryCount) {
ehcacheStats.setRegionCacheTargetMaxInMemoryCount( region, targetMaxInMemoryCount ); ehcacheStats.setRegionCacheTargetMaxInMemoryCount( region, targetMaxInMemoryCount );
sendNotification( HibernateStats.CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region ); sendNotification( HibernateStats.CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region );
@ -502,6 +560,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void setRegionCacheTargetMaxTotalCount(String region, int targetMaxTotalCount) { public void setRegionCacheTargetMaxTotalCount(String region, int targetMaxTotalCount) {
ehcacheStats.setRegionCacheTargetMaxTotalCount( region, targetMaxTotalCount ); ehcacheStats.setRegionCacheTargetMaxTotalCount( region, targetMaxTotalCount );
sendNotification( HibernateStats.CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region ); 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) * @see EhcacheStats#getNumberOfElementsInMemory(java.lang.String)
*/ */
@Override
public int getNumberOfElementsInMemory(String region) { public int getNumberOfElementsInMemory(String region) {
return ehcacheStats.getNumberOfElementsInMemory( region ); return ehcacheStats.getNumberOfElementsInMemory( region );
} }
@ -521,6 +581,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
* *
* @see EhcacheStats#getNumberOfElementsInMemory(java.lang.String) * @see EhcacheStats#getNumberOfElementsInMemory(java.lang.String)
*/ */
@Override
public int getNumberOfElementsOffHeap(String region) { public int getNumberOfElementsOffHeap(String region) {
return ehcacheStats.getNumberOfElementsOffHeap( region ); return ehcacheStats.getNumberOfElementsOffHeap( region );
} }
@ -530,6 +591,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
* *
* @see EhcacheStats#getNumberOfElementsOnDisk(java.lang.String) * @see EhcacheStats#getNumberOfElementsOnDisk(java.lang.String)
*/ */
@Override
public int getNumberOfElementsOnDisk(String region) { public int getNumberOfElementsOnDisk(String region) {
return ehcacheStats.getNumberOfElementsOnDisk( region ); return ehcacheStats.getNumberOfElementsOnDisk( region );
} }
@ -539,6 +601,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
* *
* @see EhcacheStats#getMaxGetTimeMillis() * @see EhcacheStats#getMaxGetTimeMillis()
*/ */
@Override
public long getMaxGetTimeMillis() { public long getMaxGetTimeMillis() {
return ehcacheStats.getMaxGetTimeMillis(); return ehcacheStats.getMaxGetTimeMillis();
} }
@ -548,6 +611,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
* *
* @see EhcacheStats#getMaxGetTimeMillis(java.lang.String) * @see EhcacheStats#getMaxGetTimeMillis(java.lang.String)
*/ */
@Override
public long getMaxGetTimeMillis(String cacheName) { public long getMaxGetTimeMillis(String cacheName) {
return ehcacheStats.getMaxGetTimeMillis( cacheName ); return ehcacheStats.getMaxGetTimeMillis( cacheName );
} }
@ -557,6 +621,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
* *
* @see EhcacheStats#getMinGetTimeMillis() * @see EhcacheStats#getMinGetTimeMillis()
*/ */
@Override
public long getMinGetTimeMillis() { public long getMinGetTimeMillis() {
return ehcacheStats.getMinGetTimeMillis(); return ehcacheStats.getMinGetTimeMillis();
} }
@ -566,6 +631,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
* *
* @see EhcacheStats#getMinGetTimeMillis(java.lang.String) * @see EhcacheStats#getMinGetTimeMillis(java.lang.String)
*/ */
@Override
public long getMinGetTimeMillis(String cacheName) { public long getMinGetTimeMillis(String cacheName) {
return ehcacheStats.getMinGetTimeMillis( cacheName ); return ehcacheStats.getMinGetTimeMillis( cacheName );
} }
@ -575,6 +641,7 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
* *
* @see EhcacheStats#getAverageGetTimeMillis(java.lang.String) * @see EhcacheStats#getAverageGetTimeMillis(java.lang.String)
*/ */
@Override
public float getAverageGetTimeMillis(String region) { public float getAverageGetTimeMillis(String region) {
return ehcacheStats.getAverageGetTimeMillis( region ); return ehcacheStats.getAverageGetTimeMillis( region );
} }
@ -588,10 +655,12 @@ public class EhcacheHibernate extends AbstractEmitterBean implements EhcacheHibe
} }
/** /**
* {@inheritDoc}
*
* @see AbstractEmitterBean#getNotificationInfo() * @see AbstractEmitterBean#getNotificationInfo()
*/ */
@Override @Override
public MBeanNotificationInfo[] getNotificationInfo() { public MBeanNotificationInfo[] getNotificationInfo() {
return new MBeanNotificationInfo[] {NOTIFICATION_INFO}; return new MBeanNotificationInfo[] { NOTIFICATION_INFO };
} }
} }

View File

@ -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 * 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 * is used
* *
* @param manager * @param manager the {@link CacheManager} to register the MBean for
* @param properties * @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; public void registerMBeanForCacheManager(CacheManager manager, Properties properties) throws Exception;
/** /**
* Enable hibernate statistics in the mbean. * Enable hibernate statistics in the mbean.
* *
* @param sessionFactory * @param sessionFactory the {@link SessionFactory} to enable stats for
*/ */
public void enableHibernateStatisticsSupport(SessionFactory sessionFactory); public void enableHibernateStatisticsSupport(SessionFactory sessionFactory);

View File

@ -65,9 +65,10 @@ public class EhcacheHibernateMBeanRegistrationImpl
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public synchronized void registerMBeanForCacheManager(final CacheManager manager, final Properties properties) public synchronized void registerMBeanForCacheManager(final CacheManager manager, final Properties properties)
throws Exception { throws Exception {
String sessionFactoryName = properties.getProperty( Environment.SESSION_FACTORY_NAME ); final String sessionFactoryName = properties.getProperty( Environment.SESSION_FACTORY_NAME );
String name = null; String name = null;
if ( sessionFactoryName == null ) { if ( sessionFactoryName == null ) {
name = manager.getName(); name = manager.getName();
@ -91,7 +92,7 @@ public class EhcacheHibernateMBeanRegistrationImpl
} }
try { try {
// register the CacheManager MBean // register the CacheManager MBean
MBeanServer mBeanServer = getMBeanServer(); final MBeanServer mBeanServer = getMBeanServer();
cacheManagerObjectName = EhcacheHibernateMbeanNames.getCacheManagerObjectName( cacheManagerObjectName = EhcacheHibernateMbeanNames.getCacheManagerObjectName(
cacheManagerClusterUUID, cacheManagerClusterUUID,
registeredCacheManagerName registeredCacheManagerName
@ -123,6 +124,7 @@ public class EhcacheHibernateMBeanRegistrationImpl
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void enableHibernateStatisticsSupport(SessionFactory sessionFactory) { public void enableHibernateStatisticsSupport(SessionFactory sessionFactory) {
ehcacheHibernate.enableHibernateStatistics( sessionFactory ); ehcacheHibernate.enableHibernateStatistics( sessionFactory );
} }
@ -130,6 +132,7 @@ public class EhcacheHibernateMBeanRegistrationImpl
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public synchronized void dispose() throws CacheException { public synchronized void dispose() throws CacheException {
if ( status == Status.STATUS_SHUTDOWN ) { if ( status == Status.STATUS_SHUTDOWN ) {
return; return;
@ -152,27 +155,39 @@ public class EhcacheHibernateMBeanRegistrationImpl
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public synchronized Status getStatus() { public synchronized Status getStatus() {
return status; return status;
} }
/** /**
*
* {@inheritDoc}
*
* No-op in this case * No-op in this case
*/ */
@Override
public void init() throws CacheException { public void init() throws CacheException {
// no-op // no-op
} }
/** /**
*
* {@inheritDoc}
*
* No-op in this case * No-op in this case
*/ */
@Override
public void notifyCacheAdded(String cacheName) { public void notifyCacheAdded(String cacheName) {
// no-op // no-op
} }
/** /**
* {@inheritDoc}
*
* No-op in this case * No-op in this case
*/ */
@Override
public void notifyCacheRemoved(String cacheName) { public void notifyCacheRemoved(String cacheName) {
// no-op // no-op
} }

View File

@ -49,7 +49,7 @@ public abstract class EhcacheHibernateMbeanNames {
/** /**
* Filter out invalid ObjectName characters from s. * Filter out invalid ObjectName characters from s.
* *
* @param s * @param s the name to be filtered out
* *
* @return A valid JMX ObjectName attribute value. * @return A valid JMX ObjectName attribute value.
*/ */
@ -60,15 +60,16 @@ public abstract class EhcacheHibernateMbeanNames {
/** /**
* Returns an ObjectName for the passed name * 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 * @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) public static ObjectName getCacheManagerObjectName(String cacheManagerClusterUUID, String name)
throws MalformedObjectNameException { throws MalformedObjectNameException {
ObjectName objectName = new ObjectName( final ObjectName objectName = new ObjectName(
GROUP_ID + ":type=" + EHCACHE_HIBERNATE_TYPE + ",name=" + mbeanSafe( name ) GROUP_ID + ":type=" + EHCACHE_HIBERNATE_TYPE + ",name=" + mbeanSafe( name )
+ getBeanNameSuffix( cacheManagerClusterUUID ) + getBeanNameSuffix( cacheManagerClusterUUID )
); );

View File

@ -63,7 +63,8 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* Constructor accepting the backing {@link CacheManager} * 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 { public EhcacheStatsImpl(CacheManager manager) throws NotCompliantMBeanException {
super( EhcacheStats.class ); super( EhcacheStats.class );
@ -74,6 +75,7 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public boolean isStatisticsEnabled() { public boolean isStatisticsEnabled() {
return false; return false;
} }
@ -81,6 +83,7 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void clearStats() { public void clearStats() {
sampledCacheManager.clearStatistics(); sampledCacheManager.clearStatistics();
statsSince = System.currentTimeMillis(); statsSince = System.currentTimeMillis();
@ -89,6 +92,7 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void disableStats() { public void disableStats() {
setStatisticsEnabled( false ); setStatisticsEnabled( false );
} }
@ -96,6 +100,7 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void enableStats() { public void enableStats() {
setStatisticsEnabled( true ); setStatisticsEnabled( true );
} }
@ -103,8 +108,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void flushRegionCache(String region) { public void flushRegionCache(String region) {
Cache cache = this.cacheManager.getCache( region ); final Cache cache = this.cacheManager.getCache( region );
if ( cache != null ) { if ( cache != null ) {
cache.flush(); cache.flush();
} }
@ -113,9 +119,10 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void flushRegionCaches() { public void flushRegionCaches() {
for ( String name : cacheManager.getCacheNames() ) { for ( String name : cacheManager.getCacheNames() ) {
Cache cache = this.cacheManager.getCache( name ); final Cache cache = this.cacheManager.getCache( name );
if ( cache != null ) { if ( cache != null ) {
cache.flush(); cache.flush();
} }
@ -126,6 +133,7 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public String generateActiveConfigDeclaration() { public String generateActiveConfigDeclaration() {
return this.cacheManager.getActiveConfigurationText(); return this.cacheManager.getActiveConfigurationText();
} }
@ -133,6 +141,7 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public String generateActiveConfigDeclaration(String region) { public String generateActiveConfigDeclaration(String region) {
return this.cacheManager.getActiveConfigurationText( region ); return this.cacheManager.getActiveConfigurationText( region );
} }
@ -140,10 +149,11 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getCacheHitCount() { public long getCacheHitCount() {
long count = 0; long count = 0;
for ( String name : cacheManager.getCacheNames() ) { for ( String name : cacheManager.getCacheNames() ) {
Cache cache = cacheManager.getCache( name ); final Cache cache = cacheManager.getCache( name );
if ( cache != null ) { if ( cache != null ) {
count += cache.getLiveCacheStatistics().getCacheHitCount(); count += cache.getLiveCacheStatistics().getCacheHitCount();
} }
@ -154,19 +164,21 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public double getCacheHitRate() { public double getCacheHitRate() {
long now = System.currentTimeMillis(); final long now = System.currentTimeMillis();
double deltaSecs = (double) (now - statsSince) / MILLIS_PER_SECOND; final double deltaSecs = (double) (now - statsSince) / MILLIS_PER_SECOND;
return getCacheHitCount() / deltaSecs; return getCacheHitCount() / deltaSecs;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getCacheHitSample() { public long getCacheHitSample() {
long count = 0; long count = 0;
for ( String name : cacheManager.getCacheNames() ) { for ( String name : cacheManager.getCacheNames() ) {
Cache cache = cacheManager.getCache( name ); final Cache cache = cacheManager.getCache( name );
if ( cache != null ) { if ( cache != null ) {
count += cache.getSampledCacheStatistics().getCacheHitMostRecentSample(); count += cache.getSampledCacheStatistics().getCacheHitMostRecentSample();
} }
@ -177,10 +189,11 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getCacheMissCount() { public long getCacheMissCount() {
long count = 0; long count = 0;
for ( String name : cacheManager.getCacheNames() ) { for ( String name : cacheManager.getCacheNames() ) {
Cache cache = cacheManager.getCache( name ); final Cache cache = cacheManager.getCache( name );
if ( cache != null ) { if ( cache != null ) {
count += cache.getLiveCacheStatistics().getCacheMissCount(); count += cache.getLiveCacheStatistics().getCacheMissCount();
} }
@ -191,19 +204,21 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public double getCacheMissRate() { public double getCacheMissRate() {
long now = System.currentTimeMillis(); final long now = System.currentTimeMillis();
double deltaSecs = (double) (now - statsSince) / MILLIS_PER_SECOND; final double deltaSecs = (double) (now - statsSince) / MILLIS_PER_SECOND;
return getCacheMissCount() / deltaSecs; return getCacheMissCount() / deltaSecs;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getCacheMissSample() { public long getCacheMissSample() {
long count = 0; long count = 0;
for ( String name : cacheManager.getCacheNames() ) { for ( String name : cacheManager.getCacheNames() ) {
Cache cache = cacheManager.getCache( name ); final Cache cache = cacheManager.getCache( name );
if ( cache != null ) { if ( cache != null ) {
count += cache.getSampledCacheStatistics().getCacheMissMostRecentSample(); count += cache.getSampledCacheStatistics().getCacheMissMostRecentSample();
} }
@ -214,10 +229,11 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getCachePutCount() { public long getCachePutCount() {
long count = 0; long count = 0;
for ( String name : cacheManager.getCacheNames() ) { for ( String name : cacheManager.getCacheNames() ) {
Cache cache = cacheManager.getCache( name ); final Cache cache = cacheManager.getCache( name );
if ( cache != null ) { if ( cache != null ) {
count += cache.getLiveCacheStatistics().getPutCount(); count += cache.getLiveCacheStatistics().getPutCount();
} }
@ -228,19 +244,21 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public double getCachePutRate() { public double getCachePutRate() {
long now = System.currentTimeMillis(); final long now = System.currentTimeMillis();
double deltaSecs = (double) (now - statsSince) / MILLIS_PER_SECOND; final double deltaSecs = (double) (now - statsSince) / MILLIS_PER_SECOND;
return getCachePutCount() / deltaSecs; return getCachePutCount() / deltaSecs;
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getCachePutSample() { public long getCachePutSample() {
long count = 0; long count = 0;
for ( String name : cacheManager.getCacheNames() ) { for ( String name : cacheManager.getCacheNames() ) {
Cache cache = cacheManager.getCache( name ); final Cache cache = cacheManager.getCache( name );
if ( cache != null ) { if ( cache != null ) {
count += cache.getSampledCacheStatistics().getCacheElementPutMostRecentSample(); count += cache.getSampledCacheStatistics().getCacheElementPutMostRecentSample();
} }
@ -251,6 +269,7 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public String getOriginalConfigDeclaration() { public String getOriginalConfigDeclaration() {
return this.cacheManager.getOriginalConfigurationText(); return this.cacheManager.getOriginalConfigurationText();
} }
@ -258,6 +277,7 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public String getOriginalConfigDeclaration(String region) { public String getOriginalConfigDeclaration(String region) {
return this.cacheManager.getOriginalConfigurationText( region ); return this.cacheManager.getOriginalConfigurationText( region );
} }
@ -265,8 +285,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public Map<String, Map<String, Object>> getRegionCacheAttributes() { public Map<String, Map<String, Object>> getRegionCacheAttributes() {
Map<String, Map<String, Object>> result = new HashMap<String, Map<String, Object>>(); final Map<String, Map<String, Object>> result = new HashMap<String, Map<String, Object>>();
for ( String regionName : this.cacheManager.getCacheNames() ) { for ( String regionName : this.cacheManager.getCacheNames() ) {
result.put( regionName, getRegionCacheAttributes( regionName ) ); result.put( regionName, getRegionCacheAttributes( regionName ) );
} }
@ -276,8 +297,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public Map<String, Object> getRegionCacheAttributes(String regionName) { public Map<String, Object> getRegionCacheAttributes(String regionName) {
Map<String, Object> result = new HashMap<String, Object>(); final Map<String, Object> result = new HashMap<String, Object>();
result.put( "Enabled", isRegionCacheEnabled( regionName ) ); result.put( "Enabled", isRegionCacheEnabled( regionName ) );
result.put( "LoggingEnabled", isRegionCacheLoggingEnabled( regionName ) ); result.put( "LoggingEnabled", isRegionCacheLoggingEnabled( regionName ) );
result.put( "MaxTTISeconds", getRegionCacheMaxTTISeconds( regionName ) ); result.put( "MaxTTISeconds", getRegionCacheMaxTTISeconds( regionName ) );
@ -292,8 +314,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public int getRegionCacheMaxTTISeconds(String region) { public int getRegionCacheMaxTTISeconds(String region) {
Cache cache = cacheManager.getCache( region ); final Cache cache = cacheManager.getCache( region );
if ( cache != null ) { if ( cache != null ) {
return (int) cache.getCacheConfiguration().getTimeToIdleSeconds(); return (int) cache.getCacheConfiguration().getTimeToIdleSeconds();
} }
@ -305,8 +328,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public int getRegionCacheMaxTTLSeconds(String region) { public int getRegionCacheMaxTTLSeconds(String region) {
Cache cache = cacheManager.getCache( region ); final Cache cache = cacheManager.getCache( region );
if ( cache != null ) { if ( cache != null ) {
return (int) cache.getCacheConfiguration().getTimeToLiveSeconds(); return (int) cache.getCacheConfiguration().getTimeToLiveSeconds();
} }
@ -318,8 +342,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public int getRegionCacheOrphanEvictionPeriod(String region) { public int getRegionCacheOrphanEvictionPeriod(String region) {
Cache cache = this.cacheManager.getCache( region ); final Cache cache = this.cacheManager.getCache( region );
if ( cache != null && cache.isTerracottaClustered() ) { if ( cache != null && cache.isTerracottaClustered() ) {
return cache.getCacheConfiguration().getTerracottaConfiguration().getOrphanEvictionPeriod(); return cache.getCacheConfiguration().getTerracottaConfiguration().getOrphanEvictionPeriod();
} }
@ -331,10 +356,11 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public Map<String, int[]> getRegionCacheSamples() { public Map<String, int[]> getRegionCacheSamples() {
Map<String, int[]> rv = new HashMap<String, int[]>(); final Map<String, int[]> rv = new HashMap<String, int[]>();
for ( String name : cacheManager.getCacheNames() ) { for ( String name : cacheManager.getCacheNames() ) {
Cache cache = cacheManager.getCache( name ); final Cache cache = cacheManager.getCache( name );
if ( cache != null ) { if ( cache != null ) {
rv.put( rv.put(
name, new int[] { name, new int[] {
@ -352,8 +378,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public int getRegionCacheTargetMaxInMemoryCount(String region) { public int getRegionCacheTargetMaxInMemoryCount(String region) {
Cache cache = cacheManager.getCache( region ); final Cache cache = cacheManager.getCache( region );
if ( cache != null ) { if ( cache != null ) {
return cache.getCacheConfiguration().getMaxElementsInMemory(); return cache.getCacheConfiguration().getMaxElementsInMemory();
} }
@ -365,8 +392,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public int getRegionCacheTargetMaxTotalCount(String region) { public int getRegionCacheTargetMaxTotalCount(String region) {
Cache cache = cacheManager.getCache( region ); final Cache cache = cacheManager.getCache( region );
if ( cache != null ) { if ( cache != null ) {
return cache.getCacheConfiguration().getMaxElementsOnDisk(); return cache.getCacheConfiguration().getMaxElementsOnDisk();
} }
@ -378,10 +406,11 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public String[] getTerracottaHibernateCacheRegionNames() { public String[] getTerracottaHibernateCacheRegionNames() {
ArrayList<String> rv = new ArrayList<String>(); final ArrayList<String> rv = new ArrayList<String>();
for ( String name : cacheManager.getCacheNames() ) { for ( String name : cacheManager.getCacheNames() ) {
Cache cache = cacheManager.getCache( name ); final Cache cache = cacheManager.getCache( name );
if ( cache != null ) { if ( cache != null ) {
if ( cache.getCacheConfiguration().isTerracottaClustered() ) { if ( cache.getCacheConfiguration().isTerracottaClustered() ) {
rv.add( name ); rv.add( name );
@ -394,8 +423,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public boolean isRegionCacheEnabled(String region) { public boolean isRegionCacheEnabled(String region) {
Cache cache = this.cacheManager.getCache( region ); final Cache cache = this.cacheManager.getCache( region );
if ( cache != null ) { if ( cache != null ) {
return !cache.isDisabled(); return !cache.isDisabled();
} }
@ -407,8 +437,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void setRegionCacheEnabled(String region, boolean enabled) { public void setRegionCacheEnabled(String region, boolean enabled) {
Cache cache = this.cacheManager.getCache( region ); final Cache cache = this.cacheManager.getCache( region );
if ( cache != null ) { if ( cache != null ) {
cache.setDisabled( !enabled ); cache.setDisabled( !enabled );
} }
@ -418,9 +449,10 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public boolean isRegionCachesEnabled() { public boolean isRegionCachesEnabled() {
for ( String name : this.cacheManager.getCacheNames() ) { for ( String name : this.cacheManager.getCacheNames() ) {
Cache cache = this.cacheManager.getCache( name ); final Cache cache = this.cacheManager.getCache( name );
if ( cache != null ) { if ( cache != null ) {
if ( cache.isDisabled() ) { if ( cache.isDisabled() ) {
return false; return false;
@ -431,11 +463,13 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
} }
/** /**
* {@inheritDoc}
* @see EhcacheStats#setRegionCachesEnabled(boolean) * @see EhcacheStats#setRegionCachesEnabled(boolean)
*/ */
@Override
public void setRegionCachesEnabled(final boolean flag) { public void setRegionCachesEnabled(final boolean flag) {
for ( String name : this.cacheManager.getCacheNames() ) { for ( String name : this.cacheManager.getCacheNames() ) {
Cache cache = this.cacheManager.getCache( name ); final Cache cache = this.cacheManager.getCache( name );
if ( cache != null ) { if ( cache != null ) {
cache.setDisabled( !flag ); cache.setDisabled( !flag );
} }
@ -446,8 +480,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public boolean isRegionCacheLoggingEnabled(String region) { public boolean isRegionCacheLoggingEnabled(String region) {
Cache cache = this.cacheManager.getCache( region ); final Cache cache = this.cacheManager.getCache( region );
if ( cache != null ) { if ( cache != null ) {
return cache.getCacheConfiguration().getLogging(); return cache.getCacheConfiguration().getLogging();
} }
@ -459,8 +494,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public boolean isRegionCacheOrphanEvictionEnabled(String region) { public boolean isRegionCacheOrphanEvictionEnabled(String region) {
Cache cache = this.cacheManager.getCache( region ); final Cache cache = this.cacheManager.getCache( region );
if ( cache != null && cache.isTerracottaClustered() ) { if ( cache != null && cache.isTerracottaClustered() ) {
return cache.getCacheConfiguration().getTerracottaConfiguration().getOrphanEviction(); return cache.getCacheConfiguration().getTerracottaConfiguration().getOrphanEviction();
} }
@ -472,8 +508,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public boolean isTerracottaHibernateCache(String region) { public boolean isTerracottaHibernateCache(String region) {
Cache cache = cacheManager.getCache( region ); final Cache cache = cacheManager.getCache( region );
if ( cache != null ) { if ( cache != null ) {
return cache.getCacheConfiguration().isTerracottaClustered(); return cache.getCacheConfiguration().isTerracottaClustered();
} }
@ -485,8 +522,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void setRegionCacheLoggingEnabled(String region, boolean loggingEnabled) { public void setRegionCacheLoggingEnabled(String region, boolean loggingEnabled) {
Cache cache = this.cacheManager.getCache( region ); final Cache cache = this.cacheManager.getCache( region );
if ( cache != null ) { if ( cache != null ) {
cache.getCacheConfiguration().setLogging( loggingEnabled ); cache.getCacheConfiguration().setLogging( loggingEnabled );
sendNotification( CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region ); sendNotification( CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region );
@ -496,8 +534,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void setRegionCacheMaxTTISeconds(String region, int maxTTISeconds) { public void setRegionCacheMaxTTISeconds(String region, int maxTTISeconds) {
Cache cache = this.cacheManager.getCache( region ); final Cache cache = this.cacheManager.getCache( region );
if ( cache != null ) { if ( cache != null ) {
cache.getCacheConfiguration().setTimeToIdleSeconds( maxTTISeconds ); cache.getCacheConfiguration().setTimeToIdleSeconds( maxTTISeconds );
sendNotification( CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region ); sendNotification( CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region );
@ -507,8 +546,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void setRegionCacheMaxTTLSeconds(String region, int maxTTLSeconds) { public void setRegionCacheMaxTTLSeconds(String region, int maxTTLSeconds) {
Cache cache = this.cacheManager.getCache( region ); final Cache cache = this.cacheManager.getCache( region );
if ( cache != null ) { if ( cache != null ) {
cache.getCacheConfiguration().setTimeToLiveSeconds( maxTTLSeconds ); cache.getCacheConfiguration().setTimeToLiveSeconds( maxTTLSeconds );
sendNotification( CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region ); sendNotification( CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region );
@ -518,8 +558,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void setRegionCacheTargetMaxInMemoryCount(String region, int targetMaxInMemoryCount) { public void setRegionCacheTargetMaxInMemoryCount(String region, int targetMaxInMemoryCount) {
Cache cache = this.cacheManager.getCache( region ); final Cache cache = this.cacheManager.getCache( region );
if ( cache != null ) { if ( cache != null ) {
cache.getCacheConfiguration().setMaxElementsInMemory( targetMaxInMemoryCount ); cache.getCacheConfiguration().setMaxElementsInMemory( targetMaxInMemoryCount );
sendNotification( CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region ); sendNotification( CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region );
@ -529,8 +570,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void setRegionCacheTargetMaxTotalCount(String region, int targetMaxTotalCount) { public void setRegionCacheTargetMaxTotalCount(String region, int targetMaxTotalCount) {
Cache cache = this.cacheManager.getCache( region ); final Cache cache = this.cacheManager.getCache( region );
if ( cache != null ) { if ( cache != null ) {
cache.getCacheConfiguration().setMaxElementsOnDisk( targetMaxTotalCount ); cache.getCacheConfiguration().setMaxElementsOnDisk( targetMaxTotalCount );
sendNotification( CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region ); sendNotification( CACHE_REGION_CHANGED, getRegionCacheAttributes( region ), region );
@ -542,8 +584,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
* *
* @see EhcacheStats#getNumberOfElementsInMemory(java.lang.String) * @see EhcacheStats#getNumberOfElementsInMemory(java.lang.String)
*/ */
@Override
public int getNumberOfElementsInMemory(String region) { public int getNumberOfElementsInMemory(String region) {
Cache cache = this.cacheManager.getCache( region ); final Cache cache = this.cacheManager.getCache( region );
if ( cache != null ) { if ( cache != null ) {
return (int) cache.getMemoryStoreSize(); return (int) cache.getMemoryStoreSize();
} }
@ -557,8 +600,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
* *
* @see EhcacheStats#getNumberOfElementsOffHeap(java.lang.String) * @see EhcacheStats#getNumberOfElementsOffHeap(java.lang.String)
*/ */
@Override
public int getNumberOfElementsOffHeap(String region) { public int getNumberOfElementsOffHeap(String region) {
Cache cache = this.cacheManager.getCache( region ); final Cache cache = this.cacheManager.getCache( region );
if ( cache != null ) { if ( cache != null ) {
return (int) cache.getOffHeapStoreSize(); return (int) cache.getOffHeapStoreSize();
} }
@ -572,8 +616,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
* *
* @see EhcacheStats#getNumberOfElementsOnDisk(java.lang.String) * @see EhcacheStats#getNumberOfElementsOnDisk(java.lang.String)
*/ */
@Override
public int getNumberOfElementsOnDisk(String region) { public int getNumberOfElementsOnDisk(String region) {
Cache cache = this.cacheManager.getCache( region ); final Cache cache = this.cacheManager.getCache( region );
if ( cache != null ) { if ( cache != null ) {
return cache.getDiskStoreSize(); return cache.getDiskStoreSize();
} }
@ -585,9 +630,10 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public void setStatisticsEnabled(boolean flag) { public void setStatisticsEnabled(boolean flag) {
for ( String cacheName : cacheManager.getCacheNames() ) { for ( String cacheName : cacheManager.getCacheNames() ) {
Cache cache = cacheManager.getCache( cacheName ); final Cache cache = cacheManager.getCache( cacheName );
if ( cache != null ) { if ( cache != null ) {
cache.setStatisticsEnabled( flag ); cache.setStatisticsEnabled( flag );
} }
@ -601,10 +647,11 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getMaxGetTimeMillis() { public long getMaxGetTimeMillis() {
long rv = 0; long rv = 0;
for ( String cacheName : cacheManager.getCacheNames() ) { for ( String cacheName : cacheManager.getCacheNames() ) {
Cache cache = cacheManager.getCache( cacheName ); final Cache cache = cacheManager.getCache( cacheName );
if ( cache != null ) { if ( cache != null ) {
rv = Math.max( rv, cache.getLiveCacheStatistics().getMaxGetTimeMillis() ); rv = Math.max( rv, cache.getLiveCacheStatistics().getMaxGetTimeMillis() );
} }
@ -615,10 +662,11 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public long getMinGetTimeMillis() { public long getMinGetTimeMillis() {
long rv = 0; long rv = 0;
for ( String cacheName : cacheManager.getCacheNames() ) { for ( String cacheName : cacheManager.getCacheNames() ) {
Cache cache = cacheManager.getCache( cacheName ); final Cache cache = cacheManager.getCache( cacheName );
if ( cache != null ) { if ( cache != null ) {
rv = Math.max( rv, cache.getLiveCacheStatistics().getMinGetTimeMillis() ); rv = Math.max( rv, cache.getLiveCacheStatistics().getMinGetTimeMillis() );
} }
@ -631,8 +679,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
* *
* @see EhcacheStats#getMaxGetTimeMillis(java.lang.String) * @see EhcacheStats#getMaxGetTimeMillis(java.lang.String)
*/ */
@Override
public long getMaxGetTimeMillis(String cacheName) { public long getMaxGetTimeMillis(String cacheName) {
Cache cache = cacheManager.getCache( cacheName ); final Cache cache = cacheManager.getCache( cacheName );
if ( cache != null ) { if ( cache != null ) {
return cache.getLiveCacheStatistics().getMaxGetTimeMillis(); return cache.getLiveCacheStatistics().getMaxGetTimeMillis();
} }
@ -646,8 +695,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
* *
* @see EhcacheStats#getMinGetTimeMillis(java.lang.String) * @see EhcacheStats#getMinGetTimeMillis(java.lang.String)
*/ */
@Override
public long getMinGetTimeMillis(String cacheName) { public long getMinGetTimeMillis(String cacheName) {
Cache cache = cacheManager.getCache( cacheName ); final Cache cache = cacheManager.getCache( cacheName );
if ( cache != null ) { if ( cache != null ) {
return cache.getLiveCacheStatistics().getMinGetTimeMillis(); return cache.getLiveCacheStatistics().getMinGetTimeMillis();
} }
@ -661,8 +711,9 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
* *
* @see EhcacheStats#getAverageGetTimeMillis(java.lang.String) * @see EhcacheStats#getAverageGetTimeMillis(java.lang.String)
*/ */
@Override
public float getAverageGetTimeMillis(String region) { public float getAverageGetTimeMillis(String region) {
Cache cache = this.cacheManager.getCache( region ); final Cache cache = this.cacheManager.getCache( region );
if ( cache != null ) { if ( cache != null ) {
return cache.getLiveCacheStatistics().getAverageGetTimeMillis(); return cache.getLiveCacheStatistics().getAverageGetTimeMillis();
} }
@ -680,6 +731,7 @@ public class EhcacheStatsImpl extends AbstractEmitterBean implements EhcacheStat
} }
/** /**
* {@inheritDoc}
* @see AbstractEmitterBean#getNotificationInfo() * @see AbstractEmitterBean#getNotificationInfo()
*/ */
@Override @Override

View File

@ -120,7 +120,8 @@ public class EntityStats implements Serializable {
protected long optimisticFailureCount; protected long optimisticFailureCount;
/** /**
* @param name * Constructor only naming the stat
* @param name the name of the entity
*/ */
public EntityStats(String name) { public EntityStats(String name) {
this.name = name; this.name = name;
@ -128,8 +129,9 @@ public class EntityStats implements Serializable {
} }
/** /**
* @param name * Constructor naming the stat and sourcing stats
* @param src * @param name the name of the entity
* @param src its source for the stats to expose
*/ */
public EntityStats(String name, EntityStatistics src) { public EntityStats(String name, EntityStatistics src) {
this( name ); 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) { public EntityStats(final CompositeData cData) {
int i = 0; 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) { public void add(EntityStats stats) {
loadCount += stats.getLoadCount(); loadCount += stats.getLoadCount();
@ -185,7 +189,7 @@ public class EntityStats implements Serializable {
} }
/** /**
* toString * {@inheritDoc}
*/ */
@Override @Override
public String toString() { 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() { public String getName() {
return name; return name;
} }
/** /**
* getShortName * The short name of the entity those stats are about
* @return the shortName of the entity
*/ */
public String getShortName() { public String getShortName() {
return shortName; return shortName;
} }
/** /**
* getLoadCount * Amount of load ops on the entity
* @return the load count
*/ */
public long getLoadCount() { public long getLoadCount() {
return loadCount; return loadCount;
} }
/** /**
* getUpdateCount * Amount of update ops on the entity
* @return the update count
*/ */
public long getUpdateCount() { public long getUpdateCount() {
return updateCount; return updateCount;
} }
/** /**
* getInsertCount * Amount of insert ops on the entity
* @return the insert count
*/ */
public long getInsertCount() { public long getInsertCount() {
return insertCount; return insertCount;
} }
/** /**
* getDeleteCount * Amount of delete ops on the entity
* @return the delete count
*/ */
public long getDeleteCount() { public long getDeleteCount() {
return deleteCount; return deleteCount;
} }
/** /**
* getFetchCount * Amount of fetch ops on the entity
* @return the fetch count
*/ */
public long getFetchCount() { public long getFetchCount() {
return fetchCount; return fetchCount;
} }
/** /**
* getOptimisticFailureCount * Amount of optimistic failures on the entity
* @return the optimistic failure count
*/ */
public long getOptimisticFailureCount() { public long getOptimisticFailureCount() {
return optimisticFailureCount; return optimisticFailureCount;
} }
/** /**
* toCompositeData * Creates a CompositeData instance of this instance
* @return the compositeData representation of this instance
*/ */
public CompositeData toCompositeData() { public CompositeData toCompositeData() {
try { try {
@ -268,14 +281,17 @@ public class EntityStats implements Serializable {
} }
/** /**
* newTabularDataInstance * Creates a new TabularData
* @return a new TabularData instance
*/ */
public static TabularData newTabularDataInstance() { public static TabularData newTabularDataInstance() {
return new TabularDataSupport( TABULAR_TYPE ); 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) { public static EntityStats[] fromTabularData(final TabularData tabularData) {
final List<EntityStats> countList = new ArrayList( tabularData.size() ); final List<EntityStats> countList = new ArrayList( tabularData.size() );

View File

@ -59,9 +59,9 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
/** /**
* Constructor accepting the backing {@link SessionFactory} * 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 { public HibernateStatsImpl(SessionFactory sessionFactory) throws NotCompliantMBeanException {
super( HibernateStats.class ); super( HibernateStats.class );
@ -80,6 +80,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
* *
* @see HibernateStats#clearStats() * @see HibernateStats#clearStats()
*/ */
@Override
public void clearStats() { public void clearStats() {
getStatistics().clear(); getStatistics().clear();
sendNotification( CACHE_STATISTICS_RESET ); sendNotification( CACHE_STATISTICS_RESET );
@ -90,6 +91,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
* *
* @see HibernateStats#disableStats() * @see HibernateStats#disableStats()
*/ */
@Override
public void disableStats() { public void disableStats() {
setStatisticsEnabled( false ); setStatisticsEnabled( false );
} }
@ -99,6 +101,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
* *
* @see HibernateStats#enableStats() * @see HibernateStats#enableStats()
*/ */
@Override
public void enableStats() { public void enableStats() {
setStatisticsEnabled( true ); setStatisticsEnabled( true );
} }
@ -108,6 +111,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
* *
* @see HibernateStats#getCloseStatementCount() * @see HibernateStats#getCloseStatementCount()
*/ */
@Override
public long getCloseStatementCount() { public long getCloseStatementCount() {
return getStatistics().getCloseStatementCount(); return getStatistics().getCloseStatementCount();
} }
@ -117,13 +121,18 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
* *
* @see HibernateStats#getConnectCount() * @see HibernateStats#getConnectCount()
*/ */
@Override
public long getConnectCount() { public long getConnectCount() {
return getStatistics().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() { public long getDBSQLExecutionSample() {
throw new UnsupportedOperationException( "Use getQueryExecutionCount() instead" ); throw new UnsupportedOperationException( "Use getQueryExecutionCount() instead" );
} }
@ -133,6 +142,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
* *
* @see HibernateStats#getFlushCount() * @see HibernateStats#getFlushCount()
*/ */
@Override
public long getFlushCount() { public long getFlushCount() {
return getStatistics().getFlushCount(); return getStatistics().getFlushCount();
} }
@ -142,6 +152,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
* *
* @see HibernateStats#getOptimisticFailureCount() * @see HibernateStats#getOptimisticFailureCount()
*/ */
@Override
public long getOptimisticFailureCount() { public long getOptimisticFailureCount() {
return getStatistics().getOptimisticFailureCount(); return getStatistics().getOptimisticFailureCount();
} }
@ -151,6 +162,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
* *
* @see HibernateStats#getPrepareStatementCount() * @see HibernateStats#getPrepareStatementCount()
*/ */
@Override
public long getPrepareStatementCount() { public long getPrepareStatementCount() {
return getStatistics().getPrepareStatementCount(); return getStatistics().getPrepareStatementCount();
} }
@ -160,6 +172,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
* *
* @see HibernateStats#getQueryExecutionCount() * @see HibernateStats#getQueryExecutionCount()
*/ */
@Override
public long getQueryExecutionCount() { public long getQueryExecutionCount() {
return getStatistics().getQueryExecutionCount(); return getStatistics().getQueryExecutionCount();
} }
@ -169,10 +182,11 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
* *
* @see HibernateStats#getQueryExecutionRate() * @see HibernateStats#getQueryExecutionRate()
*/ */
@Override
public double getQueryExecutionRate() { public double getQueryExecutionRate() {
long startTime = getStatistics().getStartTime(); final long startTime = getStatistics().getStartTime();
long now = System.currentTimeMillis(); final long now = System.currentTimeMillis();
double deltaSecs = (now - startTime) / MILLIS_PER_SECOND; final double deltaSecs = (now - startTime) / MILLIS_PER_SECOND;
return getQueryExecutionCount() / deltaSecs; return getQueryExecutionCount() / deltaSecs;
} }
@ -181,6 +195,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
* *
* @see HibernateStats#getQueryExecutionSample() * @see HibernateStats#getQueryExecutionSample()
*/ */
@Override
public long getQueryExecutionSample() { public long getQueryExecutionSample() {
throw new UnsupportedOperationException( "TODO: need to impl. rates for query execution" ); 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() * @see HibernateStats#getSessionCloseCount()
*/ */
@Override
public long getSessionCloseCount() { public long getSessionCloseCount() {
return getStatistics().getSessionCloseCount(); return getStatistics().getSessionCloseCount();
} }
@ -199,6 +215,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
* *
* @see HibernateStats#getSessionOpenCount() * @see HibernateStats#getSessionOpenCount()
*/ */
@Override
public long getSessionOpenCount() { public long getSessionOpenCount() {
return getStatistics().getSessionOpenCount(); return getStatistics().getSessionOpenCount();
} }
@ -208,6 +225,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
* *
* @see HibernateStats#getSuccessfulTransactionCount() * @see HibernateStats#getSuccessfulTransactionCount()
*/ */
@Override
public long getSuccessfulTransactionCount() { public long getSuccessfulTransactionCount() {
return getStatistics().getSuccessfulTransactionCount(); return getStatistics().getSuccessfulTransactionCount();
} }
@ -217,6 +235,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
* *
* @see HibernateStats#getTransactionCount() * @see HibernateStats#getTransactionCount()
*/ */
@Override
public long getTransactionCount() { public long getTransactionCount() {
return getStatistics().getTransactionCount(); return getStatistics().getTransactionCount();
} }
@ -226,6 +245,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
* *
* @see HibernateStats#isStatisticsEnabled() * @see HibernateStats#isStatisticsEnabled()
*/ */
@Override
public boolean isStatisticsEnabled() { public boolean isStatisticsEnabled() {
return getStatistics().isStatisticsEnabled(); return getStatistics().isStatisticsEnabled();
} }
@ -235,6 +255,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
* *
* @see HibernateStats#setStatisticsEnabled(boolean) * @see HibernateStats#setStatisticsEnabled(boolean)
*/ */
@Override
public void setStatisticsEnabled(boolean flag) { public void setStatisticsEnabled(boolean flag) {
getStatistics().setStatisticsEnabled( flag ); getStatistics().setStatisticsEnabled( flag );
sendNotification( CACHE_STATISTICS_ENABLED, flag ); sendNotification( CACHE_STATISTICS_ENABLED, flag );
@ -245,14 +266,15 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
* *
* @see HibernateStats#getEntityStats() * @see HibernateStats#getEntityStats()
*/ */
@Override
public TabularData getEntityStats() { public TabularData getEntityStats() {
List<CompositeData> result = new ArrayList<CompositeData>(); final List<CompositeData> result = new ArrayList<CompositeData>();
Statistics statistics = getStatistics(); final Statistics statistics = getStatistics();
for ( String entity : statistics.getEntityNames() ) { 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() ); result.add( entityStats.toCompositeData() );
} }
TabularData td = EntityStats.newTabularDataInstance(); final TabularData td = EntityStats.newTabularDataInstance();
td.putAll( result.toArray( new CompositeData[result.size()] ) ); td.putAll( result.toArray( new CompositeData[result.size()] ) );
return td; return td;
} }
@ -262,17 +284,18 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
* *
* @see HibernateStats#getCollectionStats() * @see HibernateStats#getCollectionStats()
*/ */
@Override
public TabularData getCollectionStats() { public TabularData getCollectionStats() {
List<CompositeData> result = new ArrayList<CompositeData>(); final List<CompositeData> result = new ArrayList<CompositeData>();
Statistics statistics = getStatistics(); final Statistics statistics = getStatistics();
for ( String roleName : statistics.getCollectionRoleNames() ) { for ( String roleName : statistics.getCollectionRoleNames() ) {
CollectionStats collectionStats = new CollectionStats( final CollectionStats collectionStats = new CollectionStats(
roleName, roleName,
statistics.getCollectionStatistics( roleName ) statistics.getCollectionStatistics( roleName )
); );
result.add( collectionStats.toCompositeData() ); result.add( collectionStats.toCompositeData() );
} }
TabularData td = CollectionStats.newTabularDataInstance(); final TabularData td = CollectionStats.newTabularDataInstance();
td.putAll( result.toArray( new CompositeData[result.size()] ) ); td.putAll( result.toArray( new CompositeData[result.size()] ) );
return td; return td;
} }
@ -282,14 +305,15 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
* *
* @see HibernateStats#getQueryStats() * @see HibernateStats#getQueryStats()
*/ */
@Override
public TabularData getQueryStats() { public TabularData getQueryStats() {
List<CompositeData> result = new ArrayList<CompositeData>(); final List<CompositeData> result = new ArrayList<CompositeData>();
Statistics statistics = getStatistics(); final Statistics statistics = getStatistics();
for ( String query : statistics.getQueries() ) { 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() ); result.add( queryStats.toCompositeData() );
} }
TabularData td = QueryStats.newTabularDataInstance(); final TabularData td = QueryStats.newTabularDataInstance();
td.putAll( result.toArray( new CompositeData[result.size()] ) ); td.putAll( result.toArray( new CompositeData[result.size()] ) );
return td; return td;
} }
@ -297,17 +321,18 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
public TabularData getCacheRegionStats() { public TabularData getCacheRegionStats() {
List<CompositeData> list = new ArrayList<CompositeData>(); final List<CompositeData> list = new ArrayList<CompositeData>();
Statistics statistics = getStatistics(); final Statistics statistics = getStatistics();
for ( String region : statistics.getSecondLevelCacheRegionNames() ) { for ( String region : statistics.getSecondLevelCacheRegionNames() ) {
CacheRegionStats l2CacheStats = new CacheRegionStats( final CacheRegionStats l2CacheStats = new CacheRegionStats(
region, region,
statistics.getSecondLevelCacheStatistics( region ) statistics.getSecondLevelCacheStatistics( region )
); );
list.add( l2CacheStats.toCompositeData() ); list.add( l2CacheStats.toCompositeData() );
} }
TabularData td = CacheRegionStats.newTabularDataInstance(); final TabularData td = CacheRegionStats.newTabularDataInstance();
td.putAll( list.toArray( new CompositeData[list.size()] ) ); td.putAll( list.toArray( new CompositeData[list.size()] ) );
return td; return td;
} }
@ -321,6 +346,7 @@ public class HibernateStatsImpl extends AbstractEmitterBean implements Hibernate
} }
/** /**
* {@inheritDoc}
* @see AbstractEmitterBean#getNotificationInfo() * @see AbstractEmitterBean#getNotificationInfo()
*/ */
@Override @Override

View File

@ -59,6 +59,7 @@ public final class NullHibernateStats implements HibernateStats {
* *
* @see HibernateStats#clearStats() * @see HibernateStats#clearStats()
*/ */
@Override
public void clearStats() { public void clearStats() {
// no-op // no-op
@ -69,6 +70,7 @@ public final class NullHibernateStats implements HibernateStats {
* *
* @see HibernateStats#disableStats() * @see HibernateStats#disableStats()
*/ */
@Override
public void disableStats() { public void disableStats() {
// no-op // no-op
@ -79,6 +81,7 @@ public final class NullHibernateStats implements HibernateStats {
* *
* @see HibernateStats#enableStats() * @see HibernateStats#enableStats()
*/ */
@Override
public void enableStats() { public void enableStats() {
// no-op // no-op
@ -89,6 +92,7 @@ public final class NullHibernateStats implements HibernateStats {
* *
* @see HibernateStats#getCloseStatementCount() * @see HibernateStats#getCloseStatementCount()
*/ */
@Override
public long getCloseStatementCount() { public long getCloseStatementCount() {
// no-op // no-op
return 0; return 0;
@ -99,6 +103,7 @@ public final class NullHibernateStats implements HibernateStats {
* *
* @see HibernateStats#getCollectionStats() * @see HibernateStats#getCollectionStats()
*/ */
@Override
public TabularData getCollectionStats() { public TabularData getCollectionStats() {
// no-op // no-op
return null; return null;
@ -109,6 +114,7 @@ public final class NullHibernateStats implements HibernateStats {
* *
* @see HibernateStats#getConnectCount() * @see HibernateStats#getConnectCount()
*/ */
@Override
public long getConnectCount() { public long getConnectCount() {
// no-op // no-op
return 0; return 0;
@ -116,6 +122,7 @@ public final class NullHibernateStats implements HibernateStats {
/** /**
* Not supported right now * Not supported right now
* @return 0 always
*/ */
public long getDBSQLExecutionSample() { public long getDBSQLExecutionSample() {
// no-op // no-op
@ -127,6 +134,7 @@ public final class NullHibernateStats implements HibernateStats {
* *
* @see HibernateStats#getEntityStats() * @see HibernateStats#getEntityStats()
*/ */
@Override
public TabularData getEntityStats() { public TabularData getEntityStats() {
// no-op // no-op
return null; return null;
@ -137,6 +145,7 @@ public final class NullHibernateStats implements HibernateStats {
* *
* @see HibernateStats#getFlushCount() * @see HibernateStats#getFlushCount()
*/ */
@Override
public long getFlushCount() { public long getFlushCount() {
// no-op // no-op
return 0; return 0;
@ -147,6 +156,7 @@ public final class NullHibernateStats implements HibernateStats {
* *
* @see HibernateStats#getOptimisticFailureCount() * @see HibernateStats#getOptimisticFailureCount()
*/ */
@Override
public long getOptimisticFailureCount() { public long getOptimisticFailureCount() {
// no-op // no-op
return 0; return 0;
@ -157,6 +167,7 @@ public final class NullHibernateStats implements HibernateStats {
* *
* @see HibernateStats#getPrepareStatementCount() * @see HibernateStats#getPrepareStatementCount()
*/ */
@Override
public long getPrepareStatementCount() { public long getPrepareStatementCount() {
// no-op // no-op
return 0; return 0;
@ -167,6 +178,7 @@ public final class NullHibernateStats implements HibernateStats {
* *
* @see HibernateStats#getQueryExecutionCount() * @see HibernateStats#getQueryExecutionCount()
*/ */
@Override
public long getQueryExecutionCount() { public long getQueryExecutionCount() {
// no-op // no-op
return 0; return 0;
@ -177,6 +189,7 @@ public final class NullHibernateStats implements HibernateStats {
* *
* @see HibernateStats#getQueryExecutionRate() * @see HibernateStats#getQueryExecutionRate()
*/ */
@Override
public double getQueryExecutionRate() { public double getQueryExecutionRate() {
// no-op // no-op
return 0; return 0;
@ -187,6 +200,7 @@ public final class NullHibernateStats implements HibernateStats {
* *
* @see HibernateStats#getQueryExecutionSample() * @see HibernateStats#getQueryExecutionSample()
*/ */
@Override
public long getQueryExecutionSample() { public long getQueryExecutionSample() {
// no-op // no-op
return 0; return 0;
@ -197,6 +211,7 @@ public final class NullHibernateStats implements HibernateStats {
* *
* @see HibernateStats#getQueryStats() * @see HibernateStats#getQueryStats()
*/ */
@Override
public TabularData getQueryStats() { public TabularData getQueryStats() {
// no-op // no-op
return null; return null;
@ -207,6 +222,7 @@ public final class NullHibernateStats implements HibernateStats {
* *
* @see HibernateStats#getSessionCloseCount() * @see HibernateStats#getSessionCloseCount()
*/ */
@Override
public long getSessionCloseCount() { public long getSessionCloseCount() {
// no-op // no-op
return 0; return 0;
@ -217,6 +233,7 @@ public final class NullHibernateStats implements HibernateStats {
* *
* @see HibernateStats#getSessionOpenCount() * @see HibernateStats#getSessionOpenCount()
*/ */
@Override
public long getSessionOpenCount() { public long getSessionOpenCount() {
// no-op // no-op
return 0; return 0;
@ -227,6 +244,7 @@ public final class NullHibernateStats implements HibernateStats {
* *
* @see HibernateStats#getSuccessfulTransactionCount() * @see HibernateStats#getSuccessfulTransactionCount()
*/ */
@Override
public long getSuccessfulTransactionCount() { public long getSuccessfulTransactionCount() {
// no-op // no-op
return 0; return 0;
@ -237,6 +255,7 @@ public final class NullHibernateStats implements HibernateStats {
* *
* @see HibernateStats#getTransactionCount() * @see HibernateStats#getTransactionCount()
*/ */
@Override
public long getTransactionCount() { public long getTransactionCount() {
// no-op // no-op
return 0; return 0;
@ -247,6 +266,7 @@ public final class NullHibernateStats implements HibernateStats {
* *
* @see HibernateStats#isStatisticsEnabled() * @see HibernateStats#isStatisticsEnabled()
*/ */
@Override
public boolean isStatisticsEnabled() { public boolean isStatisticsEnabled() {
// no-op // no-op
return false; return false;
@ -257,43 +277,54 @@ public final class NullHibernateStats implements HibernateStats {
* *
* @see HibernateStats#setStatisticsEnabled(boolean) * @see HibernateStats#setStatisticsEnabled(boolean)
*/ */
@Override
public void setStatisticsEnabled(boolean flag) { public void setStatisticsEnabled(boolean flag) {
// no-op // no-op
} }
/** /**
* {@inheritDoc}
* @see HibernateStats#getCacheRegionStats() * @see HibernateStats#getCacheRegionStats()
*/ */
@Override
public TabularData getCacheRegionStats() { public TabularData getCacheRegionStats() {
return null; return null;
} }
/** /**
* {@inheritDoc}
* @see javax.management.NotificationEmitter#removeNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object) * @see javax.management.NotificationEmitter#removeNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)
*/ */
@Override
public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
throws ListenerNotFoundException { throws ListenerNotFoundException {
/**/ /**/
} }
/** /**
* {@inheritDoc}
* @see javax.management.NotificationBroadcaster#addNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object) * @see javax.management.NotificationBroadcaster#addNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)
*/ */
@Override
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
throws IllegalArgumentException { throws IllegalArgumentException {
/**/ /**/
} }
/** /**
* {@inheritDoc}
* @see javax.management.NotificationBroadcaster#getNotificationInfo() * @see javax.management.NotificationBroadcaster#getNotificationInfo()
*/ */
@Override
public MBeanNotificationInfo[] getNotificationInfo() { public MBeanNotificationInfo[] getNotificationInfo() {
return null; return null;
} }
/** /**
* {@inheritDoc}
* @see javax.management.NotificationBroadcaster#removeNotificationListener(javax.management.NotificationListener) * @see javax.management.NotificationBroadcaster#removeNotificationListener(javax.management.NotificationListener)
*/ */
@Override
public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException { public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException {
/**/ /**/
} }

View File

@ -116,7 +116,7 @@ public class ProviderMBeanRegistrationHelper {
throw new CacheException( e ); throw new CacheException( e );
} }
} }
SessionFactory sessionFactory = locateSessionFactory(); final SessionFactory sessionFactory = locateSessionFactory();
if ( sessionFactory == null ) { if ( sessionFactory == null ) {
LOG.debug( LOG.debug(
"SessionFactory is probably still being initialized..." "SessionFactory is probably still being initialized..."
@ -140,29 +140,29 @@ public class ProviderMBeanRegistrationHelper {
} }
private SessionFactory locateSessionFactory() { private SessionFactory locateSessionFactory() {
String jndiName = properties.getProperty( Environment.SESSION_FACTORY_NAME ); final String jndiName = properties.getProperty( Environment.SESSION_FACTORY_NAME );
if ( jndiName != null ) { if ( jndiName != null ) {
return SessionFactoryRegistry.INSTANCE.getNamedSessionFactory( jndiName ); return SessionFactoryRegistry.INSTANCE.getNamedSessionFactory( jndiName );
} }
try { try {
Class factoryType = SessionFactoryRegistry.class; final Class factoryType = SessionFactoryRegistry.class;
Field instancesField = getField( factoryType, "sessionFactoryMap" ); final Field instancesField = getField( factoryType, "sessionFactoryMap" );
if ( instancesField == null ) { if ( instancesField == null ) {
throw new RuntimeException( "Expected 'sessionFactoryMap' field on " + SessionFactoryRegistry.class.getName() ); throw new RuntimeException( "Expected 'sessionFactoryMap' field on " + SessionFactoryRegistry.class.getName() );
} }
instancesField.setAccessible( true ); instancesField.setAccessible( true );
Map map = (Map) instancesField.get( SessionFactoryRegistry.INSTANCE ); final Map map = (Map) instancesField.get( SessionFactoryRegistry.INSTANCE );
if ( map == null ) { if ( map == null ) {
return null; return null;
} }
Iterator values = map.values().iterator(); final Iterator values = map.values().iterator();
while ( values.hasNext() ) { while ( values.hasNext() ) {
SessionFactory sessionFactory = (SessionFactory) values.next(); final SessionFactory sessionFactory = (SessionFactory) values.next();
Class sessionFactoryType = sessionFactory.getClass(); final Class sessionFactoryType = sessionFactory.getClass();
Field propertiesField = getField( sessionFactoryType, "properties" ); final Field propertiesField = getField( sessionFactoryType, "properties" );
if ( propertiesField != null ) { if ( propertiesField != null ) {
propertiesField.setAccessible( true ); propertiesField.setAccessible( true );
Properties props = (Properties) propertiesField.get( sessionFactory ); final Properties props = (Properties) propertiesField.get( sessionFactory );
if ( props != null && props.equals( properties ) ) { if ( props != null && props.equals( properties ) ) {
return sessionFactory; return sessionFactory;
} }
@ -187,4 +187,4 @@ public class ProviderMBeanRegistrationHelper {
} }
throw new NoSuchFieldError( "Type '" + c + "' has no field '" + fieldName + "'" ); throw new NoSuchFieldError( "Type '" + c + "' has no field '" + fieldName + "'" );
} }
} }

View File

@ -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 gkeim
* @author Alex Snaps * @author Alex Snaps
*/ */
@ -137,15 +139,17 @@ public class QueryStats implements Serializable {
protected long executionMinTime; protected long executionMinTime;
/** /**
* @param name * Constructor
* @param name the query string
*/ */
public QueryStats(String name) { public QueryStats(String name) {
this.query = name; this.query = name;
} }
/** /**
* @param name * Constructor
* @param src * @param name the query string
* @param src the source of the stats to this query
*/ */
public QueryStats(String name, QueryStatistics src) { public QueryStats(String name, QueryStatistics src) {
this( name ); 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) { public QueryStats(final CompositeData cData) {
int i = 0; int i = 0;
@ -183,17 +188,9 @@ public class QueryStats implements Serializable {
executionMinTime = (Long) cData.get( ITEM_NAMES[i++] ); 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) { public void add(QueryStats stats) {
cacheHitCount += stats.getCacheHitCount(); cacheHitCount += stats.getCacheHitCount();
@ -207,7 +204,7 @@ public class QueryStats implements Serializable {
} }
/** /**
* toString * {@inheritDoc}
*/ */
@Override @Override
public String toString() { public String toString() {
@ -218,70 +215,80 @@ public class QueryStats implements Serializable {
} }
/** /**
* getQuery * Accessor to the queryString
* @return the query string
*/ */
public String getQuery() { public String getQuery() {
return query; return query;
} }
/** /**
* getCacheHitCount * The amount of hits for this query
* @return the hit count
*/ */
public long getCacheHitCount() { public long getCacheHitCount() {
return cacheHitCount; return cacheHitCount;
} }
/** /**
* getCacheMissCount * The amount of misses for this query
* @return the miss count
*/ */
public long getCacheMissCount() { public long getCacheMissCount() {
return cacheMissCount; return cacheMissCount;
} }
/** /**
* getCachePutCount * The amount of puts for this query
* @return the put count
*/ */
public long getCachePutCount() { public long getCachePutCount() {
return cachePutCount; return cachePutCount;
} }
/** /**
* getExecutionCount * The amount of execution of this query
* @return the execution count
*/ */
public long getExecutionCount() { public long getExecutionCount() {
return executionCount; return executionCount;
} }
/** /**
* getExecutionRowCount * The amount of rows returned for this query
* @return the row count
*/ */
public long getExecutionRowCount() { public long getExecutionRowCount() {
return executionRowCount; return executionRowCount;
} }
/** /**
* getExecutionAvgTime * The avg time to execute this query
* @return the avg time in ms
*/ */
public long getExecutionAvgTime() { public long getExecutionAvgTime() {
return executionAvgTime; return executionAvgTime;
} }
/** /**
* getExecutionMaxTime * The max time to execute this query
* @return the max time in ms
*/ */
public long getExecutionMaxTime() { public long getExecutionMaxTime() {
return executionMaxTime; return executionMaxTime;
} }
/** /**
* getExecutionMinTime * The minimum time to execute this query
* @return the min time in ms
*/ */
public long getExecutionMinTime() { public long getExecutionMinTime() {
return executionMinTime; return executionMinTime;
} }
/** /**
* toCompositeData * Creates a CompositeData instance of this instance
* @return the compositeData representation of this instance
*/ */
public CompositeData toCompositeData() { public CompositeData toCompositeData() {
try { try {
@ -303,14 +310,17 @@ public class QueryStats implements Serializable {
} }
/** /**
* newTabularDataInstance * Creates a new TabularData
* @return a new TabularData instance
*/ */
public static TabularData newTabularDataInstance() { public static TabularData newTabularDataInstance() {
return new TabularDataSupport( TABULAR_TYPE ); 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) { public static QueryStats[] fromTabularData(final TabularData tabularData) {
final List<QueryStats> countList = new ArrayList( tabularData.size() ); final List<QueryStats> countList = new ArrayList( tabularData.size() );