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  
17  package net.sf.ehcache.management.sampled;
18  
19  import java.util.Map;
20  
21  /***
22   * An MBean for CacheManager exposing sampled cache usage statistics
23   *
24   * <p />
25   *
26   * @author <a href="mailto:asanoujam@terracottatech.com">Abhishek Sanoujam</a>
27   * @since 1.7
28   */
29  public interface SampledCacheManagerMBean {
30      /***
31       * CACHES_ENABLED
32       */
33      final String CACHES_ENABLED = "CachesEnabled";
34  
35      /***
36       * CACHES_CLEARED
37       */
38      final String CACHES_CLEARED = "CachesCleared";
39  
40      /***
41       * STATISTICS_RESET
42       */
43      final String STATISTICS_RESET = "StatisticsReset";
44  
45      /***
46       * STATISTICS_ENABLED
47       */
48      final String STATISTICS_ENABLED = "StatisticsEnabled";
49  
50      /***
51       * Gets the actual name of the cache manager. This may be different from the
52       * name used to register this mbean as there can potentially be multiple
53       * cache managers with same name
54       */
55      String getName();
56  
57      /***
58       * Gets the name used to register this mbean.
59       */
60      String getMBeanRegisteredName();
61  
62      /***
63       * Gets the status attribute of the Ehcache
64       *
65       * @return The status value, as a String from the Status enum class
66       */
67      String getStatus();
68  
69      /***
70       * Enables/disables each cache contained by this CacheManager
71       *
72       * @param enabled
73       */
74      void setEnabled(boolean enabled);
75  
76      /***
77       * Returns if each cache is enabled.
78       *
79       * @return boolean indicating that each cache is enabled
80       */
81      boolean isEnabled();
82  
83      /***
84       * Shuts down the CacheManager.
85       * <p/>
86       * If the shutdown occurs on the singleton, then the singleton is removed, so that if a singleton access method is called, a new
87       * singleton will be created.
88       */
89      void shutdown();
90  
91      /***
92       * Clears the contents of all caches in the CacheManager, but without
93       * removing any caches.
94       * <p/>
95       * This method is not synchronized. It only guarantees to clear those elements in a cache at the time that the
96       * {@link net.sf.ehcache.Ehcache#removeAll()} mehod on each cache is called.
97       */
98      void clearAll();
99  
100     /***
101      * Gets the cache names managed by the CacheManager
102      */
103     String[] getCacheNames() throws IllegalStateException;
104 
105     /***
106      * Get a map of cache name to performance metrics (hits, misses).
107      *
108      * @return a map of cache metrics
109      */
110     Map<String, long[]> getCacheMetrics();
111 
112     /***
113      * @return aggregate hit rate
114      */
115     long getCacheHitRate();
116 
117     /***
118      * @return aggregate in-memory hit rate
119      */
120     long getCacheInMemoryHitRate();
121 
122     /***
123      * @return aggregate off-heap hit rate
124      */
125     long getCacheOffHeapHitRate();
126 
127     /***
128      * @return aggregate on-disk hit rate
129      */
130     long getCacheOnDiskHitRate();
131 
132     /***
133      * @return aggregate miss rate
134      */
135     long getCacheMissRate();
136 
137     /***
138      * @return aggregate in-memory miss rate
139      */
140     long getCacheInMemoryMissRate();
141 
142     /***
143      * @return aggregate off-heap miss rate
144      */
145     long getCacheOffHeapMissRate();
146 
147     /***
148      * @return aggregate on-disk miss rate
149      */
150     long getCacheOnDiskMissRate();
151 
152     /***
153      * @return aggregate put rate
154      */
155     long getCachePutRate();
156 
157     /***
158      * @return aggregate update rate
159      */
160     long getCacheUpdateRate();
161 
162     /***
163      * @return aggregate remove rate
164      */
165     long getCacheRemoveRate();
166 
167     /***
168      * @return aggregate eviction rate
169      */
170     long getCacheEvictionRate();
171 
172     /***
173      * @return aggregate expiration rate
174      */
175     long getCacheExpirationRate();
176 
177     /***
178      * @return aggregate average get time (ms.)
179      */
180     float getCacheAverageGetTime();
181 
182     /***
183      * @return if any contained caches are configured for search
184      */
185     boolean getSearchable();
186 
187     /***
188      * @return aggregate search rate
189      */
190     long getCacheSearchRate();
191 
192     /***
193      * @return aggregate search time
194      */
195     long getCacheAverageSearchTime();
196 
197     /***
198      * Clears statistics of all caches for the associated cacheManager
199      */
200     void clearStatistics();
201 
202     /***
203      * Enable statistics for each cache contained by cacheManager
204      */
205     void enableStatistics();
206 
207     /***
208      * Disable statistics for each cache contained by cacheManager
209      */
210     void disableStatistics();
211 
212     /***
213      * Enables/disables each contained cache
214      */
215     void setStatisticsEnabled(boolean enabled);
216 
217     /***
218      * Returns true iff each contained cache has statistics enabled
219      */
220     boolean isStatisticsEnabled();
221 
222     /***
223      * generateActiveConfigDeclaration
224      *
225      * @return CacheManager configuration as String
226      */
227     String generateActiveConfigDeclaration();
228 
229     /***
230      * generateActiveConfigDeclaration
231      *
232      * @param cacheName
233      * @return Cache configuration as String
234      */
235     String generateActiveConfigDeclaration(String cacheName);
236 
237     /***
238      * Are any of the caches transactional
239      * @see net.sf.ehcache.config.CacheConfiguration.TransactionalMode
240      */
241     boolean getTransactional();
242 
243     /***
244      * Get the committed transactions count
245      * @return the committed transactions count
246      */
247     long getTransactionCommittedCount();
248 
249     /***
250      * @return aggregate Xa commit rate
251      */
252     long getTransactionCommitRate();
253 
254     /***
255      * Get the rolled back transactions count
256      * @return the rolled back transactions count
257      */
258     long getTransactionRolledBackCount();
259 
260     /***
261      * @return aggregate Xa rollback rate
262      */
263     long getTransactionRollbackRate();
264 
265     /***
266      * Get the timed out transactions count. Note that only transactions which failed to
267      * commit due to a timeout are taken into account
268      * @return the timed out transactions count
269      */
270     long getTransactionTimedOutCount();
271 
272     /***
273      * Returns whether any caches are configured for write-behind
274      */
275     boolean getHasWriteBehindWriter();
276 
277     /***
278      * Returns the total length of all write-behind queues across all caches
279      * @return aggregate writer-behind queue length
280      */
281     long getWriterQueueLength();
282 
283     /***
284      * Maximum elements that can be queued for processing by the write-behind writer
285      * @return aggregate of the maximum elements that can be waiting to be processed
286      * by the write-behind writer across all caches
287      */
288     int getWriterMaxQueueSize();
289 
290     /***
291      * Maximum number of bytes of entries in the disk stores of all caches that
292      * did not declare their own max size.
293      *
294      * @return maximum number of bytes in the disk stores of all caches that
295      * did not declare their own max size.
296      */
297     long getMaxBytesLocalDisk();
298 
299     /***
300      * Maximum number of bytes of entries in the heap memory stores of all caches that
301      * did not declare their own max size.
302      *
303      * @return maximum number of bytes in the heap memory stores of all caches that
304      * did not declare their own max size.
305      */
306     long getMaxBytesLocalHeap();
307 
308     /***
309      * Maximum number of bytes of entries in the off-heap stores of all caches that
310      * did not declare their own max size.
311      *
312      * @return maximum number of bytes in the off-heap stores of all caches that
313      * did not declare their own max size.
314      */
315     long getMaxBytesLocalOffHeap();
316 }