1 package org.apache.jcs.admin;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.jcs.engine.CacheConstants;
23 import org.apache.jcs.engine.control.CompositeCache;
24
25 /***
26 * Stores info on a cache region for the template
27 */
28 public class CacheRegionInfo
29 {
30 /*** The cache region we are getting info on. */
31 CompositeCache cache = null;
32
33 /*** number of bytes counted so far, will be a total of all items. */
34 long byteCount = 0;
35
36 /***
37 * @return the underlying region
38 */
39 public CompositeCache getCache()
40 {
41 return this.cache;
42 }
43
44 /***
45 * @return total byte count
46 */
47 public long getByteCount()
48 {
49 return this.byteCount;
50 }
51
52 /***
53 * @return a status string
54 */
55 public String getStatus()
56 {
57 int status = this.cache.getStatus();
58
59 return ( status == CacheConstants.STATUS_ALIVE
60 ? "ALIVE"
61 : status == CacheConstants.STATUS_DISPOSED
62 ? "DISPOSED"
63 : status == CacheConstants.STATUS_ERROR
64 ? "ERROR"
65 : "UNKNOWN" );
66 }
67
68 /***
69 * Return the stats for the region.
70 * <p>
71 * @return String
72 */
73 public String getStats()
74 {
75 return this.cache.getStats();
76 }
77
78 /***
79 * @return string info on the region
80 */
81 public String toString()
82 {
83 StringBuffer buf = new StringBuffer();
84 buf.append( "\nCacheRegionInfo " );
85 if ( getCache() != null )
86 {
87 buf.append( "\n CacheName [" + getCache().getCacheName() + "]" );
88 buf.append( "\n Status [" + getStatus() + "]" );
89 }
90 buf.append( "\n ByteCount [" + getByteCount() + "]" );
91
92 return buf.toString();
93 }
94 }