View Javadoc

1   /***
2    *  Copyright 2003-2010 Terracotta, Inc.
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  package net.sf.ehcache.statistics;
17  
18  /***
19   * Interface for usage statistics of a Cache.
20   *
21   * <p />
22   * Implementations of this interface is different from {@link net.sf.ehcache.Statistics} in the way that values returned from this interface
23   * implementations will reflect the current state of the cache and not a snapshot of the cache when the api's were called (which is the
24   * behavior of {@link net.sf.ehcache.Statistics})
25   * <p />
26   *
27   * @author <a href="mailto:asanoujam@terracottatech.com">Abhishek Sanoujam</a>
28   * @since 1.7
29   */
30  public interface LiveCacheStatistics {
31  
32      /***
33       * Returns true if statistics is enabled
34       *
35       * @return true if statistics is enabled
36       */
37      boolean isStatisticsEnabled();
38  
39      /***
40       * The number of times a requested item was found in the cache.
41       *
42       * @return the number of times a requested item was found in the cache
43       */
44      long getCacheHitCount();
45  
46      /***
47       * Number of times a requested item was found in the Memory Store.
48       *
49       * @return the number of times a requested item was found in memory
50       */
51      long getInMemoryHitCount();
52  
53      /***
54       * Number of times a requested item was found in the off-heap store.
55       *
56       * @return the number of times a requested item was found in off-heap
57       */
58      long getOffHeapHitCount();
59  
60      /***
61       * Number of times a requested item was found in the Disk Store.
62       *
63       * @return the number of times a requested item was found on Disk, or 0 if
64       *         there is no disk storage configured.
65       */
66      long getOnDiskHitCount();
67  
68      /***
69       * Number of times a requested element was not found in the cache.
70       *
71       * @return the number of times a requested element was not found in the
72       *         cache
73       */
74      long getCacheMissCount();
75  
76      /***
77       * Number of times a requested item was not found in the Memory Store.
78       *
79       * @return the number of times a requested item was not found in memory
80       */
81      long getInMemoryMissCount();
82  
83      /***
84       * Number of times a requested item was not found in the off-heap store.
85       *
86       * @return the number of times a requested item was not found in off-heap
87       */
88      long getOffHeapMissCount();
89  
90      /***
91       * Number of times a requested item was not found in the Disk Store.
92       *
93       * @return the number of times a requested item was not found on Disk, or 0 if
94       *         there is no disk storage configured.
95       */
96      long getOnDiskMissCount();
97  
98      /***
99       * @return the number of times a requested element was not found in the
100      *         cache and the reason being the element already expired
101      */
102     long getCacheMissCountExpired();
103 
104     /***
105      * Size of the cache based on current accuracy settings.
106      *
107      * @return The size of the cache based on current accuracy setting
108      */
109     long getSize();
110 
111     /***
112      * Number of elements in the MemoryStore
113      *
114      * @return the number of elements in memory
115      * @deprecated use {@link #getLocalHeapSize()}
116      */
117     @Deprecated
118     long getInMemorySize();
119 
120     /***
121      * Number of elements in the off-heap store
122      *
123      * @return the number of elements in off-heap
124      * @deprecated use {@link #getLocalOffHeapSize()}
125      */
126     @Deprecated
127     long getOffHeapSize();
128 
129     /***
130      * Number of elements in the DiskStore
131      *
132      * @return number of elements on disk
133      * @deprecated use {@link #getLocalDiskSize()}
134      */
135     @Deprecated
136     long getOnDiskSize();
137 
138     /***
139      * Number of entries in the MemoryStore
140      *
141      * @return the number of elements in memory
142      */
143     long getLocalHeapSize();
144 
145     /***
146      * Number of entries in the off-heap store
147      *
148      * @return the number of elements in off-heap
149      */
150     long getLocalOffHeapSize();
151 
152     /***
153      * Number of entries in the DiskStore
154      *
155      * @return number of elements on disk
156      */
157     long getLocalDiskSize();
158 
159     /***
160      * Number of of bytes used by entries in the MemoryStore
161      *
162      * @return the number of of bytes used by elements in memory
163      */
164     long getLocalHeapSizeInBytes();
165 
166     /***
167      * Number of of bytes used by entries in the off-heap store
168      *
169      * @return the number of of bytes used by elements in off-heap
170      */
171     long getLocalOffHeapSizeInBytes();
172 
173     /***
174      * Number of of bytes used by entries in the DiskStore
175      *
176      * @return number of bytes used by elements on disk
177      */
178     long getLocalDiskSizeInBytes();
179 
180     /***
181      * Average time in milli seconds taken to get an element from the cache.
182      *
183      * @return Average time taken for a get operation in milliseconds
184      */
185     float getAverageGetTimeMillis();
186 
187     /***
188      * Number of elements evicted from the cache
189      *
190      * @return Number of elements evicted from the cache
191      */
192     long getEvictedCount();
193 
194     /***
195      * Number of puts that has happened in the cache
196      *
197      * @return Number of puts
198      */
199     long getPutCount();
200 
201     /***
202      * Number of updates that as happened in the cache
203      *
204      * @return Number of updates
205      */
206     long getUpdateCount();
207 
208     /***
209      * Number of elements expired since creation or last clear
210      *
211      * @return Number of expired elements
212      */
213     long getExpiredCount();
214 
215     /***
216      * Number of elements removed since creation or last clear
217      *
218      * @return Number of elements removed
219      */
220     long getRemovedCount();
221 
222     /***
223      * Accurately measuring statistics can be expensive. Returns the current
224      * accuracy setting.
225      *
226      * @return one of Statistics.STATISTICS_ACCURACY_BEST_EFFORT,
227      *         Statistics.STATISTICS_ACCURACY_GUARANTEED,
228      *         Statistics.STATISTICS_ACCURACY_NONE
229      */
230     int getStatisticsAccuracy();
231 
232     /***
233      * Accurately measuring statistics can be expensive. Returns the current
234      * accuracy setting.
235      *
236      * @return a human readable description of the accuracy setting. One of
237      *         "None", "Best Effort" or "Guaranteed".
238      */
239     String getStatisticsAccuracyDescription();
240 
241     /***
242      * @return the name of the Ehcache
243      */
244     String getCacheName();
245 
246     /***
247      * Clears statistics of this cache
248      */
249     void clearStatistics();
250 
251     /***
252      * Return minimum time taken for a get operation in the cache in milliseconds
253      *
254      * @return minimum time taken for a get operation in the cache in milliseconds
255      */
256     long getMinGetTimeMillis();
257 
258     /***
259      * Return maximum time taken for a get operation in the cache in milliseconds
260      *
261      * @return maximum time taken for a get operation in the cache in milliseconds
262      */
263     long getMaxGetTimeMillis();
264 
265     /***
266      * Gets the size of the write-behind queue, if any.
267      * The value is for all local buckets
268      * @return Elements waiting to be processed by the write-behind writer. -1 if no write-behind
269      */
270     long getWriterQueueLength();
271 
272     /***
273      * Return the Cache's XAResource commit calls count
274      * @return the Cache's XAResource commit calls count
275      */
276     long getXaCommitCount();
277 
278     /***
279      * Return the Cache's XAResource rollback calls count
280      * @return the Cache's XAResource rollback calls count
281      */
282     long getXaRollbackCount();
283 
284 }