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 net.sf.ehcache.statistics.LiveCacheStatistics;
20  import net.sf.ehcache.statistics.sampled.SampledCacheStatistics;
21  
22  /***
23   * An MBean for Cache exposing cache statistics.
24   * Extends from both {@link LiveCacheStatistics} and {@link SampledCacheStatistics}
25   *
26   * <p />
27   *
28   * @author <a href="mailto:asanoujam@terracottatech.com">Abhishek Sanoujam</a>
29   * @since 1.7
30   */
31  public interface SampledCacheMBean extends LiveCacheStatistics, SampledCacheStatistics {
32      /***
33       * CACHE_ENABLED
34       */
35      final String CACHE_ENABLED = "CacheEnabled";
36  
37      /***
38       * CACHE_CHANGED
39       */
40      final String CACHE_CHANGED = "CacheChanged";
41  
42      /***
43       * CACHE_FLUSHED
44       */
45      final String CACHE_FLUSHED = "CacheFlushed";
46  
47      /***
48       * CACHE_CLEARED
49       */
50      final String CACHE_CLEARED = "CacheCleared";
51  
52      /***
53       * CACHE_STATISTICS_ENABLED
54       */
55      final String CACHE_STATISTICS_ENABLED = "CacheStatisticsEnabled";
56  
57      /***
58       * CACHE_STATISTICS_RESET
59       */
60      final String CACHE_STATISTICS_RESET = "CacheStatisticsReset";
61  
62      /***
63       * Is the cache enabled?
64       */
65      boolean isEnabled();
66  
67      /***
68       * Enabled/disable cache coherence mode for this node.
69       * @deprecated use {@link #setNodeBulkLoadEnabled(boolean)} instead
70       */
71      @Deprecated
72      void setNodeCoherent(boolean coherent);
73  
74      /***
75       * Enabled/disable bulk-load mode for this node.
76       */
77      void setNodeBulkLoadEnabled(boolean bulkLoadEnabled);
78  
79      /***
80       * Is the cache coherent cluster-wide?
81       * @deprecated use {@link #isClusterBulkLoadEnabled()} instead
82       */
83      @Deprecated
84      boolean isClusterCoherent();
85  
86      /***
87       * Is the cache in bulk-load mode cluster-wide?
88       */
89      boolean isClusterBulkLoadEnabled();
90  
91      /***
92       * Is the cache coherent locally?
93       * @deprecated use {@link #isNodeBulkLoadEnabled()} instead
94       */
95      @Deprecated
96      boolean isNodeCoherent();
97  
98      /***
99       * Is the cache in bulk-load mode locally?
100      */
101     boolean isNodeBulkLoadEnabled();
102 
103     /***
104      * Enabled/disable the cache.
105      */
106     void setEnabled(boolean enabled);
107 
108     /***
109      * Removes all cached items.
110      */
111     void removeAll();
112 
113     /***
114      * Flushes all cache items from memory to the disk store, and from the
115      * DiskStore to disk.
116      */
117     void flush();
118 
119     /***
120      * Gets the status attribute of the Cache.
121      *
122      * @return The status value from the Status enum class
123      */
124     String getStatus();
125 
126     /***
127      * Is the cache configured with Terracotta clustering?
128      *
129      * @return true if clustered with terracotta
130      */
131     boolean isTerracottaClustered();
132 
133     /***
134      * Returns a textual description of a Terracotta-clustered cache's consistency mode.
135      * @return "STRONG", "EVENTUAL", or "na" if the cache is not Terracotta-clustered
136      */
137     String getTerracottaConsistency();
138 
139     /***
140      * Returns a textual description of a Terracotta-clustered cache's storage-strategy.
141      * @return "CDV2", "CLASSIC", or "na" if the cache is not Terracotta-clustered
142      */
143     String getTerracottaStorageStrategy();
144 
145     /***
146      * Clear both sampled and cumulative statistics
147      */
148     void clearStatistics();
149 
150     /***
151      * Enables statistics collection
152      */
153     void enableStatistics();
154 
155     /***
156      * Disables statistics collection. Also disables sampled statistics if it is
157      * enabled.
158      */
159     void disableStatistics();
160 
161     /***
162      * Controls the statistics. Also controls sampled statistics if it is
163      * enabled.
164      */
165     void setStatisticsEnabled(boolean statsEnabled);
166 
167     /***
168      * Enables statistics collection. As it requires that normal statistics
169      * collection to be enabled, it enables it if its not already
170      */
171     void enableSampledStatistics();
172 
173     /***
174      * Disables statistics collection
175      */
176     void disableSampledStatistics();
177 
178     /***
179      * Configuration property accessor
180      *
181      * @return Max entries local heap config setting value
182      */
183     long getConfigMaxEntriesLocalHeap();
184 
185     /***
186      * Configuration property accessor
187      *
188      * @return Max elements in memory config setting value
189      * @deprecated use {@link #getConfigMaxEntriesLocalHeap()} instead
190      */
191     @Deprecated
192     int getConfigMaxElementsInMemory();
193 
194     /***
195      * setConfigMaxElementsInMemory
196      * @param maxElements
197      */
198     void setConfigMaxElementsInMemory(int maxElements);
199 
200     /***
201      * Configuration property accessor
202      *
203      * @return Max entries local disk config setting value
204      */
205     long getConfigMaxEntriesLocalDisk();
206 
207     /***
208      * Configuration property accessor
209      *
210      * @return Max elements on disk config setting value
211      * @deprecated use {@link #getConfigMaxEntriesLocalDisk()} instead
212      */
213     @Deprecated
214     int getConfigMaxElementsOnDisk();
215 
216     /***
217      * setConfigMaxElementsOnDisk
218      * @param maxElements
219      */
220     void setConfigMaxElementsOnDisk(int maxElements);
221 
222     /***
223      * Configuration property accessor
224      *
225      * @return a String representation of the policy
226      */
227     String getConfigMemoryStoreEvictionPolicy();
228 
229     /***
230      * setConfigMemoryStoreEvictionPolicy
231      * @param evictionPolicy
232      */
233     void setConfigMemoryStoreEvictionPolicy(String evictionPolicy);
234 
235     /***
236      * Configuration property accessor
237      *
238      * @return true if set to eternal in config
239      */
240     boolean isConfigEternal();
241 
242     /***
243      * setConfigEternal
244      * @param eternal
245      */
246     void setConfigEternal(boolean eternal);
247 
248     /***
249      * Configuration property accessor
250      *
251      * @return TTI in config
252      */
253     long getConfigTimeToIdleSeconds();
254 
255     /***
256      * setConfigTimeToIdleSeconds
257      * @param tti
258      */
259     void setConfigTimeToIdleSeconds(long tti);
260 
261     /***
262      * Configuration property accessor
263      *
264      * @return TTL in config
265      */
266     long getConfigTimeToLiveSeconds();
267 
268     /***
269      * setConfigTimeToLiveSeconds
270      * @param ttl
271      */
272     void setConfigTimeToLiveSeconds(long ttl);
273 
274     /***
275      * Configuration property accessor
276      *
277      * @return true if overflow to disk specified in config
278      */
279     boolean isConfigOverflowToDisk();
280 
281     /***
282      * setConfigOverflowToDisk
283      * @param overflowToDisk
284      */
285     void setConfigOverflowToDisk(boolean overflowToDisk);
286 
287     /***
288      * Configuration property accessor
289      *
290      * @return true if configured with disk persistence
291      */
292     boolean isConfigDiskPersistent();
293 
294     /***
295      * setConfigDiskPersistent
296      * @param diskPersistent
297      */
298     void setConfigDiskPersistent(boolean diskPersistent);
299 
300     /***
301      * Configuration property accessor
302      *
303      * @return Value for disk expiry thread interval in seconds specified in config
304      */
305     long getConfigDiskExpiryThreadIntervalSeconds();
306 
307     /***
308      * setConfigDiskExpiryThreadIntervalSeconds
309      * @param seconds
310      */
311     void setConfigDiskExpiryThreadIntervalSeconds(long seconds);
312 
313     /***
314      * Configuration property accessor
315      *
316      * @return true if logging is enabled on the cache
317      */
318     boolean isConfigLoggingEnabled();
319 
320     /***
321      * setConfigLoggingEnabled
322      * @param enabled
323      */
324     void setConfigLoggingEnabled(boolean enabled);
325 
326     /***
327      * Is there a registered Write-behind CacheWriter
328      */
329     boolean getHasWriteBehindWriter();
330 
331     /***
332      * Returns the total length of all write-behind queues for this cache
333      * @return writer-behind queue length
334      */
335     long getWriterQueueLength();
336 
337     /***
338      * Returns the maximum size of any write-behind queues.
339      * @return Maximum elements that can be queued for processing by the write-behind writer
340      * @see net.sf.ehcache.config.CacheWriterConfiguration#getWriteBehindMaxQueueSize()
341      */
342     int getWriterMaxQueueSize();
343 
344     /***
345      * Returns the number of configured write-behind queues/threads.
346      * @return Number of configured processing queues/threads for use by the write-behind writer
347      * @see net.sf.ehcache.config.CacheWriterConfiguration#getWriteBehindConcurrency()
348      */
349     int getWriterConcurrency();
350 
351     /***
352      * Is the cache a transactional one
353      * @see net.sf.ehcache.config.CacheConfiguration.TransactionalMode
354      */
355     boolean getTransactional();
356 
357     /***
358      * @return Xa commit rate
359      */
360     long getTransactionCommitRate();
361 
362     /***
363      * @return Xa rollback rate
364      */
365     long getTransactionRollbackRate();
366 
367     /***
368      * Is the cache configured for search
369      * @see net.sf.ehcache.config.Searchable
370      */
371     boolean getSearchable();
372 
373     /***
374      * @return search rate
375      */
376     long getCacheSearchRate();
377 
378     /***
379      * @return search time
380      */
381     long getCacheAverageSearchTime();
382 
383     /***
384      * @return hit rate
385      */
386     long getCacheHitRate();
387 
388     /***
389      * @return in-memory hit rate
390      */
391     long getCacheInMemoryHitRate();
392 
393     /***
394      * @return off-heap hit rate
395      */
396     long getCacheOffHeapHitRate();
397 
398     /***
399      * @return on-disk hit rate
400      */
401     long getCacheOnDiskHitRate();
402 
403     /***
404      * @return miss rate
405      */
406     long getCacheMissRate();
407 
408     /***
409      * @return in-memory miss rate
410      */
411     long getCacheInMemoryMissRate();
412 
413     /***
414      * @return off-heap miss rate
415      */
416     long getCacheOffHeapMissRate();
417 
418     /***
419      * @return on-disk miss rate
420      */
421     long getCacheOnDiskMissRate();
422 
423     /***
424      * @return put rate
425      */
426     long getCachePutRate();
427 
428     /***
429      * @return update rate
430      */
431     long getCacheUpdateRate();
432 
433     /***
434      * @return remove rate
435      */
436     long getCacheRemoveRate();
437 
438     /***
439      * @return eviction rate
440      */
441     long getCacheEvictionRate();
442 
443     /***
444      * @return expiration rate
445      */
446     long getCacheExpirationRate();
447 
448     /***
449      * @return average get time (ms.)
450      */
451     float getCacheAverageGetTime();
452 }