001package org.apache.commons.jcs.admin;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import javax.management.MXBean;
023import java.io.IOException;
024
025/**
026 * A MXBean to expose the JCS statistics to JMX
027 */
028@MXBean
029public interface JCSJMXBean
030{
031    /**
032     * Builds up info about each element in a region.
033     * <p>
034     * @param cacheName
035     * @return Array of CacheElementInfo objects
036     * @throws Exception
037     */
038    CacheElementInfo[] buildElementInfo( String cacheName ) throws Exception;
039
040    /**
041     * Builds up data on every region.
042     * <p>
043     * TODO we need a most light weight method that does not count bytes. The byte counting can
044     *       really swamp a server.
045     * @return Array of CacheRegionInfo objects
046     * @throws Exception
047     */
048    CacheRegionInfo[] buildCacheInfo() throws Exception;
049
050    /**
051     * Tries to estimate how much data is in a region. This is expensive. If there are any non serializable objects in
052     * the region or an error occurs, suppresses exceptions and returns 0.
053     * <p>
054     *
055     * @return int The size of the region in bytes.
056     */
057    int getByteCount(String cacheName);
058
059    /**
060     * Clears all regions in the cache.
061     * <p>
062     * If this class is running within a remote cache server, clears all regions via the <code>RemoteCacheServer</code>
063     * API, so that removes will be broadcast to client machines. Otherwise clears all regions in the cache directly via
064     * the usual cache API.
065     */
066    void clearAllRegions() throws IOException;
067
068    /**
069     * Clears a particular cache region.
070     * <p>
071     * If this class is running within a remote cache server, clears the region via the <code>RemoteCacheServer</code>
072     * API, so that removes will be broadcast to client machines. Otherwise clears the region directly via the usual
073     * cache API.
074     */
075    void clearRegion(String cacheName) throws IOException;
076
077    /**
078     * Removes a particular item from a particular region.
079     * <p>
080     * If this class is running within a remote cache server, removes the item via the <code>RemoteCacheServer</code>
081     * API, so that removes will be broadcast to client machines. Otherwise clears the region directly via the usual
082     * cache API.
083     *
084     * @param cacheName
085     * @param key
086     *
087     * @throws IOException
088     */
089    void removeItem(String cacheName, String key) throws IOException;
090}