View Javadoc
1   package org.apache.commons.jcs.admin;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.beans.ConstructorProperties;
23  
24  
25  
26  /**
27   * Stores info on a cache region for the template
28   */
29  public class CacheRegionInfo
30  {
31      /** The name of the cache region */
32      private final String cacheName;
33  
34      /** The size of the cache region */
35      private final int cacheSize;
36  
37      /** The status of the cache region */
38      private final String cacheStatus;
39  
40      /** The statistics of the cache region */
41      private final String cacheStatistics;
42  
43      /** The number of memory hits in the cache region */
44      private final int hitCountRam;
45  
46      /** The number of auxiliary hits in the cache region */
47      private final int hitCountAux;
48  
49      /** The number of misses in the cache region because the items were not found */
50      private final int missCountNotFound;
51  
52      /** The number of misses in the cache region because the items were expired */
53      private final int missCountExpired;
54  
55      /** The number of bytes counted so far, will be a total of all items */
56      private final long byteCount;
57  
58      /**
59       * Parameterized constructor
60       *
61  	 * @param cacheName The name of the cache region
62  	 * @param cacheSize The size of the cache region
63  	 * @param cacheStatus The status of the cache region
64  	 * @param cacheStatistics The statistics of the cache region
65  	 * @param hitCountRam The number of memory hits in the cache region
66  	 * @param hitCountAux The number of auxiliary hits in the cache region
67  	 * @param missCountNotFound The number of misses in the cache region because the items were not found
68  	 * @param missCountExpired The number of misses in the cache region because the items were expired
69  	 * @param byteCount The number of bytes counted so far, will be a total of all items
70  	 */
71      @ConstructorProperties({"cacheName", "cacheSize", "cacheStatus", "cacheStatistics",
72      	"hitCountRam", "hitCountAux", "missCountNotFound", "missCountExpired", "byteCount"})
73  	public CacheRegionInfo(String cacheName, int cacheSize, String cacheStatus,
74  			String cacheStatistics, int hitCountRam, int hitCountAux,
75  			int missCountNotFound, int missCountExpired, long byteCount)
76  	{
77  		super();
78  		this.cacheName = cacheName;
79  		this.cacheSize = cacheSize;
80  		this.cacheStatus = cacheStatus;
81  		this.cacheStatistics = cacheStatistics;
82  		this.hitCountRam = hitCountRam;
83  		this.hitCountAux = hitCountAux;
84  		this.missCountNotFound = missCountNotFound;
85  		this.missCountExpired = missCountExpired;
86  		this.byteCount = byteCount;
87  	}
88  
89  	/**
90  	 * @return the cacheName
91  	 */
92  	public String getCacheName()
93  	{
94  		return this.cacheName;
95  	}
96  
97  	/**
98  	 * @return the cacheSize
99  	 */
100 	public int getCacheSize()
101 	{
102 		return this.cacheSize;
103 	}
104 
105 	/**
106      * @return a status string
107      */
108     public String getCacheStatus()
109     {
110         return this.cacheStatus;
111     }
112 
113     /**
114      * Return the statistics for the region.
115      * <p>
116      * @return String
117      */
118     public String getCacheStatistics()
119     {
120         return this.cacheStatistics;
121     }
122 
123     /**
124 	 * @return the hitCountRam
125 	 */
126 	public int getHitCountRam()
127 	{
128 		return hitCountRam;
129 	}
130 
131 	/**
132 	 * @return the hitCountAux
133 	 */
134 	public int getHitCountAux()
135 	{
136 		return hitCountAux;
137 	}
138 
139 	/**
140 	 * @return the missCountNotFound
141 	 */
142 	public int getMissCountNotFound()
143 	{
144 		return missCountNotFound;
145 	}
146 
147 	/**
148 	 * @return the missCountExpired
149 	 */
150 	public int getMissCountExpired()
151 	{
152 		return missCountExpired;
153 	}
154 
155 	/**
156      * @return total byte count
157      */
158     public long getByteCount()
159     {
160         return this.byteCount;
161     }
162 
163     /**
164      * @return string info on the region
165      */
166     @Override
167     public String toString()
168     {
169         StringBuilder buf = new StringBuilder();
170         buf.append( "\nCacheRegionInfo " );
171         if ( cacheName != null )
172         {
173             buf.append( "\n CacheName [" + cacheName + "]" );
174             buf.append( "\n Status [" + cacheStatus + "]" );
175         }
176         buf.append( "\n ByteCount [" + getByteCount() + "]" );
177 
178         return buf.toString();
179     }
180 }