1 /**
2  *  Copyright 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
17 package net.sf.ehcache.statistics;
18
19 import net.sf.ehcache.CacheException;
20 import net.sf.ehcache.Ehcache;
21 import net.sf.ehcache.Element;
22 import net.sf.ehcache.Statistics;
23
24 /**
25  * A no-op implementation which can be used both as a {@link LiveCacheStatistics} and {@link LiveCacheStatisticsData}
26  *
27  * @author <a href="mailto:asanoujam@terracottatech.com">Abhishek Sanoujam</a>
28  * @since 1.7
29  */

30 public class NullLiveCacheStatisticsData implements LiveCacheStatistics, LiveCacheStatisticsData {
31
32     /**
33      * {@inheritDoc}
34      */

35     public String getCacheName() {
36         return "_unknown_";
37     }
38
39     /**
40      * {@inheritDoc}
41      */

42     public float getAverageGetTimeMillis() {
43         return 0;
44     }
45
46     /**
47      * {@inheritDoc}
48      */

49     public long getCacheHitCount() {
50         return 0;
51     }
52
53     /**
54      * {@inheritDoc}
55      */

56     public long getCacheMissCount() {
57         return 0;
58     }
59
60     /**
61      * {@inheritDoc}
62      */

63     public long getInMemoryMissCount() {
64         return 0;
65     }
66
67     /**
68      * {@inheritDoc}
69      */

70     public long getOffHeapMissCount() {
71         return 0;
72     }
73
74     /**
75      * {@inheritDoc}
76      */

77     public long getOnDiskMissCount() {
78         return 0;
79     }
80
81     /**
82      * {@inheritDoc}
83      */

84     public long getCacheMissCountExpired() {
85         return 0;
86     }
87
88     /**
89      * {@inheritDoc}
90      */

91     public long getEvictedCount() {
92         return 0;
93     }
94
95     /**
96      * {@inheritDoc}
97      */

98     public long getExpiredCount() {
99         return 0;
100     }
101
102     /**
103      * {@inheritDoc}
104      */

105     public long getInMemoryHitCount() {
106         return 0;
107     }
108
109     /**
110      * {@inheritDoc}
111      * @deprecated see {@link #getLocalHeapSize()}
112      */

113     @Deprecated
114     public long getInMemorySize() {
115         return 0;
116     }
117
118     /**
119      * {@inheritDoc}
120      */

121     public long getOffHeapHitCount() {
122         return 0;
123     }
124
125     /**
126      * {@inheritDoc}
127      * @deprecated see {@link #getLocalOffHeapSize()}
128      */

129     @Deprecated
130     public long getOffHeapSize() {
131         return 0;
132     }
133
134     /**
135      * {@inheritDoc}
136      */

137     public long getOnDiskHitCount() {
138         return 0;
139     }
140
141     /**
142      * {@inheritDoc}
143      * @deprecated see {@link #getLocalDiskSize()}
144      */

145     @Deprecated
146     public long getOnDiskSize() {
147         return 0;
148     }
149
150     /**
151      * {@inheritDoc}
152      */

153     public long getLocalHeapSize() {
154         return 0;
155     }
156
157     /**
158      * {@inheritDoc}
159      */

160     public long getLocalOffHeapSize() {
161         return 0;
162     }
163
164     /**
165      * {@inheritDoc}
166      */

167     public long getLocalDiskSize() {
168         return 0;
169     }
170
171     /**
172      * {@inheritDoc}
173      */

174     public long getLocalHeapSizeInBytes() {
175         return 0;
176     }
177
178     /**
179      * {@inheritDoc}
180      */

181     public long getLocalOffHeapSizeInBytes() {
182         return 0;
183     }
184
185     /**
186      * {@inheritDoc}
187      */

188     public long getLocalDiskSizeInBytes() {
189         return 0;
190     }
191
192     /**
193      * {@inheritDoc}
194      */

195     public long getPutCount() {
196         return 0;
197     }
198
199     /**
200      * {@inheritDoc}
201      */

202     public long getRemovedCount() {
203         return 0;
204     }
205
206     /**
207      * {@inheritDoc}
208      */

209     public long getSize() {
210         return 0;
211     }
212
213     /**
214      * {@inheritDoc}
215      */

216     public int getStatisticsAccuracy() {
217         return Statistics.STATISTICS_ACCURACY_NONE;
218     }
219
220     /**
221      * {@inheritDoc}
222      */

223     public String getStatisticsAccuracyDescription() {
224         return "None";
225     }
226
227     /**
228      * {@inheritDoc}
229      */

230     public long getUpdateCount() {
231         return 0;
232     }
233
234     /**
235      * {@inheritDoc}
236      */

237     public boolean isStatisticsEnabled() {
238         return false;
239     }
240
241     /**
242      * {@inheritDoc}
243      */

244     public void addGetTimeMillis(long millis) {
245         // no-op
246     }
247
248     /**
249      * {@inheritDoc}
250      */

251     public void cacheHitInMemory() {
252         // no-op
253     }
254
255     /**
256      * {@inheritDoc}
257      */

258     public void cacheHitOffHeap() {
259         // no-op
260     }
261
262     /**
263      * {@inheritDoc}
264      */

265     public void cacheHitOnDisk() {
266         // no-op
267     }
268
269     /**
270      * {@inheritDoc}
271      */

272     public void cacheMissExpired() {
273         // no-op
274     }
275
276     /**
277      * {@inheritDoc}
278      */

279     public void xaCommit() {
280         // no-op
281     }
282
283     /**
284      * {@inheritDoc}
285      */

286     public void xaRollback() {
287         // no-op
288     }
289
290     /**
291      * {@inheritDoc}
292      */

293     public void xaRecovered(int count) {
294         // no-op
295     }
296
297     /**
298      * {@inheritDoc}
299      */

300     public void cacheMissNotFound() {
301         // no-op
302     }
303
304     /**
305      * {@inheritDoc}
306      */

307     public void cacheMissInMemory() {
308         // no-op
309     }
310
311     /**
312      * {@inheritDoc}
313      */

314     public void cacheMissOffHeap() {
315         // no-op
316     }
317
318     /**
319      * {@inheritDoc}
320      */

321     public void cacheMissOnDisk() {
322         // no-op
323     }
324
325     /**
326      * {@inheritDoc}
327      */

328     public void clearStatistics() {
329         // no-op
330     }
331
332     /**
333      * {@inheritDoc}
334      */

335     public void registerCacheUsageListener(CacheUsageListener cacheUsageListener) throws IllegalStateException {
336         // no-op
337     }
338
339     /**
340      * {@inheritDoc}
341      */

342
343     public void removeCacheUsageListener(CacheUsageListener cacheUsageListener) throws IllegalStateException {
344         // no-op
345     }
346
347     /**
348      * {@inheritDoc}
349      */

350     public void setStatisticsAccuracy(int statisticsAccuracy) {
351         // no-op
352     }
353
354     /**
355      * {@inheritDoc}
356      */

357     public void setStatisticsEnabled(boolean enableStatistics) {
358         // no-op
359     }
360
361     /**
362      * {@inheritDoc}
363      */

364     public void dispose() {
365         // no-op
366     }
367
368     /**
369      * {@inheritDoc}
370      */

371     public void notifyElementEvicted(Ehcache cache, Element element) {
372         // no-op
373     }
374
375     /**
376      * {@inheritDoc}
377      */

378     public void notifyElementExpired(Ehcache cache, Element element) {
379         // no-op
380     }
381
382     /**
383      * {@inheritDoc}
384      */

385     public void notifyElementPut(Ehcache cache, Element element) throws CacheException {
386         // no-op
387     }
388
389     /**
390      * {@inheritDoc}
391      */

392
393     public void notifyElementRemoved(Ehcache cache, Element element) throws CacheException {
394         // no-op
395     }
396
397     /**
398      * {@inheritDoc}
399      */

400     public void notifyElementUpdated(Ehcache cache, Element element) throws CacheException {
401         // no-op
402     }
403
404     /**
405      * {@inheritDoc}
406      */

407     public void notifyRemoveAll(Ehcache cache) {
408         // no-op
409     }
410
411     /**
412      * {@inheritDoc}
413      */

414     @Override
415     public Object clone() throws CloneNotSupportedException {
416         super.clone();
417         return this;
418     }
419
420     /**
421      * {@inheritDoc}
422      */

423     public long getMaxGetTimeMillis() {
424         return 0;
425     }
426
427     /**
428      * {@inheritDoc}
429      *
430      * but returns 0, always!
431      */

432     public long getWriterQueueLength() {
433         return 0;
434     }
435
436     /**
437      * {@inheritDoc}
438      */

439     public long getXaCommitCount() {
440         return 0;
441     }
442
443     /**
444      * {@inheritDoc}
445      */

446     public long getXaRollbackCount() {
447         return 0;
448     }
449
450     /**
451      * {@inheritDoc}
452      */

453     public long getXaRecoveredCount() {
454         return 0;
455     }
456
457     /**
458      * {@inheritDoc}
459      */

460     public long getMinGetTimeMillis() {
461         return 0;
462     }
463
464     /**
465      * {@inheritDoc}
466      */

467     public void addGetTimeNanos(long nanos) {
468         /**/
469     }
470
471     /**
472      * {@inheritDoc}
473      */

474     public int getCacheHitRatio() {
475         return 0;
476     }
477
478     /**
479      * {@inheritDoc}
480      */

481     public long getAverageGetTimeNanos() {
482         return 0;
483     }
484
485     /**
486      * {@inheritDoc}
487      */

488     public long getMaxGetTimeNanos() {
489         return 0;
490     }
491
492     /**
493      * {@inheritDoc}
494      */

495     public long getMinGetTimeNanos() {
496         return 0;
497     }
498 }
499