%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jcs.auxiliary.remote.RemoteCacheAttributes |
|
|
1 | package org.apache.jcs.auxiliary.remote; |
|
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.AbstractAuxiliaryCacheAttributes; |
|
23 | import org.apache.jcs.auxiliary.AuxiliaryCacheAttributes; |
|
24 | import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheAttributes; |
|
25 | import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheConstants; |
|
26 | ||
27 | /** |
|
28 | * These objects are used to configure the remote cache client. |
|
29 | */ |
|
30 | public class RemoteCacheAttributes |
|
31 | extends AbstractAuxiliaryCacheAttributes |
|
32 | implements IRemoteCacheAttributes |
|
33 | { |
|
34 | private static final long serialVersionUID = -1555143736942374000L; |
|
35 | ||
36 | 98 | private String remoteServiceName = IRemoteCacheConstants.REMOTE_CACHE_SERVICE_VAL; |
37 | ||
38 | private String remoteHost; |
|
39 | ||
40 | private int remotePort; |
|
41 | ||
42 | /** |
|
43 | * Failover servers will be used by local caches one at a time. Listeners will be registered |
|
44 | * with all cluster servers. If we add a get from cluster attribute we will have the ability to |
|
45 | * chain clusters and have them get from each other. |
|
46 | */ |
|
47 | 98 | private String failoverServers = ""; |
48 | ||
49 | 98 | private String clusterServers = ""; |
50 | ||
51 | 98 | private int localPort = 0; |
52 | ||
53 | 98 | private int remoteType = LOCAL; |
54 | ||
55 | // what failover server we are connected to. |
|
56 | 98 | private int failoverIndex = 0; |
57 | ||
58 | private String[] failovers; |
|
59 | ||
60 | 98 | private boolean removeUponRemotePut = true; |
61 | ||
62 | 98 | private boolean getOnly = false; |
63 | ||
64 | 98 | private boolean localClusterConsistency = false; |
65 | ||
66 | // default name is remote_cache_client |
|
67 | 98 | private String threadPoolName = "remote_cache_client"; |
68 | ||
69 | // must be greater than 0 for a pool to be used. |
|
70 | 98 | private int getTimeoutMillis = -1; |
71 | ||
72 | 98 | private int rmiSocketFactoryTimeoutMillis = DEFAULT_RMI_SOCKET_FACTORY_TIMEOUT_MILLIS; |
73 | ||
74 | 98 | private boolean receive = DEFAULT_RECEIVE; |
75 | ||
76 | 98 | private int zombieQueueMaxSize = DEFAULT_ZOMBIE_QUEUE_MAX_SIZE; |
77 | ||
78 | /** Default constructor for the RemoteCacheAttributes object */ |
|
79 | public RemoteCacheAttributes() |
|
80 | { |
|
81 | 98 | super(); |
82 | 98 | } |
83 | ||
84 | /** |
|
85 | * Gets the remoteTypeName attribute of the RemoteCacheAttributes object. |
|
86 | * <p> |
|
87 | * @return The remoteTypeName value |
|
88 | */ |
|
89 | public String getRemoteTypeName() |
|
90 | { |
|
91 | 0 | if ( remoteType == LOCAL ) |
92 | { |
|
93 | 0 | return "LOCAL"; |
94 | } |
|
95 | 0 | else if ( remoteType == CLUSTER ) |
96 | { |
|
97 | 0 | return "CLUSTER"; |
98 | } |
|
99 | 0 | return "LOCAL"; |
100 | } |
|
101 | ||
102 | /** |
|
103 | * Sets the remoteTypeName attribute of the RemoteCacheAttributes object. |
|
104 | * <p> |
|
105 | * @param s The new remoteTypeName value |
|
106 | */ |
|
107 | public void setRemoteTypeName( String s ) |
|
108 | { |
|
109 | 0 | if ( s.equals( "LOCAL" ) ) |
110 | { |
|
111 | 0 | remoteType = LOCAL; |
112 | 0 | } |
113 | 0 | else if ( s.equals( "CLUSTER" ) ) |
114 | { |
|
115 | 0 | remoteType = CLUSTER; |
116 | } |
|
117 | 0 | } |
118 | ||
119 | /** |
|
120 | * Gets the failoverIndex attribute of the RemoteCacheAttributes object. |
|
121 | * <p> |
|
122 | * @return The failoverIndex value |
|
123 | */ |
|
124 | public int getFailoverIndex() |
|
125 | { |
|
126 | 0 | return failoverIndex; |
127 | } |
|
128 | ||
129 | /** |
|
130 | * Sets the failoverIndex attribute of the RemoteCacheAttributes object. |
|
131 | * <p> |
|
132 | * @param p The new failoverIndex value |
|
133 | */ |
|
134 | public void setFailoverIndex( int p ) |
|
135 | { |
|
136 | 0 | this.failoverIndex = p; |
137 | 0 | } |
138 | ||
139 | /** |
|
140 | * Gets the failovers attribute of the RemoteCacheAttributes object. |
|
141 | * <p> |
|
142 | * @return The failovers value |
|
143 | */ |
|
144 | public String[] getFailovers() |
|
145 | { |
|
146 | 0 | return this.failovers; |
147 | } |
|
148 | ||
149 | /** |
|
150 | * Sets the failovers attribute of the RemoteCacheAttributes object. |
|
151 | * <p> |
|
152 | * @param f The new failovers value |
|
153 | */ |
|
154 | public void setFailovers( String[] f ) |
|
155 | { |
|
156 | 0 | this.failovers = f; |
157 | 0 | } |
158 | ||
159 | /** |
|
160 | * Gets the remoteType attribute of the RemoteCacheAttributes object. |
|
161 | * <p> |
|
162 | * @return The remoteType value |
|
163 | */ |
|
164 | public int getRemoteType() |
|
165 | { |
|
166 | 35 | return remoteType; |
167 | } |
|
168 | ||
169 | /** |
|
170 | * Sets the remoteType attribute of the RemoteCacheAttributes object. |
|
171 | * <p> |
|
172 | * @param p The new remoteType value |
|
173 | */ |
|
174 | public void setRemoteType( int p ) |
|
175 | { |
|
176 | 0 | this.remoteType = p; |
177 | 0 | } |
178 | ||
179 | /* |
|
180 | * (non-Javadoc) |
|
181 | * @see org.apache.jcs.auxiliary.AuxiliaryCacheAttributes#copy() |
|
182 | */ |
|
183 | public AuxiliaryCacheAttributes copy() |
|
184 | { |
|
185 | try |
|
186 | { |
|
187 | 28 | return (AuxiliaryCacheAttributes) this.clone(); |
188 | } |
|
189 | 0 | catch ( Exception e ) |
190 | { |
|
191 | // swallow |
|
192 | } |
|
193 | 0 | return this; |
194 | } |
|
195 | ||
196 | /** |
|
197 | * Gets the remoteServiceName attribute of the RemoteCacheAttributes object. |
|
198 | * <p> |
|
199 | * @return The remoteServiceName value |
|
200 | */ |
|
201 | public String getRemoteServiceName() |
|
202 | { |
|
203 | 28 | return this.remoteServiceName; |
204 | } |
|
205 | ||
206 | /** |
|
207 | * Sets the remoteServiceName attribute of the RemoteCacheAttributes object. |
|
208 | * <p> |
|
209 | * @param s The new remoteServiceName value |
|
210 | */ |
|
211 | public void setRemoteServiceName( String s ) |
|
212 | { |
|
213 | 0 | this.remoteServiceName = s; |
214 | 0 | } |
215 | ||
216 | /** |
|
217 | * Gets the remoteHost attribute of the RemoteCacheAttributes object. |
|
218 | * <p> |
|
219 | * @return The remoteHost value |
|
220 | */ |
|
221 | public String getRemoteHost() |
|
222 | { |
|
223 | 28 | return this.remoteHost; |
224 | } |
|
225 | ||
226 | /** |
|
227 | * Sets the remoteHost attribute of the RemoteCacheAttributes object. |
|
228 | * <p> |
|
229 | * @param s The new remoteHost value |
|
230 | */ |
|
231 | public void setRemoteHost( String s ) |
|
232 | { |
|
233 | 28 | this.remoteHost = s; |
234 | 28 | } |
235 | ||
236 | /** |
|
237 | * Gets the remotePort attribute of the RemoteCacheAttributes object. |
|
238 | * <p> |
|
239 | * @return The remotePort value |
|
240 | */ |
|
241 | public int getRemotePort() |
|
242 | { |
|
243 | 28 | return this.remotePort; |
244 | } |
|
245 | ||
246 | /** |
|
247 | * Sets the remotePort attribute of the RemoteCacheAttributes object. |
|
248 | * <p> |
|
249 | * @param p The new remotePort value |
|
250 | */ |
|
251 | public void setRemotePort( int p ) |
|
252 | { |
|
253 | 28 | this.remotePort = p; |
254 | 28 | } |
255 | ||
256 | /** |
|
257 | * Gets the clusterServers attribute of the RemoteCacheAttributes object. |
|
258 | * <p> |
|
259 | * @return The clusterServers value |
|
260 | */ |
|
261 | public String getClusterServers() |
|
262 | { |
|
263 | 0 | return this.clusterServers; |
264 | } |
|
265 | ||
266 | /** |
|
267 | * Sets the clusterServers attribute of the RemoteCacheAttributes object. |
|
268 | * <p> |
|
269 | * @param s The new clusterServers value |
|
270 | */ |
|
271 | public void setClusterServers( String s ) |
|
272 | { |
|
273 | 0 | this.clusterServers = s; |
274 | 0 | } |
275 | ||
276 | /** |
|
277 | * Gets the failoverServers attribute of the RemoteCacheAttributes object. |
|
278 | * <p> |
|
279 | * @return The failoverServers value |
|
280 | */ |
|
281 | public String getFailoverServers() |
|
282 | { |
|
283 | 0 | return this.failoverServers; |
284 | } |
|
285 | ||
286 | /** |
|
287 | * Sets the failoverServers attribute of the RemoteCacheAttributes object. |
|
288 | * <p> |
|
289 | * @param s The new failoverServers value |
|
290 | */ |
|
291 | public void setFailoverServers( String s ) |
|
292 | { |
|
293 | 0 | this.failoverServers = s; |
294 | 0 | } |
295 | ||
296 | /** |
|
297 | * Gets the localPort attribute of the RemoteCacheAttributes object. |
|
298 | * <p> |
|
299 | * @return The localPort value |
|
300 | */ |
|
301 | public int getLocalPort() |
|
302 | { |
|
303 | 56 | return this.localPort; |
304 | } |
|
305 | ||
306 | /** |
|
307 | * Sets the localPort attribute of the RemoteCacheAttributes object |
|
308 | * @param p The new localPort value |
|
309 | */ |
|
310 | public void setLocalPort( int p ) |
|
311 | { |
|
312 | 28 | this.localPort = p; |
313 | 28 | } |
314 | ||
315 | /** |
|
316 | * Gets the removeUponRemotePut attribute of the RemoteCacheAttributes object. |
|
317 | * <p> |
|
318 | * @return The removeUponRemotePut value |
|
319 | */ |
|
320 | public boolean getRemoveUponRemotePut() |
|
321 | { |
|
322 | 14 | return this.removeUponRemotePut; |
323 | } |
|
324 | ||
325 | /** |
|
326 | * Sets the removeUponRemotePut attribute of the RemoteCacheAttributes object. |
|
327 | * <p> |
|
328 | * @param r The new removeUponRemotePut value |
|
329 | */ |
|
330 | public void setRemoveUponRemotePut( boolean r ) |
|
331 | { |
|
332 | 14 | this.removeUponRemotePut = r; |
333 | 14 | } |
334 | ||
335 | /** |
|
336 | * Gets the getOnly attribute of the RemoteCacheAttributes object. |
|
337 | * <p> |
|
338 | * @return The getOnly value |
|
339 | */ |
|
340 | public boolean getGetOnly() |
|
341 | { |
|
342 | 742 | return this.getOnly; |
343 | } |
|
344 | ||
345 | /** |
|
346 | * Sets the getOnly attribute of the RemoteCacheAttributes object |
|
347 | * @param r The new getOnly value |
|
348 | */ |
|
349 | public void setGetOnly( boolean r ) |
|
350 | { |
|
351 | 0 | this.getOnly = r; |
352 | 0 | } |
353 | ||
354 | /** |
|
355 | * Should cluster updates be propogated to the locals. |
|
356 | * <p> |
|
357 | * @return The localClusterConsistency value |
|
358 | */ |
|
359 | public boolean getLocalClusterConsistency() |
|
360 | { |
|
361 | 0 | return localClusterConsistency; |
362 | } |
|
363 | ||
364 | /** |
|
365 | * Should cluster updates be propogated to the locals. |
|
366 | * <p> |
|
367 | * @param r The new localClusterConsistency value |
|
368 | */ |
|
369 | public void setLocalClusterConsistency( boolean r ) |
|
370 | { |
|
371 | 0 | this.localClusterConsistency = r; |
372 | 0 | } |
373 | ||
374 | /* |
|
375 | * (non-Javadoc) |
|
376 | * @see org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheAttributes#getThreadPoolName() |
|
377 | */ |
|
378 | public String getThreadPoolName() |
|
379 | { |
|
380 | 0 | return threadPoolName; |
381 | } |
|
382 | ||
383 | /* |
|
384 | * (non-Javadoc) |
|
385 | * @see org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheAttributes#setThreadPoolName(java.lang.String) |
|
386 | */ |
|
387 | public void setThreadPoolName( String name ) |
|
388 | { |
|
389 | 0 | threadPoolName = name; |
390 | 0 | } |
391 | ||
392 | /* |
|
393 | * (non-Javadoc) |
|
394 | * @see org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheAttributes#getGetTimeoutMillis() |
|
395 | */ |
|
396 | public int getGetTimeoutMillis() |
|
397 | { |
|
398 | 35 | return getTimeoutMillis; |
399 | } |
|
400 | ||
401 | /* |
|
402 | * (non-Javadoc) |
|
403 | * @see org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheAttributes#setGetTimeoutMillis(int) |
|
404 | */ |
|
405 | public void setGetTimeoutMillis( int millis ) |
|
406 | { |
|
407 | 0 | getTimeoutMillis = millis; |
408 | 0 | } |
409 | ||
410 | /** |
|
411 | * @param rmiSocketFactoryTimeoutMillis The rmiSocketFactoryTimeoutMillis to set. |
|
412 | */ |
|
413 | public void setRmiSocketFactoryTimeoutMillis( int rmiSocketFactoryTimeoutMillis ) |
|
414 | { |
|
415 | 0 | this.rmiSocketFactoryTimeoutMillis = rmiSocketFactoryTimeoutMillis; |
416 | 0 | } |
417 | ||
418 | /** |
|
419 | * @return Returns the rmiSocketFactoryTimeoutMillis. |
|
420 | */ |
|
421 | public int getRmiSocketFactoryTimeoutMillis() |
|
422 | { |
|
423 | 35 | return rmiSocketFactoryTimeoutMillis; |
424 | } |
|
425 | ||
426 | /** |
|
427 | * By default this option is true. If you set it to false, you will not receive updates or |
|
428 | * removes from the remote server. |
|
429 | * <p> |
|
430 | * @param receive |
|
431 | */ |
|
432 | public void setReceive( boolean receive ) |
|
433 | { |
|
434 | 0 | this.receive = receive; |
435 | 0 | } |
436 | ||
437 | /** |
|
438 | * If RECEIVE is false then the remote cache will not register a listener with the remote |
|
439 | * server. This allows you to configure a remote server as a repository from which you can get |
|
440 | * and to which you put, but from which you do not reveive any notifications. That is, you will |
|
441 | * not receive updates or removes. |
|
442 | * <p> |
|
443 | * If you set this option to false, you should set your locl memory size to 0. |
|
444 | * <p> |
|
445 | * The remote cache manager uses this value to decide whether or not to register a listener. |
|
446 | * @return the receive value. |
|
447 | */ |
|
448 | public boolean isReceive() |
|
449 | { |
|
450 | 21 | return this.receive; |
451 | } |
|
452 | ||
453 | /** |
|
454 | * The number of elements the zombie queue will hold. This queue is used to store events if we |
|
455 | * loose our conenction with the server. |
|
456 | * <p> |
|
457 | * @param zombieQueueMaxSize The zombieQueueMaxSize to set. |
|
458 | */ |
|
459 | public void setZombieQueueMaxSize( int zombieQueueMaxSize ) |
|
460 | { |
|
461 | 0 | this.zombieQueueMaxSize = zombieQueueMaxSize; |
462 | 0 | } |
463 | ||
464 | /** |
|
465 | * The number of elements the zombie queue will hold. This queue is used to store events if we |
|
466 | * loose our conenction with the server. |
|
467 | * <p> |
|
468 | * @return Returns the zombieQueueMaxSize. |
|
469 | */ |
|
470 | public int getZombieQueueMaxSize() |
|
471 | { |
|
472 | 0 | return zombieQueueMaxSize; |
473 | } |
|
474 | ||
475 | /** |
|
476 | * @return String, all the important values that can be configured |
|
477 | */ |
|
478 | public String toString() |
|
479 | { |
|
480 | 0 | StringBuffer buf = new StringBuffer(); |
481 | 0 | buf.append( "\n RemoteCacheAttributes " ); |
482 | 0 | buf.append( "\n remoteHost = [" + this.remoteHost + "]" ); |
483 | 0 | buf.append( "\n remotePort = [" + this.remotePort + "]" ); |
484 | 0 | buf.append( "\n cacheName = [" + this.cacheName + "]" ); |
485 | 0 | buf.append( "\n removeUponRemotePut = [" + this.removeUponRemotePut + "]" ); |
486 | 0 | buf.append( "\n getOnly = [" + getOnly + "]" ); |
487 | 0 | buf.append( "\n receive = [" + isReceive() + "]" ); |
488 | 0 | buf.append( "\n getTimeoutMillis = [" + getGetTimeoutMillis() + "]" ); |
489 | 0 | buf.append( "\n threadPoolName = [" + getThreadPoolName() + "]" ); |
490 | 0 | buf.append( "\n remoteType = [" + remoteType + "]" ); |
491 | 0 | buf.append( "\n localClusterConsistency = [" + getLocalClusterConsistency() + "]" ); |
492 | 0 | buf.append( "\n zombieQueueMaxSize = [" + getZombieQueueMaxSize() + "]" ); |
493 | 0 | return buf.toString(); |
494 | } |
|
495 | ||
496 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |