| %line | %branch | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| org.apache.jcs.auxiliary.remote.server.RemoteCacheServerAttributes |
|
|
| 1 | package org.apache.jcs.auxiliary.remote.server; |
|
| 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.IRemoteCacheConstants; |
|
| 25 | import org.apache.jcs.auxiliary.remote.server.behavior.IRemoteCacheServerAttributes; |
|
| 26 | ||
| 27 | /** |
|
| 28 | * These attributes are used to configure the remote cache server. |
|
| 29 | */ |
|
| 30 | public class RemoteCacheServerAttributes |
|
| 31 | extends AbstractAuxiliaryCacheAttributes |
|
| 32 | implements IRemoteCacheServerAttributes |
|
| 33 | { |
|
| 34 | private static final long serialVersionUID = -2741662082869155365L; |
|
| 35 | ||
| 36 | 77 | 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 | 77 | private String clusterServers = ""; |
| 48 | ||
| 49 | 77 | private int servicePort = 0; |
| 50 | ||
| 51 | 77 | private int remoteType = LOCAL; |
| 52 | ||
| 53 | 77 | private boolean removeUponRemotePut = true; |
| 54 | ||
| 55 | 77 | private boolean getOnly = false; |
| 56 | ||
| 57 | 77 | private boolean localClusterConsistency = false; |
| 58 | ||
| 59 | 77 | private boolean allowClusterGet = true; |
| 60 | ||
| 61 | 77 | private String configFileName = ""; |
| 62 | ||
| 63 | /** Default constructor for the RemoteCacheAttributes object */ |
|
| 64 | public RemoteCacheServerAttributes() |
|
| 65 | { |
|
| 66 | 77 | super(); |
| 67 | 77 | } |
| 68 | ||
| 69 | /** |
|
| 70 | * Gets the remoteTypeName attribute of the RemoteCacheAttributes object |
|
| 71 | * <p> |
|
| 72 | * @return The remoteTypeName value |
|
| 73 | */ |
|
| 74 | public String getRemoteTypeName() |
|
| 75 | { |
|
| 76 | 14 | if ( remoteType == LOCAL ) |
| 77 | { |
|
| 78 | 7 | return "LOCAL"; |
| 79 | } |
|
| 80 | 7 | else if ( remoteType == CLUSTER ) |
| 81 | { |
|
| 82 | 7 | return "CLUSTER"; |
| 83 | } |
|
| 84 | 0 | return "LOCAL"; |
| 85 | } |
|
| 86 | ||
| 87 | /** |
|
| 88 | * Sets the remoteTypeName attribute of the RemoteCacheAttributes object |
|
| 89 | * <p> |
|
| 90 | * @param s The new remoteTypeName value |
|
| 91 | */ |
|
| 92 | public void setRemoteTypeName( String s ) |
|
| 93 | { |
|
| 94 | 14 | if ( s.equals( "LOCAL" ) ) |
| 95 | { |
|
| 96 | 7 | remoteType = LOCAL; |
| 97 | 7 | } |
| 98 | 7 | else if ( s.equals( "CLUSTER" ) ) |
| 99 | { |
|
| 100 | 7 | remoteType = CLUSTER; |
| 101 | } |
|
| 102 | 14 | } |
| 103 | ||
| 104 | /** |
|
| 105 | * Gets the remoteType attribute of the RemoteCacheAttributes object |
|
| 106 | * <p> |
|
| 107 | * @return The remoteType value |
|
| 108 | */ |
|
| 109 | public int getRemoteType() |
|
| 110 | { |
|
| 111 | 14 | return remoteType; |
| 112 | } |
|
| 113 | ||
| 114 | /** |
|
| 115 | * Sets the remoteType attribute of the RemoteCacheAttributes object |
|
| 116 | * <p> |
|
| 117 | * @param p The new remoteType value |
|
| 118 | */ |
|
| 119 | public void setRemoteType( int p ) |
|
| 120 | { |
|
| 121 | 0 | this.remoteType = p; |
| 122 | 0 | } |
| 123 | ||
| 124 | /** |
|
| 125 | * clones |
|
| 126 | * <p> |
|
| 127 | * @return AuxiliaryCacheAttributes clone |
|
| 128 | */ |
|
| 129 | public AuxiliaryCacheAttributes copy() |
|
| 130 | { |
|
| 131 | try |
|
| 132 | { |
|
| 133 | 0 | return (AuxiliaryCacheAttributes) this.clone(); |
| 134 | } |
|
| 135 | 0 | catch ( Exception e ) |
| 136 | { |
|
| 137 | // swallow |
|
| 138 | } |
|
| 139 | 0 | return this; |
| 140 | } |
|
| 141 | ||
| 142 | /** |
|
| 143 | * Gets the remoteServiceName attribute of the RemoteCacheAttributes object |
|
| 144 | * <p> |
|
| 145 | * @return The remoteServiceName value |
|
| 146 | */ |
|
| 147 | public String getRemoteServiceName() |
|
| 148 | { |
|
| 149 | 0 | return this.remoteServiceName; |
| 150 | } |
|
| 151 | ||
| 152 | /** |
|
| 153 | * Sets the remoteServiceName attribute of the RemoteCacheAttributes object |
|
| 154 | * <p> |
|
| 155 | * @param s The new remoteServiceName value |
|
| 156 | */ |
|
| 157 | public void setRemoteServiceName( String s ) |
|
| 158 | { |
|
| 159 | 0 | this.remoteServiceName = s; |
| 160 | 0 | } |
| 161 | ||
| 162 | /** |
|
| 163 | * Gets the remoteHost attribute of the RemoteCacheAttributes object |
|
| 164 | * <p> |
|
| 165 | * @return The remoteHost value |
|
| 166 | */ |
|
| 167 | public String getRemoteHost() |
|
| 168 | { |
|
| 169 | 14 | return this.remoteHost; |
| 170 | } |
|
| 171 | ||
| 172 | /** |
|
| 173 | * Sets the remoteHost attribute of the RemoteCacheAttributes object |
|
| 174 | * <p> |
|
| 175 | * @param s The new remoteHost value |
|
| 176 | */ |
|
| 177 | public void setRemoteHost( String s ) |
|
| 178 | { |
|
| 179 | 0 | this.remoteHost = s; |
| 180 | 0 | } |
| 181 | ||
| 182 | /** |
|
| 183 | * Gets the remotePort attribute of the RemoteCacheAttributes object |
|
| 184 | * <p> |
|
| 185 | * @return The remotePort value |
|
| 186 | */ |
|
| 187 | public int getRemotePort() |
|
| 188 | { |
|
| 189 | 14 | return this.remotePort; |
| 190 | } |
|
| 191 | ||
| 192 | /** |
|
| 193 | * Sets the remotePort attribute of the RemoteCacheAttributes object |
|
| 194 | * <p> |
|
| 195 | * @param p The new remotePort value |
|
| 196 | */ |
|
| 197 | public void setRemotePort( int p ) |
|
| 198 | { |
|
| 199 | 0 | this.remotePort = p; |
| 200 | 0 | } |
| 201 | ||
| 202 | /** |
|
| 203 | * Gets the clusterServers attribute of the RemoteCacheAttributes object |
|
| 204 | * <p> |
|
| 205 | * @return The clusterServers value |
|
| 206 | */ |
|
| 207 | public String getClusterServers() |
|
| 208 | { |
|
| 209 | 0 | return this.clusterServers; |
| 210 | } |
|
| 211 | ||
| 212 | /** |
|
| 213 | * Sets the clusterServers attribute of the RemoteCacheAttributes object |
|
| 214 | * <p> |
|
| 215 | * @param s The new clusterServers value |
|
| 216 | */ |
|
| 217 | public void setClusterServers( String s ) |
|
| 218 | { |
|
| 219 | 0 | this.clusterServers = s; |
| 220 | 0 | } |
| 221 | ||
| 222 | /** |
|
| 223 | * Gets the localPort attribute of the RemoteCacheAttributes object |
|
| 224 | * <p> |
|
| 225 | * @return The localPort value |
|
| 226 | */ |
|
| 227 | public int getServicePort() |
|
| 228 | { |
|
| 229 | 56 | return this.servicePort; |
| 230 | } |
|
| 231 | ||
| 232 | /** |
|
| 233 | * Sets the localPort attribute of the RemoteCacheAttributes object |
|
| 234 | * <p> |
|
| 235 | * @param p The new localPort value |
|
| 236 | */ |
|
| 237 | public void setServicePort( int p ) |
|
| 238 | { |
|
| 239 | 7 | this.servicePort = p; |
| 240 | 7 | } |
| 241 | ||
| 242 | /** |
|
| 243 | * Gets the removeUponRemotePut attribute of the RemoteCacheAttributes object |
|
| 244 | * <p> |
|
| 245 | * @return The removeUponRemotePut value |
|
| 246 | */ |
|
| 247 | public boolean getRemoveUponRemotePut() |
|
| 248 | { |
|
| 249 | 14 | return this.removeUponRemotePut; |
| 250 | } |
|
| 251 | ||
| 252 | /** |
|
| 253 | * Sets the removeUponRemotePut attribute of the RemoteCacheAttributes object |
|
| 254 | * <p> |
|
| 255 | * @param r The new removeUponRemotePut value |
|
| 256 | */ |
|
| 257 | public void setRemoveUponRemotePut( boolean r ) |
|
| 258 | { |
|
| 259 | 0 | this.removeUponRemotePut = r; |
| 260 | 0 | } |
| 261 | ||
| 262 | /** |
|
| 263 | * Gets the getOnly attribute of the RemoteCacheAttributes object |
|
| 264 | * <p> |
|
| 265 | * @return The getOnly value |
|
| 266 | */ |
|
| 267 | public boolean getGetOnly() |
|
| 268 | { |
|
| 269 | 14 | return this.getOnly; |
| 270 | } |
|
| 271 | ||
| 272 | /** |
|
| 273 | * Sets the getOnly attribute of the RemoteCacheAttributes object |
|
| 274 | * <p> |
|
| 275 | * @param r The new getOnly value |
|
| 276 | */ |
|
| 277 | public void setGetOnly( boolean r ) |
|
| 278 | { |
|
| 279 | 0 | this.getOnly = r; |
| 280 | 0 | } |
| 281 | ||
| 282 | /** |
|
| 283 | * Should cluster updates be propogated to the locals |
|
| 284 | * <p> |
|
| 285 | * @return The localClusterConsistency value |
|
| 286 | */ |
|
| 287 | public boolean getLocalClusterConsistency() |
|
| 288 | { |
|
| 289 | 84 | return localClusterConsistency; |
| 290 | } |
|
| 291 | ||
| 292 | /** |
|
| 293 | * Should cluster updates be propogated to the locals |
|
| 294 | * <p> |
|
| 295 | * @param r The new localClusterConsistency value |
|
| 296 | */ |
|
| 297 | public void setLocalClusterConsistency( boolean r ) |
|
| 298 | { |
|
| 299 | 14 | this.localClusterConsistency = r; |
| 300 | 14 | } |
| 301 | ||
| 302 | /** |
|
| 303 | * Should gets from non-cluster clients be allowed to get from other remote auxiliaries. |
|
| 304 | * <p> |
|
| 305 | * @return The localClusterConsistency value |
|
| 306 | */ |
|
| 307 | public boolean getAllowClusterGet() |
|
| 308 | { |
|
| 309 | 35 | return allowClusterGet; |
| 310 | } |
|
| 311 | ||
| 312 | /** |
|
| 313 | * Should we try to get from other cluster servers if we don't find the items locally. |
|
| 314 | * <p> |
|
| 315 | * @param r The new localClusterConsistency value |
|
| 316 | */ |
|
| 317 | public void setAllowClusterGet( boolean r ) |
|
| 318 | { |
|
| 319 | 7 | allowClusterGet = r; |
| 320 | 7 | } |
| 321 | ||
| 322 | /** |
|
| 323 | * Gets the ConfigFileName attribute of the IRemoteCacheAttributes object |
|
| 324 | * <p> |
|
| 325 | * @return The clusterServers value |
|
| 326 | */ |
|
| 327 | public String getConfigFileName() |
|
| 328 | { |
|
| 329 | 70 | return configFileName; |
| 330 | } |
|
| 331 | ||
| 332 | /** |
|
| 333 | * Sets the ConfigFileName attribute of the IRemoteCacheAttributes object |
|
| 334 | * <p> |
|
| 335 | * @param s The new clusterServers value |
|
| 336 | */ |
|
| 337 | public void setConfigFileName( String s ) |
|
| 338 | { |
|
| 339 | 56 | configFileName = s; |
| 340 | 56 | } |
| 341 | ||
| 342 | /* |
|
| 343 | * (non-Javadoc) |
|
| 344 | * @see java.lang.Object#toString() |
|
| 345 | */ |
|
| 346 | public String toString() |
|
| 347 | { |
|
| 348 | 14 | StringBuffer buf = new StringBuffer(); |
| 349 | 14 | buf.append( "\n remoteHost = " + this.getRemoteHost() ); |
| 350 | 14 | buf.append( "\n remotePort = " + this.getRemotePort() ); |
| 351 | 14 | buf.append( "\n cacheName = " + this.getCacheName() ); |
| 352 | 14 | buf.append( "\n removeUponRemotePut = " + this.getRemoveUponRemotePut() ); |
| 353 | 14 | buf.append( "\n getOnly = " + this.getGetOnly() ); |
| 354 | 14 | buf.append( "\n allowClusterGet = " + this.getAllowClusterGet() ); |
| 355 | 14 | buf.append( "\n localClusterConsistency = " + this.getLocalClusterConsistency() ); |
| 356 | 14 | buf.append( "\n getConfigFileName = " + this.getConfigFileName() ); |
| 357 | 14 | return buf.toString(); |
| 358 | } |
|
| 359 | } |
| This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |