From f93d1412a4ab1ffd2372786390478453c89e925b Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Mon, 21 Mar 2011 11:51:49 -0500 Subject: [PATCH] HHH-6033 - Migrate stats to api/spi/internal split --- .../engine/SessionFactoryImplementor.java | 2 +- .../spi/LogicalConnectionImplementor.java | 2 - .../spi/TransactionEnvironment.java | 2 +- .../hibernate/impl/SessionFactoryImpl.java | 15 +- .../java/org/hibernate/impl/SessionImpl.java | 5 +- .../impl/TransactionEnvironmentImpl.java | 2 +- .../org/hibernate/jmx/StatisticsService.java | 7 +- .../hibernate/stat/CollectionStatistics.java | 7 +- .../stat/CollectionStatisticsImpl.java | 76 -- ...currentSecondLevelCacheStatisticsImpl.java | 87 --- .../org/hibernate/stat/EntityStatistics.java | 7 +- .../hibernate/stat/EntityStatisticsImpl.java | 84 --- .../org/hibernate/stat/QueryStatistics.java | 7 +- .../hibernate/stat/QueryStatisticsImpl.java | 138 ---- .../stat/SecondLevelCacheStatistics.java | 7 +- .../org/hibernate/stat/SessionStatistics.java | 7 +- .../java/org/hibernate/stat/Statistics.java | 12 +- .../org/hibernate/stat/StatisticsImpl.java | 666 ------------------ .../{ => internal}/CategorizedStatistics.java | 11 +- .../ConcurrentCollectionStatisticsImpl.java | 29 +- .../ConcurrentEntityStatisticsImpl.java | 27 +- .../ConcurrentQueryStatisticsImpl.java | 29 +- ...urrentSecondLevelCacheStatisticsImpl.java} | 54 +- .../ConcurrentStatisticsImpl.java | 20 +- .../{ => internal}/SessionStatisticsImpl.java | 10 +- .../main/java/org/hibernate/stat/package.html | 3 +- .../stat/{ => spi}/StatisticsImplementor.java | 5 +- .../common/TransactionEnvironmentImpl.java | 4 +- 28 files changed, 181 insertions(+), 1144 deletions(-) delete mode 100644 hibernate-core/src/main/java/org/hibernate/stat/CollectionStatisticsImpl.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/stat/ConcurrentSecondLevelCacheStatisticsImpl.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/stat/EntityStatisticsImpl.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/stat/QueryStatisticsImpl.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/stat/StatisticsImpl.java rename hibernate-core/src/main/java/org/hibernate/stat/{ => internal}/CategorizedStatistics.java (81%) rename hibernate-core/src/main/java/org/hibernate/stat/{ => internal}/ConcurrentCollectionStatisticsImpl.java (58%) rename hibernate-core/src/main/java/org/hibernate/stat/{ => internal}/ConcurrentEntityStatisticsImpl.java (63%) rename hibernate-core/src/main/java/org/hibernate/stat/{ => internal}/ConcurrentQueryStatisticsImpl.java (80%) rename hibernate-core/src/main/java/org/hibernate/stat/{SecondLevelCacheStatisticsImpl.java => internal/ConcurrentSecondLevelCacheStatisticsImpl.java} (66%) rename hibernate-core/src/main/java/org/hibernate/stat/{ => internal}/ConcurrentStatisticsImpl.java (97%) rename hibernate-core/src/main/java/org/hibernate/stat/{ => internal}/SessionStatisticsImpl.java (90%) rename hibernate-core/src/main/java/org/hibernate/stat/{ => spi}/StatisticsImplementor.java (97%) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/SessionFactoryImplementor.java b/hibernate-core/src/main/java/org/hibernate/engine/SessionFactoryImplementor.java index 735f5c8b8b..d3cea25517 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/SessionFactoryImplementor.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/SessionFactoryImplementor.java @@ -51,7 +51,7 @@ import org.hibernate.persister.entity.EntityPersister; import org.hibernate.proxy.EntityNotFoundDelegate; import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; import org.hibernate.service.spi.ServiceRegistry; -import org.hibernate.stat.StatisticsImplementor; +import org.hibernate.stat.spi.StatisticsImplementor; import org.hibernate.type.Type; import org.hibernate.type.TypeResolver; diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/LogicalConnectionImplementor.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/LogicalConnectionImplementor.java index 45f39ddfb8..37333d80a8 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/LogicalConnectionImplementor.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/LogicalConnectionImplementor.java @@ -23,8 +23,6 @@ */ package org.hibernate.engine.jdbc.spi; import org.hibernate.ConnectionReleaseMode; -import org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler; -import org.hibernate.stat.StatisticsImplementor; import java.sql.Connection; diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/spi/TransactionEnvironment.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/spi/TransactionEnvironment.java index f45713c57b..9605e3270b 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/spi/TransactionEnvironment.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/spi/TransactionEnvironment.java @@ -26,7 +26,7 @@ package org.hibernate.engine.transaction.spi; import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.service.jta.platform.spi.JtaPlatform; -import org.hibernate.stat.StatisticsImplementor; +import org.hibernate.stat.spi.StatisticsImplementor; /** * Provides access to transactional services. diff --git a/hibernate-core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java index e7e34f97c7..0c012b1dd4 100644 --- a/hibernate-core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java @@ -116,9 +116,9 @@ import org.hibernate.proxy.EntityNotFoundDelegate; import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; import org.hibernate.service.jta.platform.spi.JtaPlatform; import org.hibernate.service.spi.ServiceRegistry; -import org.hibernate.stat.ConcurrentStatisticsImpl; +import org.hibernate.stat.internal.ConcurrentStatisticsImpl; import org.hibernate.stat.Statistics; -import org.hibernate.stat.StatisticsImplementor; +import org.hibernate.stat.spi.StatisticsImplementor; import org.hibernate.tool.hbm2ddl.SchemaExport; import org.hibernate.tool.hbm2ddl.SchemaUpdate; import org.hibernate.tool.hbm2ddl.SchemaValidator; @@ -205,9 +205,7 @@ public final class SessionFactoryImpl SessionFactoryObserver observer) throws HibernateException { LOG.buildingSessionFactory(); - this.statistics = new ConcurrentStatisticsImpl( this ); - getStatistics().setStatisticsEnabled( settings.isStatisticsEnabled() ); - LOG.debugf("Statistics initialized [enabled=%s]", settings.isStatisticsEnabled()); + this.statistics = buildStatistics( settings, serviceRegistry ); this.properties = new Properties(); this.properties.putAll( cfg.getProperties() ); @@ -474,6 +472,13 @@ public final class SessionFactoryImpl this.observer.sessionFactoryCreated( this ); } + private Statistics buildStatistics(Settings settings, ServiceRegistry serviceRegistry) { + Statistics statistics = new ConcurrentStatisticsImpl( this ); + getStatistics().setStatisticsEnabled( settings.isStatisticsEnabled() ); + LOG.debugf("Statistics initialized [enabled=%s]", settings.isStatisticsEnabled()); + return statistics; + } + public TransactionEnvironment getTransactionEnvironment() { return transactionEnvironment; } diff --git a/hibernate-core/src/main/java/org/hibernate/impl/SessionImpl.java b/hibernate-core/src/main/java/org/hibernate/impl/SessionImpl.java index cd09279ecb..6281ec0e6d 100644 --- a/hibernate-core/src/main/java/org/hibernate/impl/SessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/impl/SessionImpl.java @@ -35,7 +35,6 @@ import java.sql.Blob; import java.sql.Clob; import java.sql.Connection; import java.sql.SQLException; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -122,8 +121,6 @@ import org.hibernate.event.ReplicateEvent; import org.hibernate.event.ReplicateEventListener; import org.hibernate.event.SaveOrUpdateEvent; import org.hibernate.event.SaveOrUpdateEventListener; -import org.hibernate.internal.util.StringHelper; -import org.hibernate.internal.util.collections.ArrayHelper; import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.jdbc.WorkExecutorVisitable; import org.hibernate.jdbc.ReturningWork; @@ -139,7 +136,7 @@ import org.hibernate.pretty.MessageHelper; import org.hibernate.proxy.HibernateProxy; import org.hibernate.proxy.LazyInitializer; import org.hibernate.stat.SessionStatistics; -import org.hibernate.stat.SessionStatisticsImpl; +import org.hibernate.stat.internal.SessionStatisticsImpl; import org.hibernate.type.SerializationException; import org.hibernate.type.Type; import org.jboss.logging.Logger; diff --git a/hibernate-core/src/main/java/org/hibernate/impl/TransactionEnvironmentImpl.java b/hibernate-core/src/main/java/org/hibernate/impl/TransactionEnvironmentImpl.java index 0049f1f0a3..145e801df4 100644 --- a/hibernate-core/src/main/java/org/hibernate/impl/TransactionEnvironmentImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/impl/TransactionEnvironmentImpl.java @@ -29,7 +29,7 @@ import org.hibernate.engine.transaction.spi.TransactionEnvironment; import org.hibernate.engine.transaction.spi.TransactionFactory; import org.hibernate.service.jta.platform.spi.JtaPlatform; import org.hibernate.service.spi.ServiceRegistry; -import org.hibernate.stat.StatisticsImplementor; +import org.hibernate.stat.spi.StatisticsImplementor; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/jmx/StatisticsService.java b/hibernate-core/src/main/java/org/hibernate/jmx/StatisticsService.java index 0c5b0f58b3..106813fb1b 100644 --- a/hibernate-core/src/main/java/org/hibernate/jmx/StatisticsService.java +++ b/hibernate-core/src/main/java/org/hibernate/jmx/StatisticsService.java @@ -12,7 +12,8 @@ import org.hibernate.stat.EntityStatistics; import org.hibernate.stat.QueryStatistics; import org.hibernate.stat.SecondLevelCacheStatistics; import org.hibernate.stat.Statistics; -import org.hibernate.stat.StatisticsImpl; +import org.hibernate.stat.internal.ConcurrentStatisticsImpl; + import org.jboss.logging.Logger; /** @@ -54,7 +55,7 @@ public class StatisticsService implements StatisticsServiceMBean { SessionFactory sf; String sfJNDIName; - Statistics stats = new StatisticsImpl(); + Statistics stats = new ConcurrentStatisticsImpl(); /** * @see StatisticsServiceMBean#setSessionFactoryJNDIName(java.lang.String) @@ -93,7 +94,7 @@ public class StatisticsService implements StatisticsServiceMBean { public void setSessionFactory(SessionFactory sf) { this.sf = sf; if (sf == null) { - stats = new StatisticsImpl(); + stats = new ConcurrentStatisticsImpl(); } else { stats = sf.getStatistics(); diff --git a/hibernate-core/src/main/java/org/hibernate/stat/CollectionStatistics.java b/hibernate-core/src/main/java/org/hibernate/stat/CollectionStatistics.java index c1e94ddfec..7cc4ec5000 100755 --- a/hibernate-core/src/main/java/org/hibernate/stat/CollectionStatistics.java +++ b/hibernate-core/src/main/java/org/hibernate/stat/CollectionStatistics.java @@ -1,10 +1,10 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as + * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as * indicated by the @author tags or express copyright attribution * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat Middleware LLC. + * distributed under license by Red Hat Inc. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU @@ -20,16 +20,15 @@ * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA - * */ package org.hibernate.stat; + import java.io.Serializable; /** * Collection related statistics * * @author Gavin King - * @author Alex Snaps */ public interface CollectionStatistics extends Serializable { diff --git a/hibernate-core/src/main/java/org/hibernate/stat/CollectionStatisticsImpl.java b/hibernate-core/src/main/java/org/hibernate/stat/CollectionStatisticsImpl.java deleted file mode 100644 index f2e9c5946f..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/stat/CollectionStatisticsImpl.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as - * indicated by the @author tags or express copyright attribution - * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat Middleware LLC. - * - * This copyrighted material is made available to anyone wishing to use, modify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this distribution; if not, write to: - * Free Software Foundation, Inc. - * 51 Franklin Street, Fifth Floor - * Boston, MA 02110-1301 USA - * - */ -package org.hibernate.stat; - - -/** - * Collection related statistics - * - * @author Gavin King - */ -public class CollectionStatisticsImpl extends CategorizedStatistics implements CollectionStatistics { - - CollectionStatisticsImpl(String role) { - super(role); - } - - long loadCount; - long fetchCount; - long updateCount; - long removeCount; - long recreateCount; - - public long getLoadCount() { - return loadCount; - } - - public long getFetchCount() { - return fetchCount; - } - - public long getRecreateCount() { - return recreateCount; - } - - public long getRemoveCount() { - return removeCount; - } - - public long getUpdateCount() { - return updateCount; - } - - public String toString() { - return new StringBuilder() - .append("CollectionStatistics") - .append("[loadCount=").append(this.loadCount) - .append(",fetchCount=").append(this.fetchCount) - .append(",recreateCount=").append(this.recreateCount) - .append(",removeCount=").append(this.removeCount) - .append(",updateCount=").append(this.updateCount) - .append(']') - .toString(); - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/stat/ConcurrentSecondLevelCacheStatisticsImpl.java b/hibernate-core/src/main/java/org/hibernate/stat/ConcurrentSecondLevelCacheStatisticsImpl.java deleted file mode 100644 index f1550a1333..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/stat/ConcurrentSecondLevelCacheStatisticsImpl.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.hibernate.stat; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.concurrent.atomic.AtomicLong; -import org.hibernate.cache.CacheKey; -import org.hibernate.cache.Region; - -/** - * Second level cache statistics of a specific region - * - * @author Alex Snaps - */ -public class ConcurrentSecondLevelCacheStatisticsImpl extends CategorizedStatistics implements SecondLevelCacheStatistics { - - private final transient Region region; - private AtomicLong hitCount = new AtomicLong(); - private AtomicLong missCount = new AtomicLong(); - private AtomicLong putCount = new AtomicLong(); - - ConcurrentSecondLevelCacheStatisticsImpl(Region region) { - super(region.getName()); - this.region = region; - } - - public long getHitCount() { - return hitCount.get(); - } - - public long getMissCount() { - return missCount.get(); - } - - public long getPutCount() { - return putCount.get(); - } - - public long getElementCountInMemory() { - return region.getElementCountInMemory(); - } - - public long getElementCountOnDisk() { - return region.getElementCountOnDisk(); - } - - public long getSizeInMemory() { - return region.getSizeInMemory(); - } - - public Map getEntries() { - Map map = new HashMap(); - Iterator iter = region.toMap().entrySet().iterator(); - while (iter.hasNext()) { - Map.Entry me = (Map.Entry) iter.next(); - map.put(((CacheKey) me.getKey()).getKey(), me.getValue()); - } - return map; - } - - public String toString() { - StringBuilder buf = new StringBuilder() - .append("SecondLevelCacheStatistics") - .append("[hitCount=").append(this.hitCount) - .append(",missCount=").append(this.missCount) - .append(",putCount=").append(this.putCount); - //not sure if this would ever be null but wanted to be careful - if (region != null) { - buf.append(",elementCountInMemory=").append(this.getElementCountInMemory()) - .append(",elementCountOnDisk=").append(this.getElementCountOnDisk()) - .append(",sizeInMemory=").append(this.getSizeInMemory()); - } - buf.append(']'); - return buf.toString(); - } - - void incrementHitCount() { - hitCount.getAndIncrement(); - } - - void incrementMissCount() { - missCount.getAndIncrement(); - } - - void incrementPutCount() { - putCount.getAndIncrement(); - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/stat/EntityStatistics.java b/hibernate-core/src/main/java/org/hibernate/stat/EntityStatistics.java index b156772c2c..5d95b89c92 100755 --- a/hibernate-core/src/main/java/org/hibernate/stat/EntityStatistics.java +++ b/hibernate-core/src/main/java/org/hibernate/stat/EntityStatistics.java @@ -1,10 +1,10 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as + * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as * indicated by the @author tags or express copyright attribution * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat Middleware LLC. + * distributed under license by Red Hat Inc. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU @@ -20,16 +20,15 @@ * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA - * */ package org.hibernate.stat; + import java.io.Serializable; /** * Entity related statistics * * @author Gavin King - * @author Alex Snaps */ public interface EntityStatistics extends Serializable { long getDeleteCount(); diff --git a/hibernate-core/src/main/java/org/hibernate/stat/EntityStatisticsImpl.java b/hibernate-core/src/main/java/org/hibernate/stat/EntityStatisticsImpl.java deleted file mode 100644 index 0bb299089b..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/stat/EntityStatisticsImpl.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as - * indicated by the @author tags or express copyright attribution - * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat Middleware LLC. - * - * This copyrighted material is made available to anyone wishing to use, modify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this distribution; if not, write to: - * Free Software Foundation, Inc. - * 51 Franklin Street, Fifth Floor - * Boston, MA 02110-1301 USA - * - */ -package org.hibernate.stat; - - - -/** - * Entity related statistics - * - * @author Gavin King - */ -public class EntityStatisticsImpl extends CategorizedStatistics implements EntityStatistics { - - EntityStatisticsImpl(String name) { - super(name); - } - - long loadCount; - long updateCount; - long insertCount; - long deleteCount; - long fetchCount; - long optimisticFailureCount; - - public long getDeleteCount() { - return deleteCount; - } - - public long getInsertCount() { - return insertCount; - } - - public long getLoadCount() { - return loadCount; - } - - public long getUpdateCount() { - return updateCount; - } - - public long getFetchCount() { - return fetchCount; - } - - public long getOptimisticFailureCount() { - return optimisticFailureCount; - } - - public String toString() { - return new StringBuilder() - .append("EntityStatistics") - .append("[loadCount=").append(this.loadCount) - .append(",updateCount=").append(this.updateCount) - .append(",insertCount=").append(this.insertCount) - .append(",deleteCount=").append(this.deleteCount) - .append(",fetchCount=").append(this.fetchCount) - .append(",optimisticLockFailureCount=").append(this.optimisticFailureCount) - .append(']') - .toString(); - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/stat/QueryStatistics.java b/hibernate-core/src/main/java/org/hibernate/stat/QueryStatistics.java index 2b39ad3d39..592b5bd665 100755 --- a/hibernate-core/src/main/java/org/hibernate/stat/QueryStatistics.java +++ b/hibernate-core/src/main/java/org/hibernate/stat/QueryStatistics.java @@ -1,10 +1,10 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as + * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as * indicated by the @author tags or express copyright attribution * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat Middleware LLC. + * distributed under license by Red Hat Inc. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU @@ -20,9 +20,9 @@ * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA - * */ package org.hibernate.stat; + import java.io.Serializable; /** @@ -31,7 +31,6 @@ import java.io.Serializable; * Note that for a cached query, the cache miss is equals to the db count * * @author Gavin King - * @author Alex Snaps */ public interface QueryStatistics extends Serializable { long getExecutionCount(); diff --git a/hibernate-core/src/main/java/org/hibernate/stat/QueryStatisticsImpl.java b/hibernate-core/src/main/java/org/hibernate/stat/QueryStatisticsImpl.java deleted file mode 100644 index 019bc757c3..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/stat/QueryStatisticsImpl.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2010, Red Hat Inc. or third-party contributors as - * indicated by the @author tags or express copyright attribution - * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat Inc. - * - * This copyrighted material is made available to anyone wishing to use, modify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this distribution; if not, write to: - * Free Software Foundation, Inc. - * 51 Franklin Street, Fifth Floor - * Boston, MA 02110-1301 USA - * - */ -package org.hibernate.stat; - - -/** - * Query statistics (HQL and SQL) - *

- * Note that for a cached query, the cache miss is equals to the db count - * - * @author Gavin King - */ -public class QueryStatisticsImpl extends CategorizedStatistics implements QueryStatistics { - - /*package*/ - long cacheHitCount; - /*package*/ - long cacheMissCount; - /*package*/ - long cachePutCount; - private long executionCount; - private long executionRowCount; - private long executionAvgTime; - private long executionMaxTime; - private long executionMinTime = Long.MAX_VALUE; - - QueryStatisticsImpl(String query) { - super(query); - } - - /** - * queries executed to the DB - */ - public long getExecutionCount() { - return executionCount; - } - - /** - * Queries retrieved successfully from the cache - */ - public long getCacheHitCount() { - return cacheHitCount; - } - - public long getCachePutCount() { - return cachePutCount; - } - - public long getCacheMissCount() { - return cacheMissCount; - } - - /** - * Number of lines returned by all the executions of this query (from DB) - * For now, {@link org.hibernate.Query#iterate()} - * and {@link org.hibernate.Query#scroll()()} do not fill this statistic - * - * @return The number of rows cumulatively returned by the given query; iterate - * and scroll queries do not effect this total as their number of returned rows - * is not known at execution time. - */ - public long getExecutionRowCount() { - return executionRowCount; - } - - /** - * average time in ms taken by the execution of this query onto the DB - */ - public long getExecutionAvgTime() { - return executionAvgTime; - } - - /** - * max time in ms taken by the execution of this query onto the DB - */ - public long getExecutionMaxTime() { - return executionMaxTime; - } - - /** - * min time in ms taken by the execution of this query onto the DB - */ - public long getExecutionMinTime() { - return executionMinTime; - } - - /** - * add statistics report of a DB query - * - * @param rows rows count returned - * @param time time taken - */ - void executed(long rows, long time) { - if (time < executionMinTime) executionMinTime = time; - if (time > executionMaxTime) executionMaxTime = time; - executionAvgTime = (executionAvgTime * executionCount + time) / (executionCount + 1); - executionCount++; - executionRowCount += rows; - } - - public String toString() { - return new StringBuilder() - .append("QueryStatistics") - .append("[cacheHitCount=").append(this.cacheHitCount) - .append(",cacheMissCount=").append(this.cacheMissCount) - .append(",cachePutCount=").append(this.cachePutCount) - .append(",executionCount=").append(this.executionCount) - .append(",executionRowCount=").append(this.executionRowCount) - .append(",executionAvgTime=").append(this.executionAvgTime) - .append(",executionMaxTime=").append(this.executionMaxTime) - .append(",executionMinTime=").append(this.executionMinTime) - .append(']') - .toString(); - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/stat/SecondLevelCacheStatistics.java b/hibernate-core/src/main/java/org/hibernate/stat/SecondLevelCacheStatistics.java index 31fe3483d1..c71583b409 100755 --- a/hibernate-core/src/main/java/org/hibernate/stat/SecondLevelCacheStatistics.java +++ b/hibernate-core/src/main/java/org/hibernate/stat/SecondLevelCacheStatistics.java @@ -1,10 +1,10 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as + * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as * indicated by the @author tags or express copyright attribution * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat Middleware LLC. + * distributed under license by Red Hat Inc. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU @@ -20,9 +20,9 @@ * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA - * */ package org.hibernate.stat; + import java.io.Serializable; import java.util.Map; @@ -30,7 +30,6 @@ import java.util.Map; * Second level cache statistics of a specific region * * @author Gavin King - * @author Alex Snaps */ public interface SecondLevelCacheStatistics extends Serializable { diff --git a/hibernate-core/src/main/java/org/hibernate/stat/SessionStatistics.java b/hibernate-core/src/main/java/org/hibernate/stat/SessionStatistics.java index 32313f192f..42b02290f3 100755 --- a/hibernate-core/src/main/java/org/hibernate/stat/SessionStatistics.java +++ b/hibernate-core/src/main/java/org/hibernate/stat/SessionStatistics.java @@ -1,10 +1,10 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as + * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as * indicated by the @author tags or express copyright attribution * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat Middleware LLC. + * distributed under license by Red Hat Inc. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU @@ -20,9 +20,9 @@ * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA - * */ package org.hibernate.stat; + import java.util.Set; /** @@ -31,7 +31,6 @@ import java.util.Set; * @author Gavin King */ public interface SessionStatistics { - /** * Get the number of entity instances associated with the session */ diff --git a/hibernate-core/src/main/java/org/hibernate/stat/Statistics.java b/hibernate-core/src/main/java/org/hibernate/stat/Statistics.java index d51a18b834..f8ac25b076 100755 --- a/hibernate-core/src/main/java/org/hibernate/stat/Statistics.java +++ b/hibernate-core/src/main/java/org/hibernate/stat/Statistics.java @@ -1,10 +1,10 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as + * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as * indicated by the @author tags or express copyright attribution * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat Middleware LLC. + * distributed under license by Red Hat Inc. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU @@ -20,16 +20,12 @@ * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA - * */ package org.hibernate.stat; - - /** - * Statistics for a particular SessionFactory. - * Beware of milliseconds metrics, they are depdendent of the JVM precision: - * you may then encounter a 10 ms approximation dending on you OS platform. + * Exposes statistics for a particular {@link org.hibernate.SessionFactory}. Beware of milliseconds metrics, they + * are dependent of the JVM precision: you may then encounter a 10 ms approximation depending on you OS platform. * Please refer to the JVM documentation for more information. * * @author Emmanuel Bernard diff --git a/hibernate-core/src/main/java/org/hibernate/stat/StatisticsImpl.java b/hibernate-core/src/main/java/org/hibernate/stat/StatisticsImpl.java deleted file mode 100644 index a941bc8bf7..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/stat/StatisticsImpl.java +++ /dev/null @@ -1,666 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as - * indicated by the @author tags or express copyright attribution - * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat Middleware LLC. - * - * This copyrighted material is made available to anyone wishing to use, modify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this distribution; if not, write to: - * Free Software Foundation, Inc. - * 51 Franklin Street, Fifth Floor - * Boston, MA 02110-1301 USA - * - */ -package org.hibernate.stat; - -import java.util.HashMap; -import java.util.Map; -import org.hibernate.HibernateLogger; -import org.hibernate.cache.Region; -import org.hibernate.engine.SessionFactoryImplementor; -import org.hibernate.internal.util.collections.ArrayHelper; -import org.jboss.logging.Logger; - -/** - * @see org.hibernate.stat.Statistics - * - * @author Gavin King - * - * @deprecated Use {@link org.hibernate.stat.ConcurrentStatisticsImpl} instead - */ -@Deprecated -public class StatisticsImpl implements Statistics, StatisticsImplementor { - - //TODO: we should provide some way to get keys of collection of statistics to make it easier to retrieve from a GUI perspective - - private static final HibernateLogger LOG = Logger.getMessageLogger(HibernateLogger.class, StatisticsImpl.class.getName()); - - private SessionFactoryImplementor sessionFactory; - - private boolean isStatisticsEnabled; - private long startTime; - private long sessionOpenCount; - private long sessionCloseCount; - private long flushCount; - private long connectCount; - - private long prepareStatementCount; - private long closeStatementCount; - - private long entityLoadCount; - private long entityUpdateCount; - private long entityInsertCount; - private long entityDeleteCount; - private long entityFetchCount; - private long collectionLoadCount; - private long collectionUpdateCount; - private long collectionRemoveCount; - private long collectionRecreateCount; - private long collectionFetchCount; - - private long secondLevelCacheHitCount; - private long secondLevelCacheMissCount; - private long secondLevelCachePutCount; - - private long queryExecutionCount; - private long queryExecutionMaxTime; - private String queryExecutionMaxTimeQueryString; - private long queryCacheHitCount; - private long queryCacheMissCount; - private long queryCachePutCount; - - private long commitedTransactionCount; - private long transactionCount; - - private long optimisticFailureCount; - - /** second level cache statistics per region */ - private final Map secondLevelCacheStatistics = new HashMap(); - /** entity statistics per name */ - private final Map entityStatistics = new HashMap(); - /** collection statistics per name */ - private final Map collectionStatistics = new HashMap(); - /** entity statistics per query string (HQL or SQL) */ - private final Map queryStatistics = new HashMap(); - - public StatisticsImpl() { - clear(); - } - - public StatisticsImpl(SessionFactoryImplementor sessionFactory) { - clear(); - this.sessionFactory = sessionFactory; - } - - /** - * reset all statistics - */ - public synchronized void clear() { - secondLevelCacheHitCount = 0; - secondLevelCacheMissCount = 0; - secondLevelCachePutCount = 0; - - sessionCloseCount = 0; - sessionOpenCount = 0; - flushCount = 0; - connectCount = 0; - - prepareStatementCount = 0; - closeStatementCount = 0; - - entityDeleteCount = 0; - entityInsertCount = 0; - entityUpdateCount = 0; - entityLoadCount = 0; - entityFetchCount = 0; - - collectionRemoveCount = 0; - collectionUpdateCount = 0; - collectionRecreateCount = 0; - collectionLoadCount = 0; - collectionFetchCount = 0; - - queryExecutionCount = 0; - queryCacheHitCount = 0; - queryExecutionMaxTime = 0; - queryExecutionMaxTimeQueryString = null; - queryCacheMissCount = 0; - queryCachePutCount = 0; - - transactionCount = 0; - commitedTransactionCount = 0; - - optimisticFailureCount = 0; - - secondLevelCacheStatistics.clear(); - entityStatistics.clear(); - collectionStatistics.clear(); - queryStatistics.clear(); - - startTime = System.currentTimeMillis(); - } - - public synchronized void openSession() { - sessionOpenCount++; - } - - public synchronized void closeSession() { - sessionCloseCount++; - } - - public synchronized void flush() { - flushCount++; - } - - public synchronized void connect() { - connectCount++; - } - - public synchronized void loadEntity(String entityName) { - entityLoadCount++; - ((EntityStatisticsImpl) getEntityStatistics(entityName)).loadCount++; - } - - public synchronized void fetchEntity(String entityName) { - entityFetchCount++; - ((EntityStatisticsImpl) getEntityStatistics(entityName)).fetchCount++; - } - - /** - * find entity statistics per name - * - * @param entityName entity name - * @return EntityStatistics object - */ - public synchronized EntityStatistics getEntityStatistics(String entityName) { - EntityStatisticsImpl es = (EntityStatisticsImpl) entityStatistics.get(entityName); - if (es == null) { - es = new EntityStatisticsImpl(entityName); - entityStatistics.put(entityName, es); - } - return es; - } - - public synchronized void updateEntity(String entityName) { - entityUpdateCount++; - EntityStatisticsImpl es = (EntityStatisticsImpl) getEntityStatistics(entityName); - es.updateCount++; - } - - public synchronized void insertEntity(String entityName) { - entityInsertCount++; - EntityStatisticsImpl es = (EntityStatisticsImpl) getEntityStatistics(entityName); - es.insertCount++; - } - - public synchronized void deleteEntity(String entityName) { - entityDeleteCount++; - EntityStatisticsImpl es = (EntityStatisticsImpl) getEntityStatistics(entityName); - es.deleteCount++; - } - - /** - * Get collection statistics per role - * - * @param role collection role - * @return CollectionStatistics - */ - public synchronized CollectionStatistics getCollectionStatistics(String role) { - CollectionStatisticsImpl cs = (CollectionStatisticsImpl) collectionStatistics.get(role); - if (cs==null) { - cs = new CollectionStatisticsImpl(role); - collectionStatistics.put(role, cs); - } - return cs; - } - - public synchronized void loadCollection(String role) { - collectionLoadCount++; - ((CollectionStatisticsImpl) getCollectionStatistics(role)).loadCount++; - } - - public synchronized void fetchCollection(String role) { - collectionFetchCount++; - ((CollectionStatisticsImpl) getCollectionStatistics(role)).fetchCount++; - } - - public synchronized void updateCollection(String role) { - collectionUpdateCount++; - ((CollectionStatisticsImpl) getCollectionStatistics(role)).updateCount++; - } - - public synchronized void recreateCollection(String role) { - collectionRecreateCount++; - ((CollectionStatisticsImpl) getCollectionStatistics(role)).recreateCount++; - } - - public synchronized void removeCollection(String role) { - collectionRemoveCount++; - ((CollectionStatisticsImpl) getCollectionStatistics(role)).removeCount++; - } - - /** - * Second level cache statistics per region - * - * @param regionName region name - * @return SecondLevelCacheStatistics - */ - public synchronized SecondLevelCacheStatistics getSecondLevelCacheStatistics(String regionName) { - SecondLevelCacheStatisticsImpl slcs = (SecondLevelCacheStatisticsImpl) secondLevelCacheStatistics.get(regionName); - if ( slcs == null ) { - if ( sessionFactory == null ) { - return null; - } - Region region = sessionFactory.getSecondLevelCacheRegion( regionName ); - if ( region == null ) { - return null; - } - slcs = new SecondLevelCacheStatisticsImpl(region); - secondLevelCacheStatistics.put( regionName, slcs ); - } - return slcs; - } - - public synchronized void secondLevelCachePut(String regionName) { - secondLevelCachePutCount++; - ((SecondLevelCacheStatisticsImpl) getSecondLevelCacheStatistics(regionName)).putCount++; - } - - public synchronized void secondLevelCacheHit(String regionName) { - secondLevelCacheHitCount++; - ((SecondLevelCacheStatisticsImpl) getSecondLevelCacheStatistics(regionName)).hitCount++; - } - - public synchronized void secondLevelCacheMiss(String regionName) { - secondLevelCacheMissCount++; - ((SecondLevelCacheStatisticsImpl) getSecondLevelCacheStatistics(regionName)).missCount++; - } - - public synchronized void queryExecuted(String hql, int rows, long time) { - queryExecutionCount++; - if (queryExecutionMaxTime @@ -12,7 +38,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; * @author Alex Snaps */ public class ConcurrentQueryStatisticsImpl extends CategorizedStatistics implements QueryStatistics { - private final AtomicLong cacheHitCount = new AtomicLong(); private final AtomicLong cacheMissCount = new AtomicLong(); private final AtomicLong cachePutCount = new AtomicLong(); diff --git a/hibernate-core/src/main/java/org/hibernate/stat/SecondLevelCacheStatisticsImpl.java b/hibernate-core/src/main/java/org/hibernate/stat/internal/ConcurrentSecondLevelCacheStatisticsImpl.java similarity index 66% rename from hibernate-core/src/main/java/org/hibernate/stat/SecondLevelCacheStatisticsImpl.java rename to hibernate-core/src/main/java/org/hibernate/stat/internal/ConcurrentSecondLevelCacheStatisticsImpl.java index 316f3e10d5..191c80c70a 100644 --- a/hibernate-core/src/main/java/org/hibernate/stat/SecondLevelCacheStatisticsImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/stat/internal/ConcurrentSecondLevelCacheStatisticsImpl.java @@ -1,10 +1,10 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as + * Copyright (c) 2011, Red Hat Inc. or third-party contributors as * indicated by the @author tags or express copyright attribution * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat Middleware LLC. + * distributed under license by Red Hat Inc. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU @@ -20,42 +20,44 @@ * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA - * */ -package org.hibernate.stat; +package org.hibernate.stat.internal; + import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.concurrent.atomic.AtomicLong; + import org.hibernate.cache.CacheKey; import org.hibernate.cache.Region; +import org.hibernate.stat.SecondLevelCacheStatistics; /** * Second level cache statistics of a specific region * - * @author Gavin King + * @author Alex Snaps */ -public class SecondLevelCacheStatisticsImpl extends CategorizedStatistics implements SecondLevelCacheStatistics { +public class ConcurrentSecondLevelCacheStatisticsImpl extends CategorizedStatistics implements SecondLevelCacheStatistics { + private final transient Region region; + private AtomicLong hitCount = new AtomicLong(); + private AtomicLong missCount = new AtomicLong(); + private AtomicLong putCount = new AtomicLong(); - private transient Region region; - long hitCount; - long missCount; - long putCount; - - SecondLevelCacheStatisticsImpl(Region region) { - super(region.getName()); + ConcurrentSecondLevelCacheStatisticsImpl(Region region) { + super( region.getName() ); this.region = region; } public long getHitCount() { - return hitCount; + return hitCount.get(); } public long getMissCount() { - return missCount; + return missCount.get(); } public long getPutCount() { - return putCount; + return putCount.get(); } public long getElementCountInMemory() { @@ -81,18 +83,30 @@ public class SecondLevelCacheStatisticsImpl extends CategorizedStatistics implem } public String toString() { - StringBuilder builder = new StringBuilder() + StringBuilder buf = new StringBuilder() .append("SecondLevelCacheStatistics") .append("[hitCount=").append(this.hitCount) .append(",missCount=").append(this.missCount) .append(",putCount=").append(this.putCount); //not sure if this would ever be null but wanted to be careful if (region != null) { - builder.append(",elementCountInMemory=").append(this.getElementCountInMemory()) + buf.append(",elementCountInMemory=").append(this.getElementCountInMemory()) .append(",elementCountOnDisk=").append(this.getElementCountOnDisk()) .append(",sizeInMemory=").append(this.getSizeInMemory()); } - builder.append(']'); - return builder.toString(); + buf.append(']'); + return buf.toString(); + } + + void incrementHitCount() { + hitCount.getAndIncrement(); + } + + void incrementMissCount() { + missCount.getAndIncrement(); + } + + void incrementPutCount() { + putCount.getAndIncrement(); } } diff --git a/hibernate-core/src/main/java/org/hibernate/stat/ConcurrentStatisticsImpl.java b/hibernate-core/src/main/java/org/hibernate/stat/internal/ConcurrentStatisticsImpl.java similarity index 97% rename from hibernate-core/src/main/java/org/hibernate/stat/ConcurrentStatisticsImpl.java rename to hibernate-core/src/main/java/org/hibernate/stat/internal/ConcurrentStatisticsImpl.java index 4d42f74b71..f951841469 100644 --- a/hibernate-core/src/main/java/org/hibernate/stat/ConcurrentStatisticsImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/stat/internal/ConcurrentStatisticsImpl.java @@ -21,28 +21,34 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.stat; +package org.hibernate.stat.internal; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicLong; + +import org.jboss.logging.Logger; + import org.hibernate.HibernateLogger; import org.hibernate.cache.Region; import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.internal.util.collections.ArrayHelper; -import org.jboss.logging.Logger; +import org.hibernate.service.spi.Service; +import org.hibernate.stat.CollectionStatistics; +import org.hibernate.stat.EntityStatistics; +import org.hibernate.stat.QueryStatistics; +import org.hibernate.stat.SecondLevelCacheStatistics; +import org.hibernate.stat.spi.StatisticsImplementor; /** - * Implementation of {@link Statistics}, as well as {@link StatisticsImplementor}, based on the - * {@link java.util.concurrent} package introduced in Java 5. + * Implementation of {@link org.hibernate.stat.Statistics} based on the {@link java.util.concurrent} package. * * @author Alex Snaps */ @SuppressWarnings({ "unchecked" }) -public class ConcurrentStatisticsImpl implements Statistics, StatisticsImplementor { +public class ConcurrentStatisticsImpl implements StatisticsImplementor, Service { - private static final HibernateLogger LOG = Logger.getMessageLogger(HibernateLogger.class, - ConcurrentStatisticsImpl.class.getName()); + private static final HibernateLogger LOG = Logger.getMessageLogger(HibernateLogger.class, ConcurrentStatisticsImpl.class.getName()); private SessionFactoryImplementor sessionFactory; diff --git a/hibernate-core/src/main/java/org/hibernate/stat/SessionStatisticsImpl.java b/hibernate-core/src/main/java/org/hibernate/stat/internal/SessionStatisticsImpl.java similarity index 90% rename from hibernate-core/src/main/java/org/hibernate/stat/SessionStatisticsImpl.java rename to hibernate-core/src/main/java/org/hibernate/stat/internal/SessionStatisticsImpl.java index 70c6c24cfb..3b60ebf6f9 100755 --- a/hibernate-core/src/main/java/org/hibernate/stat/SessionStatisticsImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/stat/internal/SessionStatisticsImpl.java @@ -1,10 +1,10 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as + * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as * indicated by the @author tags or express copyright attribution * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat Middleware LLC. + * distributed under license by Red Hat Inc. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU @@ -20,12 +20,14 @@ * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA - * */ -package org.hibernate.stat; +package org.hibernate.stat.internal; + import java.util.Collections; import java.util.Set; + import org.hibernate.engine.SessionImplementor; +import org.hibernate.stat.SessionStatistics; /** * @author Gavin King diff --git a/hibernate-core/src/main/java/org/hibernate/stat/package.html b/hibernate-core/src/main/java/org/hibernate/stat/package.html index 8fcebc6574..85468ead3c 100755 --- a/hibernate-core/src/main/java/org/hibernate/stat/package.html +++ b/hibernate-core/src/main/java/org/hibernate/stat/package.html @@ -27,8 +27,7 @@

- This package exposes statistics about a running - Hibernate instance to the application. + This package exposes statistics about a running Hibernate instance to the application.

diff --git a/hibernate-core/src/main/java/org/hibernate/stat/StatisticsImplementor.java b/hibernate-core/src/main/java/org/hibernate/stat/spi/StatisticsImplementor.java similarity index 97% rename from hibernate-core/src/main/java/org/hibernate/stat/StatisticsImplementor.java rename to hibernate-core/src/main/java/org/hibernate/stat/spi/StatisticsImplementor.java index 88a6310b7b..21970d17c5 100644 --- a/hibernate-core/src/main/java/org/hibernate/stat/StatisticsImplementor.java +++ b/hibernate-core/src/main/java/org/hibernate/stat/spi/StatisticsImplementor.java @@ -21,8 +21,9 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.stat; +package org.hibernate.stat.spi; +import org.hibernate.stat.Statistics; /** * Statistics SPI for the Hibernate core. This is essentially the "statistic collector" API, its the contract @@ -30,7 +31,7 @@ package org.hibernate.stat; * * @author Emmanuel Bernard */ -public interface StatisticsImplementor { +public interface StatisticsImplementor extends Statistics { /** * Callback about a session being opened. */ diff --git a/hibernate-core/src/test/java/org/hibernate/test/common/TransactionEnvironmentImpl.java b/hibernate-core/src/test/java/org/hibernate/test/common/TransactionEnvironmentImpl.java index f1267b2698..ebc840dd5f 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/common/TransactionEnvironmentImpl.java +++ b/hibernate-core/src/test/java/org/hibernate/test/common/TransactionEnvironmentImpl.java @@ -30,8 +30,8 @@ import org.hibernate.engine.transaction.spi.TransactionEnvironment; import org.hibernate.engine.transaction.spi.TransactionFactory; import org.hibernate.service.jta.platform.spi.JtaPlatform; import org.hibernate.service.spi.ServiceRegistry; -import org.hibernate.stat.ConcurrentStatisticsImpl; -import org.hibernate.stat.StatisticsImplementor; +import org.hibernate.stat.internal.ConcurrentStatisticsImpl; +import org.hibernate.stat.spi.StatisticsImplementor; /** * @author Steve Ebersole