%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes |
|
|
1 | package org.apache.jcs.auxiliary.disk.indexed; |
|
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 org.apache.jcs.auxiliary.AuxiliaryCacheAttributes; |
|
23 | import org.apache.jcs.auxiliary.disk.AbstractDiskCacheAttributes; |
|
24 | ||
25 | /** |
|
26 | * Configuration class for the Indexed Disk Cache |
|
27 | */ |
|
28 | public class IndexedDiskCacheAttributes |
|
29 | extends AbstractDiskCacheAttributes |
|
30 | { |
|
31 | private static final long serialVersionUID = -2190863599358782950L; |
|
32 | ||
33 | private static final int DEFAULT_maxKeySize = 5000; |
|
34 | ||
35 | /** -1 means no limit. */ |
|
36 | 181 | private int maxKeySize = DEFAULT_maxKeySize; |
37 | ||
38 | private static final int DEFAULT_maxRecycleBinSize = 5000; |
|
39 | ||
40 | /** |
|
41 | * Cannot be larger than the max size. If max is less than 0, this will be |
|
42 | * 5000 |
|
43 | */ |
|
44 | 181 | private int maxRecycleBinSize = DEFAULT_maxRecycleBinSize; |
45 | ||
46 | // default to -1, i.e., don't optimize until shutdown |
|
47 | 181 | private int optimizeAtRemoveCount = -1; |
48 | ||
49 | /** Should we optimize on shutdown. */ |
|
50 | public static final boolean DEFAULT_OPTIMIZE_ON_SHUTDOWN = true; |
|
51 | ||
52 | 181 | private boolean optimizeOnShutdown = DEFAULT_OPTIMIZE_ON_SHUTDOWN; |
53 | ||
54 | /** |
|
55 | * Constructor for the DiskCacheAttributes object |
|
56 | */ |
|
57 | public IndexedDiskCacheAttributes() |
|
58 | { |
|
59 | 181 | super(); |
60 | 181 | } |
61 | ||
62 | /** |
|
63 | * Gets the maxKeySize attribute of the DiskCacheAttributes object |
|
64 | * <p> |
|
65 | * @return The maxKeySize value |
|
66 | */ |
|
67 | public int getMaxKeySize() |
|
68 | { |
|
69 | 311 | return this.maxKeySize; |
70 | } |
|
71 | ||
72 | /** |
|
73 | * Sets the maxKeySize attribute of the DiskCacheAttributes object |
|
74 | * <p> |
|
75 | * @param maxKeySize |
|
76 | * The new maxKeySize value |
|
77 | */ |
|
78 | public void setMaxKeySize( int maxKeySize ) |
|
79 | { |
|
80 | 152 | this.maxKeySize = maxKeySize; |
81 | ||
82 | // make sure the sizes are in accord with our rule. |
|
83 | 152 | setMaxRecycleBinSize( maxRecycleBinSize ); |
84 | 152 | } |
85 | ||
86 | /** |
|
87 | * Gets the optimizeAtRemoveCount attribute of the DiskCacheAttributes |
|
88 | * object |
|
89 | * <p> |
|
90 | * @return The optimizeAtRemoveCount value |
|
91 | */ |
|
92 | public int getOptimizeAtRemoveCount() |
|
93 | { |
|
94 | 67206 | return this.optimizeAtRemoveCount; |
95 | } |
|
96 | ||
97 | /** |
|
98 | * Sets the optimizeAtRemoveCount attribute of the DiskCacheAttributes |
|
99 | * object This number determines how often the disk cache should run real |
|
100 | * time optimizations. |
|
101 | * <p> |
|
102 | * @param cnt |
|
103 | * The new optimizeAtRemoveCount value |
|
104 | */ |
|
105 | public void setOptimizeAtRemoveCount( int cnt ) |
|
106 | { |
|
107 | 106 | this.optimizeAtRemoveCount = cnt; |
108 | 106 | } |
109 | ||
110 | /** |
|
111 | * This cannot be larger than the maxKeySize. It wouldn't hurt anything, but |
|
112 | * it makes the config necessary. The recycle bin entry willbe at least as |
|
113 | * large as a key. |
|
114 | * <p> |
|
115 | * If the maxKeySize is -1 this will be set tot he default, which is 5000. |
|
116 | * <p> |
|
117 | * @param maxRecycleBinSize |
|
118 | * The maxRecycleBinSize to set. |
|
119 | */ |
|
120 | public void setMaxRecycleBinSize( int maxRecycleBinSize ) |
|
121 | { |
|
122 | 258 | this.maxRecycleBinSize = maxRecycleBinSize; |
123 | 258 | } |
124 | ||
125 | /** |
|
126 | * @return Returns the maxRecycleBinSize. |
|
127 | */ |
|
128 | public int getMaxRecycleBinSize() |
|
129 | { |
|
130 | 940 | return maxRecycleBinSize; |
131 | } |
|
132 | ||
133 | /** |
|
134 | * @param optimizeOnShutdown The optimizeOnShutdown to set. |
|
135 | */ |
|
136 | public void setOptimizeOnShutdown( boolean optimizeOnShutdown ) |
|
137 | { |
|
138 | 0 | this.optimizeOnShutdown = optimizeOnShutdown; |
139 | 0 | } |
140 | ||
141 | /** |
|
142 | * @return Returns the optimizeOnShutdown. |
|
143 | */ |
|
144 | public boolean isOptimizeOnShutdown() |
|
145 | { |
|
146 | 311 | return optimizeOnShutdown; |
147 | } |
|
148 | ||
149 | /** |
|
150 | * Returns a copy of the attributes. |
|
151 | * <p> |
|
152 | * @return AuxiliaryCacheAttributes |
|
153 | */ |
|
154 | public AuxiliaryCacheAttributes copy() |
|
155 | { |
|
156 | try |
|
157 | { |
|
158 | 209 | return (AuxiliaryCacheAttributes) this.clone(); |
159 | } |
|
160 | 0 | catch ( Exception e ) |
161 | { |
|
162 | // swallow |
|
163 | } |
|
164 | 0 | return this; |
165 | } |
|
166 | ||
167 | /** |
|
168 | * Write out the values for debugging purposes. |
|
169 | * <p> |
|
170 | * @return String |
|
171 | */ |
|
172 | public String toString() |
|
173 | { |
|
174 | 0 | StringBuffer str = new StringBuffer(); |
175 | 0 | str.append( "IndexedDiskCacheAttributes " ); |
176 | 0 | str.append( "\n diskPath = " + diskPath ); |
177 | 0 | str.append( "\n maxPurgatorySize = " + maxPurgatorySize ); |
178 | 0 | str.append( "\n maxKeySize = " + maxKeySize ); |
179 | 0 | str.append( "\n maxRecycleBinSize = " + maxRecycleBinSize ); |
180 | 0 | str.append( "\n optimizeAtRemoveCount = " + optimizeAtRemoveCount ); |
181 | 0 | str.append( "\n shutdownSpoolTimeLimit = " + shutdownSpoolTimeLimit ); |
182 | 0 | str.append( "\n optimizeOnShutdown = " + optimizeOnShutdown ); |
183 | 0 | return str.toString(); |
184 | } |
|
185 | ||
186 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |