View Javadoc
1   package org.apache.commons.jcs3.admin;
2   
3   import java.io.IOException;
4   import java.util.List;
5   
6   /*
7    * Licensed to the Apache Software Foundation (ASF) under one
8    * or more contributor license agreements.  See the NOTICE file
9    * distributed with this work for additional information
10   * regarding copyright ownership.  The ASF licenses this file
11   * to you under the Apache License, Version 2.0 (the
12   * "License"); you may not use this file except in compliance
13   * with the License.  You may obtain a copy of the License at
14   *
15   *   http://www.apache.org/licenses/LICENSE-2.0
16   *
17   * Unless required by applicable law or agreed to in writing,
18   * software distributed under the License is distributed on an
19   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20   * KIND, either express or implied.  See the License for the
21   * specific language governing permissions and limitations
22   * under the License.
23   */
24  
25  import javax.management.MXBean;
26  
27  /**
28   * A MXBean to expose the JCS statistics to JMX
29   */
30  @MXBean
31  public interface JCSJMXBean
32  {
33      /**
34       * Builds up info about each element in a region.
35       * <p>
36       * @param cacheName
37       * @return List of CacheElementInfo objects
38       * @throws IOException
39       */
40      List<CacheElementInfo> buildElementInfo( String cacheName ) throws IOException;
41  
42      /**
43       * Builds up data on every region.
44       * <p>
45       * TODO we need a most light weight method that does not count bytes. The byte counting can
46       *       really swamp a server.
47       * @return List of CacheRegionInfo objects
48       */
49      List<CacheRegionInfo> buildCacheInfo();
50  
51      /**
52       * Tries to estimate how much data is in a region. This is expensive. If there are any non serializable objects in
53       * the region or an error occurs, suppresses exceptions and returns 0.
54       * <p>
55       *
56       * @return long The size of the region in bytes.
57       */
58      long getByteCount(String cacheName);
59  
60      /**
61       * Clears all regions in the cache.
62       * <p>
63       * If this class is running within a remote cache server, clears all regions via the <code>RemoteCacheServer</code>
64       * API, so that removes will be broadcast to client machines. Otherwise clears all regions in the cache directly via
65       * the usual cache API.
66       */
67      void clearAllRegions() throws IOException;
68  
69      /**
70       * Clears a particular cache region.
71       * <p>
72       * If this class is running within a remote cache server, clears the region via the <code>RemoteCacheServer</code>
73       * API, so that removes will be broadcast to client machines. Otherwise clears the region directly via the usual
74       * cache API.
75       */
76      void clearRegion(String cacheName) throws IOException;
77  
78      /**
79       * Removes a particular item from a particular region.
80       * <p>
81       * If this class is running within a remote cache server, removes the item via the <code>RemoteCacheServer</code>
82       * API, so that removes will be broadcast to client machines. Otherwise clears the region directly via the usual
83       * cache API.
84       *
85       * @param cacheName
86       * @param key
87       *
88       * @throws IOException
89       */
90      void removeItem(String cacheName, String key) throws IOException;
91  }