1 package org.apache.commons.jcs.auxiliary.lateral;
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.commons.jcs.auxiliary.AbstractAuxiliaryCacheAttributes;
23 import org.apache.commons.jcs.auxiliary.lateral.behavior.ILateralCacheAttributes;
24
25 /**
26 * This class stores attributes for all of the available lateral cache auxiliaries.
27 */
28 public class LateralCacheAttributes
29 extends AbstractAuxiliaryCacheAttributes
30 implements ILateralCacheAttributes
31 {
32 /** Don't change */
33 private static final long serialVersionUID = -3408449508837393660L;
34
35 /** Default receive setting */
36 private static final boolean DEFAULT_RECEIVE = true;
37
38 /** THe type of lateral */
39 private String transmissionTypeName = "UDP";
40
41 /** indicates the lateral type, this needs to change */
42 private Type transmissionType = Type.UDP;
43
44 /** The http servers */
45 private String httpServers;
46
47 /** used to identify the service that this manager will be operating on */
48 private String httpServer = "";
49
50 /** this needs to change */
51 private String udpMulticastAddr = "228.5.6.7";
52
53 /** this needs to change */
54 private int udpMulticastPort = 6789;
55
56 /** this needs to change */
57 private int httpListenerPort = 8080;
58
59 /** disables gets from laterals */
60 private boolean putOnlyMode = true;
61
62 /**
63 * do we receive and broadcast or only broadcast this is useful when you don't want to get any
64 * notifications
65 */
66 private boolean receive = DEFAULT_RECEIVE;
67
68 /** If the primary fails, we will queue items before reconnect. This limits the number of items that can be queued. */
69 private int zombieQueueMaxSize = DEFAULT_ZOMBIE_QUEUE_MAX_SIZE;
70
71 /**
72 * Sets the httpServer attribute of the LateralCacheAttributes object
73 * <P>
74 * @param val The new httpServer value
75 */
76 @Override
77 public void setHttpServer( String val )
78 {
79 httpServer = val;
80 }
81
82 /**
83 * Gets the httpServer attribute of the LateralCacheAttributes object
84 * @return The httpServer value
85 */
86 @Override
87 public String getHttpServer()
88 {
89 return httpServer;
90 }
91
92 /**
93 * Sets the httpServers attribute of the LateralCacheAttributes object
94 * @param val The new httpServers value
95 */
96 @Override
97 public void setHttpServers( String val )
98 {
99 httpServers = val;
100 }
101
102 /**
103 * Gets the httpSrvers attribute of the LateralCacheAttributes object
104 * @return The httpServers value
105 */
106 @Override
107 public String getHttpServers()
108 {
109 return httpServers;
110 }
111
112 /**
113 * Sets the httpListenerPort attribute of the ILateralCacheAttributes object
114 * @param val The new tcpListenerPort value
115 */
116 @Override
117 public void setHttpListenerPort( int val )
118 {
119 this.httpListenerPort = val;
120 }
121
122 /**
123 * Gets the httpListenerPort attribute of the ILateralCacheAttributes object
124 * @return The httpListenerPort value
125 */
126 @Override
127 public int getHttpListenerPort()
128 {
129 return this.httpListenerPort;
130 }
131
132 /**
133 * Sets the udpMulticastAddr attribute of the LateralCacheAttributes object
134 * @param val The new udpMulticastAddr value
135 */
136 @Override
137 public void setUdpMulticastAddr( String val )
138 {
139 udpMulticastAddr = val;
140 }
141
142 /**
143 * Gets the udpMulticastAddr attribute of the LateralCacheAttributes object
144 * @return The udpMulticastAddr value
145 */
146 @Override
147 public String getUdpMulticastAddr()
148 {
149 return udpMulticastAddr;
150 }
151
152 /**
153 * Sets the udpMulticastPort attribute of the LateralCacheAttributes object
154 * @param val The new udpMulticastPort value
155 */
156 @Override
157 public void setUdpMulticastPort( int val )
158 {
159 udpMulticastPort = val;
160 }
161
162 /**
163 * Gets the udpMulticastPort attribute of the LateralCacheAttributes object
164 * @return The udpMulticastPort value
165 */
166 @Override
167 public int getUdpMulticastPort()
168 {
169 return udpMulticastPort;
170 }
171
172 /**
173 * Sets the transmissionType attribute of the LateralCacheAttributes object
174 * @param val The new transmissionType value
175 */
176 @Override
177 public void setTransmissionType( Type val )
178 {
179 this.transmissionType = val;
180 this.transmissionTypeName = val.toString();
181 }
182
183 /**
184 * Gets the transmissionType attribute of the LateralCacheAttributes object
185 * @return The transmissionType value
186 */
187 @Override
188 public Type getTransmissionType()
189 {
190 return this.transmissionType;
191 }
192
193 /**
194 * Sets the transmissionTypeName attribute of the LateralCacheAttributes object
195 * @param val The new transmissionTypeName value
196 */
197 @Override
198 public void setTransmissionTypeName( String val )
199 {
200 this.transmissionTypeName = val;
201 this.transmissionType = Type.valueOf(val);
202 }
203
204 /**
205 * Gets the transmissionTypeName attribute of the LateralCacheAttributes object
206 * @return The transmissionTypeName value
207 */
208 @Override
209 public String getTransmissionTypeName()
210 {
211 return this.transmissionTypeName;
212 }
213
214 /**
215 * Sets the outgoingOnlyMode attribute of the ILateralCacheAttributes. When this is true the
216 * lateral cache will only issue put and remove order and will not try to retrieve elements from
217 * other lateral caches.
218 * @param val The new transmissionTypeName value
219 */
220 @Override
221 public void setPutOnlyMode( boolean val )
222 {
223 this.putOnlyMode = val;
224 }
225
226 /**
227 * @return The outgoingOnlyMode value. Stops gets from going remote.
228 */
229 @Override
230 public boolean getPutOnlyMode()
231 {
232 return putOnlyMode;
233 }
234
235 /**
236 * @param receive The receive to set.
237 */
238 @Override
239 public void setReceive( boolean receive )
240 {
241 this.receive = receive;
242 }
243
244 /**
245 * @return Returns the receive.
246 */
247 @Override
248 public boolean isReceive()
249 {
250 return receive;
251 }
252
253 /**
254 * The number of elements the zombie queue will hold. This queue is used to store events if we
255 * loose our connection with the server.
256 * <p>
257 * @param zombieQueueMaxSize The zombieQueueMaxSize to set.
258 */
259 @Override
260 public void setZombieQueueMaxSize( int zombieQueueMaxSize )
261 {
262 this.zombieQueueMaxSize = zombieQueueMaxSize;
263 }
264
265 /**
266 * The number of elements the zombie queue will hold. This queue is used to store events if we
267 * loose our connection with the server.
268 * <p>
269 * @return Returns the zombieQueueMaxSize.
270 */
271 @Override
272 public int getZombieQueueMaxSize()
273 {
274 return zombieQueueMaxSize;
275 }
276
277 /**
278 * @return debug string.
279 */
280 @Override
281 public String toString()
282 {
283 StringBuilder buf = new StringBuilder();
284 //buf.append( "cacheName=" + cacheName + "\n" );
285 //buf.append( "putOnlyMode=" + putOnlyMode + "\n" );
286 //buf.append( "transmissionTypeName=" + transmissionTypeName + "\n" );
287 //buf.append( "transmissionType=" + transmissionType + "\n" );
288 //buf.append( "tcpServer=" + tcpServer + "\n" );
289 buf.append( transmissionTypeName + httpServer + udpMulticastAddr + String.valueOf( udpMulticastPort ) );
290 return buf.toString();
291 }
292 }