View Javadoc

1   /**
2    *  Copyright 2003-2007 Greg Luck
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.management;
18  
19  /**
20   * @author Greg Luck
21   * @version $Id: CacheStatisticsMBean.java 512 2007-07-10 09:18:45Z gregluck $
22   * @since 1.3
23   */
24  public interface CacheStatisticsMBean {
25  
26      /**
27       * Clears the statistic counters to 0 for the associated Cache.
28       */
29      public void clearStatistics();
30  
31      /**
32       * The number of times a requested item was found in the cache.
33       *
34       * @return the number of times a requested item was found in the cache
35       */
36      public long getCacheHits();
37  
38      /**
39       * Number of times a requested item was found in the Memory Store.
40       *
41       * @return the number of times a requested item was found in memory
42       */
43      public long getInMemoryHits();
44  
45      /**
46       * Number of times a requested item was found in the Disk Store.
47       *
48       * @return the number of times a requested item was found on Disk, or 0 if there is no disk storage configured.
49       */
50      public long getOnDiskHits();
51  
52      /**
53       * @return the number of times a requested element was not found in the cache
54       */
55      public long getCacheMisses();
56  
57      /**
58       * Gets the number of elements stored in the cache. Caclulating this can be expensive. Accordingly,
59       * this method will return three different values, depending on the statistics accuracy setting.
60       * <h3>Best Effort Size</h3>
61       * This result is returned when the statistics accuracy setting is {@link net.sf.ehcache.Statistics#STATISTICS_ACCURACY_BEST_EFFORT}.
62       * <p/>
63       * The size is the number of {@link net.sf.ehcache.Element}s in the {@link net.sf.ehcache.store.MemoryStore} plus
64       * the number of {@link net.sf.ehcache.Element}s in the {@link net.sf.ehcache.store.DiskStore}.
65       * <p/>
66       * This number is the actual number of elements, including expired elements that have
67       * not been removed. Any duplicates between stores are accounted for.
68       * <p/>
69       * Expired elements are removed from the the memory store when
70       * getting an expired element, or when attempting to spool an expired element to
71       * disk.
72       * <p/>
73       * Expired elements are removed from the disk store when getting an expired element,
74       * or when the expiry thread runs, which is once every five minutes.
75       * <p/>
76       * <h3>Guaranteed Accuracy Size</h3>
77       * This result is returned when the statistics accuracy setting is {@link net.sf.ehcache.Statistics#STATISTICS_ACCURACY_GUARANTEED}.
78       * <p/>
79       * This method accounts for elements which might be expired or duplicated between stores. It take approximately
80       * 200ms per 1000 elements to execute.
81       * <h3>Fast but non-accurate Size</h3>
82       * This result is returned when the statistics accuracy setting is {@link net.sf.ehcache.Statistics#STATISTICS_ACCURACY_NONE}.
83       * <p/>
84       * The number given may contain expired elements. In addition if the DiskStore is used it may contain some double
85       * counting of elements. It takes 6ms for 1000 elements to execute. Time to execute is O(log n). 50,000 elements take
86       * 36ms.
87       *
88       * @return the number of elements in the ehcache, with a varying degree of accuracy, depending on accuracy setting.
89       */
90      public long getObjectCount();
91  
92      /**
93       * Accurately measuring statistics can be expensive. Returns the current accuracy setting.
94       *
95       * @return one of {@link net.sf.ehcache.Statistics#STATISTICS_ACCURACY_BEST_EFFORT},
96       *         {@link net.sf.ehcache.Statistics#STATISTICS_ACCURACY_GUARANTEED},
97       *         {@link net.sf.ehcache.Statistics#STATISTICS_ACCURACY_NONE}
98       */
99      public int getStatisticsAccuracy();
100 
101 
102     /**
103      * Accurately measuring statistics can be expensive. Returns the current accuracy setting.
104      * @return a human readable description of the accuracy setting. One of "None", "Best Effort" or "Guaranteed".
105      */
106     public String getStatisticsAccuracyDescription();
107 
108     /**
109      * @return the name of the Ehcache, or null is there no associated cache
110      */
111     public String getAssociatedCacheName();
112 
113 }