001: //$Id: Statistics.java 8262 2005-09-30 07:48:53Z oneovthafew $
002: package org.hibernate.stat;
003:
004: /**
005: * Statistics for a particular <tt>SessionFactory</tt>.
006: * Beware of milliseconds metrics, they are depdendent of the JVM precision:
007: * you may then encounter a 10 ms approximation dending on you OS platform.
008: * Please refer to the JVM documentation for more information.
009: *
010: * @author Emmanuel Bernard
011: */
012: public interface Statistics {
013: /**
014: * reset all statistics
015: */
016: public void clear();
017:
018: /**
019: * find entity statistics per name
020: *
021: * @param entityName entity name
022: * @return EntityStatistics object
023: */
024: public EntityStatistics getEntityStatistics(String entityName);
025:
026: /**
027: * Get collection statistics per role
028: *
029: * @param role collection role
030: * @return CollectionStatistics
031: */
032: public CollectionStatistics getCollectionStatistics(String role);
033:
034: /**
035: * Second level cache statistics per region
036: *
037: * @param regionName region name
038: * @return SecondLevelCacheStatistics
039: */
040: public SecondLevelCacheStatistics getSecondLevelCacheStatistics(
041: String regionName);
042:
043: /**
044: * Query statistics from query string (HQL or SQL)
045: *
046: * @param queryString query string
047: * @return QueryStatistics
048: */
049: public QueryStatistics getQueryStatistics(String queryString);
050:
051: /**
052: * Get global number of entity deletes
053: * @return entity deletion count
054: */
055: public long getEntityDeleteCount();
056:
057: /**
058: * Get global number of entity inserts
059: * @return entity insertion count
060: */
061: public long getEntityInsertCount();
062:
063: /**
064: * Get global number of entity loads
065: * @return entity load (from DB)
066: */
067: public long getEntityLoadCount();
068:
069: /**
070: * Get global number of entity fetchs
071: * @return entity fetch (from DB)
072: */
073: public long getEntityFetchCount();
074:
075: /**
076: * Get global number of entity updates
077: * @return entity update
078: */
079: public long getEntityUpdateCount();
080:
081: /**
082: * Get global number of executed queries
083: * @return query execution count
084: */
085: public long getQueryExecutionCount();
086:
087: /**
088: * Get the time in milliseconds of the slowest query.
089: */
090: public long getQueryExecutionMaxTime();
091:
092: /**
093: * Get the query string for the slowest query.
094: */
095: public String getQueryExecutionMaxTimeQueryString();
096:
097: /**
098: * Get the global number of cached queries successfully retrieved from cache
099: */
100: public long getQueryCacheHitCount();
101:
102: /**
103: * Get the global number of cached queries *not* found in cache
104: */
105: public long getQueryCacheMissCount();
106:
107: /**
108: * Get the global number of cacheable queries put in cache
109: */
110: public long getQueryCachePutCount();
111:
112: /**
113: * Get the global number of flush executed by sessions (either implicit or explicit)
114: */
115: public long getFlushCount();
116:
117: /**
118: * Get the global number of connections asked by the sessions
119: * (the actual number of connections used may be much smaller depending
120: * whether you use a connection pool or not)
121: */
122: public long getConnectCount();
123:
124: /**
125: * Global number of cacheable entities/collections successfully retrieved from the cache
126: */
127: public long getSecondLevelCacheHitCount();
128:
129: /**
130: * Global number of cacheable entities/collections not found in the cache and loaded from the database.
131: */
132: public long getSecondLevelCacheMissCount();
133:
134: /**
135: * Global number of cacheable entities/collections put in the cache
136: */
137: public long getSecondLevelCachePutCount();
138:
139: /**
140: * Global number of sessions closed
141: */
142: public long getSessionCloseCount();
143:
144: /**
145: * Global number of sessions opened
146: */
147: public long getSessionOpenCount();
148:
149: /**
150: * Global number of collections loaded
151: */
152: public long getCollectionLoadCount();
153:
154: /**
155: * Global number of collections fetched
156: */
157: public long getCollectionFetchCount();
158:
159: /**
160: * Global number of collections updated
161: */
162: public long getCollectionUpdateCount();
163:
164: /**
165: * Global number of collections removed
166: */
167: //even on inverse="true"
168: public long getCollectionRemoveCount();
169:
170: /**
171: * Global number of collections recreated
172: */
173: public long getCollectionRecreateCount();
174:
175: /**
176: * @return start time in ms (JVM standards {@link System#currentTimeMillis()})
177: */
178: public long getStartTime();
179:
180: /**
181: * log in info level the main statistics
182: */
183: public void logSummary();
184:
185: /**
186: * Are statistics logged
187: */
188: public boolean isStatisticsEnabled();
189:
190: /**
191: * Enable statistics logs (this is a dynamic parameter)
192: */
193: public void setStatisticsEnabled(boolean b);
194:
195: /**
196: * Get all executed query strings
197: */
198: public String[] getQueries();
199:
200: /**
201: * Get the names of all entities
202: */
203: public String[] getEntityNames();
204:
205: /**
206: * Get the names of all collection roles
207: */
208: public String[] getCollectionRoleNames();
209:
210: /**
211: * Get all second-level cache region names
212: */
213: public String[] getSecondLevelCacheRegionNames();
214:
215: /**
216: * The number of transactions we know to have been successful
217: */
218: public long getSuccessfulTransactionCount();
219:
220: /**
221: * The number of transactions we know to have completed
222: */
223: public long getTransactionCount();
224:
225: /**
226: * The number of prepared statements that were acquired
227: */
228: public long getPrepareStatementCount();
229:
230: /**
231: * The number of prepared statements that were released
232: */
233: public long getCloseStatementCount();
234:
235: /**
236: * The number of <tt>StaleObjectStateException</tt>s
237: * that occurred
238: */
239: public long getOptimisticFailureCount();
240: }
|