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