View Javadoc
1   package org.apache.commons.jcs3.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.jcs3.auxiliary.remote.CommonRemoteCacheAttributes;
23  import org.apache.commons.jcs3.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;
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 final static 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 final static 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      }
63  
64      /**
65       * Gets the localPort attribute of the RemoteCacheAttributes object
66       * <p>
67       * @return The localPort value
68       */
69      @Override
70      public int getServicePort()
71      {
72          return this.servicePort;
73      }
74  
75      /**
76       * Sets the localPort attribute of the RemoteCacheAttributes object
77       * <p>
78       * @param p The new localPort value
79       */
80      @Override
81      public void setServicePort( final int p )
82      {
83          this.servicePort = p;
84      }
85  
86      /**
87       * Should gets from non-cluster clients be allowed to get from other remote auxiliaries.
88       * <p>
89       * @return The localClusterConsistency value
90       */
91      @Override
92      public boolean isAllowClusterGet()
93      {
94          return allowClusterGet;
95      }
96  
97      /**
98       * Should we try to get from other cluster servers if we don't find the items locally.
99       * <p>
100      * @param r The new localClusterConsistency value
101      */
102     @Override
103     public void setAllowClusterGet( final boolean r )
104     {
105         allowClusterGet = r;
106     }
107 
108     /**
109      * Gets the ConfigFileName attribute of the IRemoteCacheAttributes object
110      * <p>
111      * @return The clusterServers value
112      */
113     @Override
114     public String getConfigFileName()
115     {
116         return configFileName;
117     }
118 
119     /**
120      * Sets the ConfigFileName attribute of the IRemoteCacheAttributes object
121      * <p>
122      * @param s The new clusterServers value
123      */
124     @Override
125     public void setConfigFileName( final String s )
126     {
127         configFileName = s;
128     }
129 
130     /**
131      * Should we try to keep the registry alive
132      * <p>
133      * @param useRegistryKeepAlive the useRegistryKeepAlive to set
134      */
135     @Override
136     public void setUseRegistryKeepAlive( final boolean useRegistryKeepAlive )
137     {
138         this.useRegistryKeepAlive = useRegistryKeepAlive;
139     }
140 
141     /**
142      * Should we start the registry
143      * <p>
144      * @param startRegistry the startRegistry to set
145      * @deprecated Always true, to be removed
146      */
147     @Deprecated
148     @Override
149     public void setStartRegistry( final 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     @Deprecated
161     @Override
162     public boolean isStartRegistry()
163     {
164         return startRegistry;
165     }
166 
167     /**
168      * Should we try to keep the registry alive
169      * <p>
170      * @return the useRegistryKeepAlive
171      */
172     @Override
173     public boolean isUseRegistryKeepAlive()
174     {
175         return useRegistryKeepAlive;
176     }
177 
178     /**
179      * @param registryKeepAliveDelayMillis the registryKeepAliveDelayMillis to set
180      */
181     @Override
182     public void setRegistryKeepAliveDelayMillis( final long registryKeepAliveDelayMillis )
183     {
184         this.registryKeepAliveDelayMillis = registryKeepAliveDelayMillis;
185     }
186 
187     /**
188      * @return the registryKeepAliveDelayMillis
189      */
190     @Override
191     public long getRegistryKeepAliveDelayMillis()
192     {
193         return registryKeepAliveDelayMillis;
194     }
195 
196     /**
197      * @return String details
198      */
199     @Override
200     public String toString()
201     {
202         final StringBuilder buf = new StringBuilder(super.toString());
203         buf.append( "\n servicePort = [" + this.getServicePort() + "]" );
204         buf.append( "\n allowClusterGet = [" + this.isAllowClusterGet() + "]" );
205         buf.append( "\n configFileName = [" + this.getConfigFileName() + "]" );
206         buf.append( "\n rmiSocketFactoryTimeoutMillis = [" + this.getRmiSocketFactoryTimeoutMillis() + "]" );
207         buf.append( "\n useRegistryKeepAlive = [" + this.isUseRegistryKeepAlive() + "]" );
208         buf.append( "\n registryKeepAliveDelayMillis = [" + this.getRegistryKeepAliveDelayMillis() + "]" );
209         buf.append( "\n eventQueueType = [" + this.getEventQueueType() + "]" );
210         buf.append( "\n eventQueuePoolName = [" + this.getEventQueuePoolName() + "]" );
211         return buf.toString();
212     }
213 }