View Javadoc
1   package org.apache.commons.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.commons.jcs.auxiliary.remote.CommonRemoteCacheAttributes;
23  import org.apache.commons.jcs.auxiliary.remote.server.behavior.IRemoteCacheServerAttributes;
24  
25  /**
26   * These attributes are used to configure the remote cache server.
27   */
28  public class RemoteCacheServerAttributes
29      extends CommonRemoteCacheAttributes
30      implements IRemoteCacheServerAttributes
31  {
32      /** Don't change */
33      private static final long serialVersionUID = -2741662082869155365L;
34  
35      /** port the server will listen to */
36      private int servicePort = 0;
37  
38      /** Can a cluster remote get from other remotes */
39      private boolean allowClusterGet = true;
40  
41      /** The config file, the initialization is multistage. Remote cache then composite cache. */
42      private String configFileName = "";
43  
44      /** Should we start the registry */
45      private boolean DEFAULT_START_REGISTRY = true;
46  
47      /** Should we start the registry */
48      private boolean startRegistry = DEFAULT_START_REGISTRY;
49  
50      /** Should we try to keep the registry alive */
51      private boolean DEFAULT_USE_REGISTRY_KEEP_ALIVE = true;
52  
53      /** Should we try to keep the registry alive */
54      private boolean useRegistryKeepAlive = DEFAULT_USE_REGISTRY_KEEP_ALIVE;
55  
56      /** The delay between runs */
57      private long registryKeepAliveDelayMillis = 15 * 1000;
58  
59      /** Default constructor for the RemoteCacheAttributes object */
60      public RemoteCacheServerAttributes()
61      {
62          super();
63      }
64  
65      /**
66       * Gets the localPort attribute of the RemoteCacheAttributes object
67       * <p>
68       * @return The localPort value
69       */
70      @Override
71      public int getServicePort()
72      {
73          return this.servicePort;
74      }
75  
76      /**
77       * Sets the localPort attribute of the RemoteCacheAttributes object
78       * <p>
79       * @param p The new localPort value
80       */
81      @Override
82      public void setServicePort( int p )
83      {
84          this.servicePort = p;
85      }
86  
87      /**
88       * Should gets from non-cluster clients be allowed to get from other remote auxiliaries.
89       * <p>
90       * @return The localClusterConsistency value
91       */
92      @Override
93      public boolean isAllowClusterGet()
94      {
95          return allowClusterGet;
96      }
97  
98      /**
99       * Should we try to get from other cluster servers if we don't find the items locally.
100      * <p>
101      * @param r The new localClusterConsistency value
102      */
103     @Override
104     public void setAllowClusterGet( boolean r )
105     {
106         allowClusterGet = r;
107     }
108 
109     /**
110      * Gets the ConfigFileName attribute of the IRemoteCacheAttributes object
111      * <p>
112      * @return The clusterServers value
113      */
114     @Override
115     public String getConfigFileName()
116     {
117         return configFileName;
118     }
119 
120     /**
121      * Sets the ConfigFileName attribute of the IRemoteCacheAttributes object
122      * <p>
123      * @param s The new clusterServers value
124      */
125     @Override
126     public void setConfigFileName( String s )
127     {
128         configFileName = s;
129     }
130 
131     /**
132      * Should we try to keep the registry alive
133      * <p>
134      * @param useRegistryKeepAlive the useRegistryKeepAlive to set
135      */
136     @Override
137     public void setUseRegistryKeepAlive( boolean useRegistryKeepAlive )
138     {
139         this.useRegistryKeepAlive = useRegistryKeepAlive;
140     }
141 
142     /**
143      * Should we start the registry
144      * <p>
145      * @param startRegistry the startRegistry to set
146      * @deprecated Always true, to be removed
147      */
148     @Override
149     public void setStartRegistry( boolean startRegistry )
150     {
151         this.startRegistry = startRegistry;
152     }
153 
154     /**
155      * Should we start the registry
156      * <p>
157      * @return the startRegistry
158      * @deprecated Always true, to be removed
159      */
160     @Override
161     public boolean isStartRegistry()
162     {
163         return startRegistry;
164     }
165 
166     /**
167      * Should we try to keep the registry alive
168      * <p>
169      * @return the useRegistryKeepAlive
170      */
171     @Override
172     public boolean isUseRegistryKeepAlive()
173     {
174         return useRegistryKeepAlive;
175     }
176 
177     /**
178      * @param registryKeepAliveDelayMillis the registryKeepAliveDelayMillis to set
179      */
180     @Override
181     public void setRegistryKeepAliveDelayMillis( long registryKeepAliveDelayMillis )
182     {
183         this.registryKeepAliveDelayMillis = registryKeepAliveDelayMillis;
184     }
185 
186     /**
187      * @return the registryKeepAliveDelayMillis
188      */
189     @Override
190     public long getRegistryKeepAliveDelayMillis()
191     {
192         return registryKeepAliveDelayMillis;
193     }
194 
195     /**
196      * @return String details
197      */
198     @Override
199     public String toString()
200     {
201         StringBuilder buf = new StringBuilder(super.toString());
202         buf.append( "\n servicePort = [" + this.getServicePort() + "]" );
203         buf.append( "\n allowClusterGet = [" + this.isAllowClusterGet() + "]" );
204         buf.append( "\n configFileName = [" + this.getConfigFileName() + "]" );
205         buf.append( "\n rmiSocketFactoryTimeoutMillis = [" + this.getRmiSocketFactoryTimeoutMillis() + "]" );
206         buf.append( "\n useRegistryKeepAlive = [" + this.isUseRegistryKeepAlive() + "]" );
207         buf.append( "\n registryKeepAliveDelayMillis = [" + this.getRegistryKeepAliveDelayMillis() + "]" );
208         buf.append( "\n eventQueueType = [" + this.getEventQueueType() + "]" );
209         buf.append( "\n eventQueuePoolName = [" + this.getEventQueuePoolName() + "]" );
210         return buf.toString();
211     }
212 }