|
1
|
|
|
package org.apereo.cas.configuration.model.support.hazelcast; |
|
2
|
|
|
|
|
3
|
|
|
import org.apereo.cas.configuration.support.RequiresModule; |
|
4
|
|
|
import org.apereo.cas.configuration.support.RequiredProperty; |
|
5
|
|
|
import org.apereo.cas.util.CollectionUtils; |
|
6
|
|
|
|
|
7
|
|
|
import java.io.Serializable; |
|
8
|
|
|
import java.util.List; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* This is {@link HazelcastClusterProperties}. |
|
12
|
|
|
* |
|
13
|
|
|
* @author Misagh Moayyed |
|
14
|
|
|
* @since 5.2.0 |
|
15
|
|
|
*/ |
|
16
|
|
|
@RequiresModule(name = "cas-server-support-hazelcast-ticket-registry") |
|
17
|
|
|
public class HazelcastClusterProperties implements Serializable { |
|
18
|
|
|
private static final long serialVersionUID = 1817784607045775145L; |
|
19
|
|
|
/** |
|
20
|
|
|
* Hazelcast has a flexible logging configuration and doesn't depend on any logging framework except JDK logging. |
|
21
|
|
|
* It has in-built adaptors for a number of logging frameworks and also supports custom loggers by providing logging interfaces. |
|
22
|
|
|
* To use built-in adaptors you should set this setting to one of predefined types below. |
|
23
|
|
|
* <ul> |
|
24
|
|
|
* <li>jdk: JDK logging</li> |
|
25
|
|
|
* <li>log4j: Log4j</li> |
|
26
|
|
|
* <li>slf4j: Slf4j</li> |
|
27
|
|
|
* <li>none: Disable logging</li> |
|
28
|
|
|
* </ul> |
|
29
|
|
|
*/ |
|
30
|
|
|
private String loggingType = "slf4j"; |
|
31
|
|
|
/** |
|
32
|
|
|
* Max timeout of heartbeat in seconds for a node to assume it is dead. |
|
33
|
|
|
*/ |
|
34
|
|
|
private int maxNoHeartbeatSeconds = 300; |
|
35
|
|
|
/** |
|
36
|
|
|
* The instance name. |
|
37
|
|
|
*/ |
|
38
|
|
|
@RequiredProperty |
|
39
|
|
|
private String instanceName = "localhost"; |
|
40
|
|
|
/** |
|
41
|
|
|
* You may also want to choose to use only one port. In that case, you can disable the auto-increment feature of port. |
|
42
|
|
|
*/ |
|
43
|
|
|
private boolean portAutoIncrement = true; |
|
44
|
|
|
/** |
|
45
|
|
|
* You can specify the ports which Hazelcast will use to communicate between cluster members. |
|
46
|
|
|
* The name of the parameter for this is port and its default value is 5701. |
|
47
|
|
|
* By default, Hazelcast will try 100 ports to bind. Meaning that, if you set the value of port as 5701, |
|
48
|
|
|
* as members are joining to the cluster, Hazelcast tries to find ports between 5701 and 5801. |
|
49
|
|
|
*/ |
|
50
|
|
|
@RequiredProperty |
|
51
|
|
|
private int port = 5701; |
|
52
|
|
|
/** |
|
53
|
|
|
* Enables a multicast configuration using a group address and port. |
|
54
|
|
|
* Contains the configuration for the multicast discovery mechanism. |
|
55
|
|
|
* With the multicast discovery mechanism Hazelcast allows Hazelcast members to find each other using multicast. |
|
56
|
|
|
* So Hazelcast members do not need to know concrete addresses of members, they just multicast to everyone listening. |
|
57
|
|
|
* It depends on your environment if multicast is possible or allowed; otherwise you need to have a look at the tcp/ip cluster |
|
58
|
|
|
*/ |
|
59
|
|
|
private boolean multicastEnabled; |
|
60
|
|
|
/** |
|
61
|
|
|
* Enable TCP/IP config. |
|
62
|
|
|
* Contains the configuration for the Tcp/Ip join mechanism. |
|
63
|
|
|
* The Tcp/Ip join mechanism relies on one or more well known members. So when a new member wants to join a cluster, it will try to connect |
|
64
|
|
|
* to one of the well known members. If it is able to connect, it will now about all members in the cluster |
|
65
|
|
|
* and doesn't rely on these well known members anymore. |
|
66
|
|
|
*/ |
|
67
|
|
|
private boolean tcpipEnabled = true; |
|
68
|
|
|
/** |
|
69
|
|
|
* Sets the well known members. |
|
70
|
|
|
* If members is empty, calling this method will have the same effect as calling clear(). |
|
71
|
|
|
* A member can be a comma separated string, e..g '10.11.12.1,10.11.12.2' which indicates multiple members are going to be added. |
|
72
|
|
|
*/ |
|
73
|
|
|
@RequiredProperty |
|
74
|
|
|
private List<String> members = CollectionUtils.wrap("localhost"); |
|
75
|
|
|
/** |
|
76
|
|
|
* Sets the maximum size of the map. |
|
77
|
|
|
*/ |
|
78
|
|
|
private int maxHeapSizePercentage = 85; |
|
79
|
|
|
/** |
|
80
|
|
|
* <ul> |
|
81
|
|
|
* <li>FREE_HEAP_PERCENTAGE: Policy based on minimum free JVM heap memory percentage per JVM.</li> |
|
82
|
|
|
* <li>FREE_HEAP_SIZE: Policy based on minimum free JVM heap memory in megabytes per JVM.</li> |
|
83
|
|
|
* <li>FREE_NATIVE_MEMORY_PERCENTAGE: Policy based on minimum free native memory percentage per Hazelcast instance.</li> |
|
84
|
|
|
* <li>FREE_NATIVE_MEMORY_SIZE: Policy based on minimum free native memory in megabytes per Hazelcast instance.</li> |
|
85
|
|
|
* <li>PER_NODE: Policy based on maximum number of entries stored per data structure (map, cache etc) on each Hazelcast instance.</li> |
|
86
|
|
|
* <li>PER_PARTITION: Policy based on maximum number of entries stored per data structure (map, cache etc) on each partition.</li> |
|
87
|
|
|
* <li>USED_HEAP_PERCENTAGE: Policy based on maximum used JVM heap memory percentage per data structure (map, cache etc) on each Hazelcast instance |
|
88
|
|
|
* .</li> |
|
89
|
|
|
* <li>USED_HEAP_SIZE: Policy based on maximum used JVM heap memory in megabytes per data structure (map, cache etc) on each Hazelcast instance.</li> |
|
90
|
|
|
* <li>USED_NATIVE_MEMORY_PERCENTAGE: Policy based on maximum used native memory percentage per data structure (map, cache etc) on each Hazelcast |
|
91
|
|
|
* instance.</li> |
|
92
|
|
|
* <li>USED_NATIVE_MEMORY_SIZE: Policy based on maximum used native memory in megabytes per data structure (map, cache etc) on each Hazelcast instance |
|
93
|
|
|
* .</li> |
|
94
|
|
|
* </ul> |
|
95
|
|
|
*/ |
|
96
|
|
|
private String maxSizePolicy = "USED_HEAP_PERCENTAGE"; |
|
97
|
|
|
/** |
|
98
|
|
|
* Hazelcast supports policy-based eviction for distributed maps. Currently supported policies |
|
99
|
|
|
* are LRU (Least Recently Used) and LFU (Least Frequently Used) and NONE. |
|
100
|
|
|
* See <a href="http://docs.hazelcast.org/docs/latest-development/manual/html/Distributed_Data_Structures/Map/Map_Eviction.html">this</a> for more info. |
|
101
|
|
|
*/ |
|
102
|
|
|
private String evictionPolicy = "LRU"; |
|
103
|
|
|
/** |
|
104
|
|
|
* To provide data safety, Hazelcast allows you to specify the number of backup copies you want to have. That way, |
|
105
|
|
|
* data on a cluster member will be copied onto other member(s). |
|
106
|
|
|
* To create synchronous backups, select the number of backup copies. |
|
107
|
|
|
* When this count is 1, a map entry will have its backup on one other member in the cluster. If you set it to 2, then a map entry will |
|
108
|
|
|
* have its backup on two other members. You can set it to 0 |
|
109
|
|
|
* if you do not want your entries to be backed up, e.g., if performance is more important than backing up. |
|
110
|
|
|
* The maximum value for the backup count is 6. |
|
111
|
|
|
* Sync backup operations have a blocking cost which may lead to latency issues. |
|
112
|
|
|
*/ |
|
113
|
|
|
private int backupCount = 1; |
|
114
|
|
|
/** |
|
115
|
|
|
* Hazelcast supports both synchronous and asynchronous backups. By default, backup operations are synchronous. |
|
116
|
|
|
* In this case, backup operations block operations until backups are successfully copied to backup members |
|
117
|
|
|
* (or deleted from backup members in case of remove) and acknowledgements are received. Therefore, backups are updated before a put operation |
|
118
|
|
|
* is completed, provided that the cluster is stable. |
|
119
|
|
|
* Asynchronous backups, on the other hand, do not block operations. They are |
|
120
|
|
|
* fire and forget and do not require acknowledgements; the backup operations are performed at some point in time. |
|
121
|
|
|
*/ |
|
122
|
|
|
private int asyncBackupCount; |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* Connection timeout in seconds for the TCP/IP config |
|
126
|
|
|
* and members joining the cluster. |
|
127
|
|
|
*/ |
|
128
|
|
|
private int timeout = 5; |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* IPv6 support has been switched off by default, since some platforms |
|
132
|
|
|
* have issues in use of IPv6 stack. And some other platforms such as Amazon AWS have no support at all. To enable IPv6 support |
|
133
|
|
|
* set this setting to false. |
|
134
|
|
|
*/ |
|
135
|
|
|
private boolean ipv4Enabled = true; |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* Multicast trusted interfaces for discovery. |
|
139
|
|
|
* With the multicast auto-discovery mechanism, Hazelcast allows cluster members to find each other using multicast communication. |
|
140
|
|
|
* The cluster members do not need to know the concrete addresses of the other members, |
|
141
|
|
|
* as they just multicast to all the other members for listening. Whether multicast is possible or allowed depends on your environment. |
|
142
|
|
|
*/ |
|
143
|
|
|
private String multicastTrustedInterfaces; |
|
144
|
|
|
/** |
|
145
|
|
|
* The multicast group address used for discovery. |
|
146
|
|
|
* With the multicast auto-discovery mechanism, Hazelcast allows cluster members to find each other using multicast communication. |
|
147
|
|
|
* The cluster members do not need to know the concrete addresses of the other members, |
|
148
|
|
|
* as they just multicast to all the other members for listening. Whether multicast is possible or allowed depends on your environment. |
|
149
|
|
|
*/ |
|
150
|
|
|
private String multicastGroup; |
|
151
|
|
|
/** |
|
152
|
|
|
* The multicast port used for discovery. |
|
153
|
|
|
*/ |
|
154
|
|
|
private int multicastPort; |
|
155
|
|
|
/** |
|
156
|
|
|
* specifies the time in seconds that a member should wait for a valid multicast response from another |
|
157
|
|
|
* member running in the network before declaring itself the leader member (the first member joined to the cluster) |
|
158
|
|
|
* and creating its own cluster. This only applies to the startup of members where no leader has been assigned yet. |
|
159
|
|
|
* If you specify a high value, such as 60 seconds, it means that until a leader is selected, |
|
160
|
|
|
* each member will wait 60 seconds before moving on. |
|
161
|
|
|
* Be careful when providing a high value. Also, be careful not to set the value too low, |
|
162
|
|
|
* or the members might give up too early and create their own cluster. |
|
163
|
|
|
*/ |
|
164
|
|
|
private int multicastTimeout = 2; |
|
165
|
|
|
/** |
|
166
|
|
|
* Gets the time to live for the multicast package in seconds. |
|
167
|
|
|
* This is the default time-to-live for multicast packets sent out on the socket |
|
168
|
|
|
*/ |
|
169
|
|
|
private int multicastTimeToLive = 32; |
|
170
|
|
|
|
|
171
|
|
|
public int getBackupCount() { |
|
172
|
|
|
return backupCount; |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
public void setBackupCount(final int backupCount) { |
|
176
|
|
|
this.backupCount = backupCount; |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
public int getAsyncBackupCount() { |
|
180
|
|
|
return asyncBackupCount; |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
public void setAsyncBackupCount(final int asyncBackupCount) { |
|
184
|
|
|
this.asyncBackupCount = asyncBackupCount; |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
public String getLoggingType() { |
|
188
|
|
|
return loggingType; |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
public void setLoggingType(final String loggingType) { |
|
192
|
|
|
this.loggingType = loggingType; |
|
193
|
|
|
} |
|
194
|
|
|
|
|
195
|
|
|
public int getMaxNoHeartbeatSeconds() { |
|
196
|
|
|
return maxNoHeartbeatSeconds; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
public void setMaxNoHeartbeatSeconds(final int maxNoHeartbeatSeconds) { |
|
200
|
|
|
this.maxNoHeartbeatSeconds = maxNoHeartbeatSeconds; |
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
public String getInstanceName() { |
|
204
|
|
|
return instanceName; |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
public void setInstanceName(final String instanceName) { |
|
208
|
|
|
this.instanceName = instanceName; |
|
209
|
|
|
} |
|
210
|
|
|
|
|
211
|
|
|
public boolean isPortAutoIncrement() { |
|
212
|
|
|
return portAutoIncrement; |
|
213
|
|
|
} |
|
214
|
|
|
|
|
215
|
|
|
public void setPortAutoIncrement(final boolean portAutoIncrement) { |
|
216
|
|
|
this.portAutoIncrement = portAutoIncrement; |
|
217
|
|
|
} |
|
218
|
|
|
|
|
219
|
|
|
public int getPort() { |
|
220
|
|
|
return port; |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
public void setPort(final int port) { |
|
224
|
|
|
this.port = port; |
|
225
|
|
|
} |
|
226
|
|
|
|
|
227
|
|
|
public boolean isMulticastEnabled() { |
|
228
|
|
|
return multicastEnabled; |
|
229
|
|
|
} |
|
230
|
|
|
|
|
231
|
|
|
public void setMulticastEnabled(final boolean multicastEnabled) { |
|
232
|
|
|
this.multicastEnabled = multicastEnabled; |
|
233
|
|
|
} |
|
234
|
|
|
|
|
235
|
|
|
public boolean isTcpipEnabled() { |
|
236
|
|
|
return tcpipEnabled; |
|
237
|
|
|
} |
|
238
|
|
|
|
|
239
|
|
|
public void setTcpipEnabled(final boolean tcpipEnabled) { |
|
240
|
|
|
this.tcpipEnabled = tcpipEnabled; |
|
241
|
|
|
} |
|
242
|
|
|
|
|
243
|
|
|
public List<String> getMembers() { |
|
244
|
|
|
return members; |
|
245
|
|
|
} |
|
246
|
|
|
|
|
247
|
|
|
public void setMembers(final List<String> members) { |
|
248
|
|
|
this.members = members; |
|
249
|
|
|
} |
|
250
|
|
|
|
|
251
|
|
|
public int getMaxHeapSizePercentage() { |
|
252
|
|
|
return maxHeapSizePercentage; |
|
253
|
|
|
} |
|
254
|
|
|
|
|
255
|
|
|
public void setMaxHeapSizePercentage(final int maxHeapSizePercentage) { |
|
256
|
|
|
this.maxHeapSizePercentage = maxHeapSizePercentage; |
|
257
|
|
|
} |
|
258
|
|
|
|
|
259
|
|
|
public String getMaxSizePolicy() { |
|
260
|
|
|
return maxSizePolicy; |
|
261
|
|
|
} |
|
262
|
|
|
|
|
263
|
|
|
public void setMaxSizePolicy(final String maxSizePolicy) { |
|
264
|
|
|
this.maxSizePolicy = maxSizePolicy; |
|
265
|
|
|
} |
|
266
|
|
|
|
|
267
|
|
|
public String getEvictionPolicy() { |
|
268
|
|
|
return evictionPolicy; |
|
269
|
|
|
} |
|
270
|
|
|
|
|
271
|
|
|
public void setEvictionPolicy(final String evictionPolicy) { |
|
272
|
|
|
this.evictionPolicy = evictionPolicy; |
|
273
|
|
|
} |
|
274
|
|
|
|
|
275
|
|
|
public String getMulticastTrustedInterfaces() { |
|
276
|
|
|
return multicastTrustedInterfaces; |
|
277
|
|
|
} |
|
278
|
|
|
|
|
279
|
|
|
public void setMulticastTrustedInterfaces(final String multicastTrustedInterfaces) { |
|
280
|
|
|
this.multicastTrustedInterfaces = multicastTrustedInterfaces; |
|
281
|
|
|
} |
|
282
|
|
|
|
|
283
|
|
|
public String getMulticastGroup() { |
|
284
|
|
|
return multicastGroup; |
|
285
|
|
|
} |
|
286
|
|
|
|
|
287
|
|
|
public void setMulticastGroup(final String multicastGroup) { |
|
288
|
|
|
this.multicastGroup = multicastGroup; |
|
289
|
|
|
} |
|
290
|
|
|
|
|
291
|
|
|
public int getMulticastPort() { |
|
292
|
|
|
return multicastPort; |
|
293
|
|
|
} |
|
294
|
|
|
|
|
295
|
|
|
public void setMulticastPort(final int multicastPort) { |
|
296
|
|
|
this.multicastPort = multicastPort; |
|
297
|
|
|
} |
|
298
|
|
|
|
|
299
|
|
|
public int getMulticastTimeout() { |
|
300
|
|
|
return multicastTimeout; |
|
301
|
|
|
} |
|
302
|
|
|
|
|
303
|
|
|
public void setMulticastTimeout(final int multicastTimeout) { |
|
304
|
|
|
this.multicastTimeout = multicastTimeout; |
|
305
|
|
|
} |
|
306
|
|
|
|
|
307
|
|
|
public int getMulticastTimeToLive() { |
|
308
|
|
|
return multicastTimeToLive; |
|
309
|
|
|
} |
|
310
|
|
|
|
|
311
|
|
|
public void setMulticastTimeToLive(final int multicastTimeToLive) { |
|
312
|
|
|
this.multicastTimeToLive = multicastTimeToLive; |
|
313
|
|
|
} |
|
314
|
|
|
|
|
315
|
|
|
public int getTimeout() { |
|
316
|
|
|
return timeout; |
|
317
|
|
|
} |
|
318
|
|
|
|
|
319
|
|
|
public void setTimeout(final int timeout) { |
|
320
|
|
|
this.timeout = timeout; |
|
321
|
|
|
} |
|
322
|
|
|
|
|
323
|
|
|
public boolean isIpv4Enabled() { |
|
324
|
|
|
return ipv4Enabled; |
|
325
|
|
|
} |
|
326
|
|
|
|
|
327
|
|
|
public void setIpv4Enabled(final boolean ipv4Enabled) { |
|
328
|
|
|
this.ipv4Enabled = ipv4Enabled; |
|
329
|
|
|
} |
|
330
|
|
|
|
|
331
|
|
|
} |
|
332
|
|
|
|