<group>
<name>openfire</name>
<password>openfire</password>
</group>
You can create cluster groups. To do this, use the group configuration element.By specifying a group name and group password, you can separate your clusters in a simple way. Example groupings can be by development, production, test, app, etc. The following is an example declarative configuration.
<properties>
<property name="hazelcast.logging.type">slf4j</property>
<property name="hazelcast.operation.call.timeout.millis">30000</property>
<property name="hazelcast.memcache.enabled">false</property>
<property name="hazelcast.rest.enabled">false</property>
</properties>
Hazelcast has a flexible logging configuration and does not depend on any logging framework except JDK logging. It has built-in adaptors for a number of logging frameworks and it also supports custom loggers by providing logging interfaces.
To use built-in adaptors, set the hazelcast.logging.type property to one of the predefined types below.
jdk: JDK logging (default)
log4j: Log4j
slf4j: Slf4j
none: disable logging
You can set hazelcast.logging.type through declarative configuration, programmatic configuration, or JVM system property.
<management-center enabled="false"/>
<network><!--网络配置-->
<port auto-increment="true" port-count="100">5701</port><!--端口-->
<outbound-ports><!--出站端口-->
<ports>0</ports>
</outbound-ports>
<join>
<multicast enabled="true">
<multicast-group>224.2.2.3</multicast-group>
<multicast-port>54327</multicast-port>
</multicast>
<tcp-ip enabled="false"/>
<aws enabled="false"/>
</join>
<interfaces enabled="false">
<interface>10.10.1.*</interface>
</interfaces>
<ssl enabled="false"/>
<socket-interceptor enabled="false"/>
<symmetric-encryption enabled="false">
<!--
encryption algorithm such as
DES/ECB/PKCS5Padding,
PBEWithMD5AndDES,
AES/CBC/PKCS5Padding,
Blowfish,
DESede
-->
<algorithm>PBEWithMD5AndDES</algorithm>
<!-- salt value to use when generating the secret key -->
<salt>thesalt</salt>
<!-- pass phrase to use when generating the secret key -->
<password>thepass</password>
<!-- iteration count to use when generating the secret key -->
<iteration-count>19</iteration-count>
</symmetric-encryption>
</network>
You can specify which network interfaces that Hazelcast should use. Servers mostly have more than one network interface, so you may want to list the valid IPs. Range characters (‘’ and ‘-‘) can be used for simplicity. For instance, 10.3.10. refers to IPs between 10.3.10.0 and 10.3.10.255. Interface 10.3.10.4-18 refers to IPs between 10.3.10.4 and 10.3.10.18 (4 and 18 included). If network interface configuration is enabled (it is disabled by default) and if Hazelcast cannot find an matching interface, then it will print a message on the console and will not start on that node
Hazelcast allows you to use SSL socket communication among all Hazelcast members. To use it, you need to implement com.hazelcast.nio.ssl.SSLContextFactory and configure the SSL section in network configuration.
<network>
...
<ssl enabled="true">
<factory-class-name>
com.hazelcast.examples.MySSLContextFactory
</factory-class-name>
<properties>
<property name="foo">bar</property>
</properties>
</ssl>
</network>
Hazelcast provides a default SSLContextFactory, com.hazelcast.nio.ssl.BasicSSLContextFactory, which uses configured keystore to initialize SSLContext. You define keyStore and keyStorePassword, and you can set keyManagerAlgorithm (default SunX509), trustManagerAlgorithm (default SunX509) and protocol (default TLS).
<network>
...
<ssl enabled="true">
<factory-class-name>
com.hazelcast.nio.ssl.BasicSSLContextFactory
</factory-class-name>
<properties>
<property name="keyStore">keyStore</property>
<property name="keyStorePassword">keyStorePassword</property>
<property name="keyManagerAlgorithm">SunX509</property>
<property name="trustManagerAlgorithm">SunX509</property>
<property name="protocol">TLS</property>
</properties>
</ssl>
</network>
<network>
...
<socket-interceptor enabled="true">
<class-name>com.hazelcast.examples.MySocketInterceptor</class-name>
<properties>
<property name="kerberos-host">kerb-host-name</property>
<property name="kerberos-config-file">kerb.conf</property>
</properties>
</socket-interceptor>
...
</network>
<symmetric-encryption enabled="true">
<!--encryption algorithm such as
DES/ECB/PKCS5Padding,
PBEWithMD5AndDES,
Blowfish,
DESede
-->
<algorithm>PBEWithMD5AndDES</algorithm><!--加密方式-->
<!-- salt value to use when generating the secret key -->
<salt>thesalt</salt>
<!-- pass phrase to use when generating the secret key -->
<password>thepass</password>
<!-- iteration count to use when generating the secret key -->
<iteration-count>19</iteration-count><!--迭代次数-->
</symmetric-encryption>
You can do custom grouping using Hazelcast’s interface matching configuration. This way, you can add different and multiple interfaces to a group. You can also use wildcards in the interface addresses. For example, the users can create rack aware or data warehouse partition groups using custom partition grouping
<partition-group enabled="true" group-type="CUSTOM">
<member-group>
<interface>10.10.0.*</interface>
<interface>10.10.3.*</interface>
<interface>10.10.5.*</interface>
</member-group>
<member-group>
<interface>10.10.10.10-100</interface>
<interface>10.10.1.*</interface>
<interface>10.10.2.*</interface>
</member-group
</partition-group>
<executor-service name="exec">
<pool-size>1</pool-size>
<queue-capacity>10</queue-capacity>
<statistics-enabled>true</statistics-enabled>
</executor-service>
pool-size: The number of executor threads per Member for the Executor.
queue-capacity: Executor’s task queue capacity.
statistics-enabled: Some statistics like pending operations count, started operations count, completed operations count, cancelled operations count can be retrieved by setting this parameter’s value as true. The method for retrieving the statistics is getLocalExecutorStats().
<queue name="default">
<!--
队列的最大值。当JVM本地队列大小达到最大值时,所有put/offer操作将被封锁,直到队列的大小下降低于JVM的最大值。值为0和Integer.MAX_VALUE之间的任何整数。0表示Integer.MAX_VALUE. 默认值为0。
-->
<max-size>0</max-size>
<!--
备份的数量。如果1设置为备份数量,也就是说为了安全将map上的所有条目复制到另一个JVM上
。0表示没有备份。
-->
<backup-count>1</backup-count>
<!--
异步备份数量,0表示没有备份
-->
<async-backup-count>0</async-backup-count>
<!--空队列生存时间,-1表示一直存在-->
<empty-queue-ttl>-1</empty-queue-ttl>
</queue>
<hazelcast>
<multimap name="default">
<backup-count>0</backup-count>
<async-backup-count>1</async-backup-count>
<value-collection-type>SET</value-collection-type>
<entry-listeners>
<entry-listener include-value="false" local="false">
com.hazelcast.examples.EntryListener
</entry-listener>
</entry-listeners>
</map>
</hazelcast>
<list name="default">
<backup-count>1</backup-count>
<async-backup-count>0</async-backup-count>
<max-size>10</max-size>
<item-listeners>
<item-listener>
com.hazelcast.examples.ItemListener
</item-listener>
</item-listeners>
</list>
<set name="default">
<backup-count>1</backup-count>
<async-backup-count>0</async-backup-count>
<max-size>10</max-size>
<item-listeners>
<item-listener>
com.hazelcast.examples.ItemListener
</item-listener>
<item-listeners>
</set>
<jobtracker name="default">
<max-thread-size>0</max-thread-size>
<!-- Queue size 0 means number of partitions * 2 -->
<queue-size>0</queue-size>
<retry-count>0</retry-count>
<chunk-size>1000</chunk-size>
<communicate-stats>true</communicate-stats>
<topology-changed-strategy>CANCEL_RUNNING_OPERATION</topology-changed-strategy>
</jobtracker>
max-thread-size: Configures the maximum thread pool size of the JobTracker.
queue-size: Defines the maximum number of tasks that are able to wait to be processed. A value of 0 means an unbounded queue. Very low numbers can prevent successful execution since job might not be correctly scheduled or intermediate chunks might be lost.
retry-count: Currently not used. Reserved for later use where the framework will automatically try to restart / retry operations from an available save point.
chunk-size: Defines the number of emitted values before a chunk is sent to the reducers. If your emitted values are big or you want to better balance your work, you might want to change this to a lower or higher value. A value of 0 means immediate transmission, but remember that low values mean higher traffic costs. A very high value might cause an OutOfMemoryError to occur if the emitted values do not fit into heap memory before being sent to the reducers. To prevent this, you might want to use a combiner to pre-reduce values on mapping nodes.
communicate-stats: Defines if statistics (for example, statistics about processed entries) are transmitted to the job emitter. This can show progress to a user inside of an UI system, but it produces additional traffic. If not needed, you might want to deactivate this.
topology-changed-strategy: Defines how the MapReduce framework will react on topology changes while executing a job. Currently, only CANCEL_RUNNING_OPERATION is fully supported, which throws an exception to the job emitter (will throw a com.hazelcast.mapreduce.TopologyChangedException).
<semaphore name="default">
<initial-permits>0</initial-permits>
<backup-count>1</backup-count>
<async-backup-count>0</async-backup-count>
</semaphore>
initial-permits:在并发存取的状况下,线程的数目。例如,设为3,那么并发存取限制为3条线;
backup-count: 同步备份的数目;
async-backup-count: 同步备份的数目。
<reliable-topic name="default">
<read-batch-size>10</read-batch-size>
<topic-overload-policy>BLOCK</topic-overload-policy>
<statistics-enabled>true</statistics-enabled>
</reliable-topic>
statistics-enabled: 允许或者禁止reliable topic使用统计量集合,默认值为true;
read-batch-size:Reliable Topic从群组中读取到的消息的最小数量,默认值为10;
topic-overload-policy:控制超负载的策略,可用的值为DISCARD_OLDEST,DISCARD_NEWST,BLOCK和ERROR,默认值为BLOCK。
<ringbuffer name="default">
<capacity>10000</capacity>
<backup-count>1</backup-count>
<async-backup-count>0</async-backup-count>
<time-to-live-seconds>30</time-to-live-seconds>
<in-memory-format>BINARY</in-memory-format>
</ringbuffer>
capacity:Ringbuffer内存的大小,默认值为10000;
time-to-live-seconds:项目在Ringbuffer中保留的时间,如果设为0,那么它是不可用的,默认值为0;
backup-count: 同步备份的数量,默认值为1;
async-backup-count: 同步备份的数量,默认值为0;
in-memory-format: 当项目存储在Ringbuffer中时的格式,可用的值为OBJECT和BINARY,默认值为BINARY。
<serialization>
<portable-version>0</portable-version>
</serialization>
portable-version:定义了便携式序列化的版本,便携式版本可以区分两个相同的类的,一旦类稍有改变 ,例如增加/移除方法,或将方法的名称进行改变。
<services enable-defaults="true"/>
启用该服务。
Hazelcast Map(即IMAP)扩展了java.util.concurrent.ConcurrentMap接口,继承了java.util.Map类。它是Java map的分布式实现。我们可以从Hazelcast map中读或写通过get和put方法。
该标签决定数据在内存中存储的方式。它有三种值:BINARY,OBJECT,NATIVA。BINARY是默认的选项,将数据存储为连续的二进制的格式;如果设置为OBJECT,数据将会以非连续的形式存储;数据将会被存储在JVM的非堆区。
同步备份的数目,如果设的值为1,为了防止发生错误,map的所有内容将被复制到另一个JVM。如果数目为0,就意味着不进行备份。
同步备份的数目,0意味着不备份。
是否可以读取本地的备份接口,默认值为false使之具有更强的一致性。允许读取备份数据会给用户更多的权利。
入口在map中存活的最大的秒数。存活的时间比设置的时间长,并且没有更新的值时,入口将会自动从map中释放。它的取值范围是0到Integer.MAX_VALUE。0意味着无穷大,并且默认值为0。
<time-to-live-seconds>0</time-to-live-seconds>
在map中每个entry保持空闲的最大时间。
<max-idle-seconds>0</max-idle-seconds>
entry的释放政策,有效值为:NONE,不释放;LRU(Least Recently Used),释放最少的最近使用过的entry;LFU(Least Frequently Used),释放最少的最常使用的entry。
<eviction-policy>LRU</eviction-policy>
map的最大数目(即,map最大的entry数)。当达到最大数目时,map将会按已定义的释放政策进行操作。它有四种属性:PER_NODE,JVM中最大的map entry数;PER_PARTITION,在各分区中最大的entry数;USED_HEAP_SIZE,在JVM中以兆计的最大使用堆数;USED_HEAP_PERCENTAGE,在JVM中,使用堆的最大百分比。
<max-size policy="PER_NODE">100000</max-size>
当达到最大数目时,被释放的百分比。如果值为25,那么25%的接口将会被释放。
<eviction-percentage>25</eviction-percentage>
检测部分map是否被释放前经过的最短时间,以毫秒计。默认值为100毫秒。
<min-eviction-check-millis>100</min-eviction-check-millis>
当从分裂中回复时,在小集群里的map接口将会合并到大的集群中取,基于这里设置的政策。当一个接口合并到集群中时 ,集群中可能已经存在拥有相同键得接口。但对于相同的键,它们的数值可能不尽相同。那么,该给这个键设置怎样的值呢?这个政策将会解决这个冲突。默认的政策为PutIfAbsentMapMergePolicy.
以下为内置的合并政策:
com.hazelcast.map.merge.PassThroughMergePolicy,如果没有对于键没有存在的接口,那么接口会添加进集群;
com.hazelcast.map.merge.PutIfAbsentMapMergePolicy,如果在集群中不存在这样的集成接口,接口就会被加入 ;
com.hazelcast.map.merge.HigherHitsMapMergePolicy ,具有更高值得接口会被加入。
com.hazelcast.map.merge.LatestUpdateMapMergePolicy ,最新的接口将被加入。
<merge-policy>com.hazelcast.map.merge.PassThroughMergePolicy</merge-policy>
near-cache提供了一个对map集群的本地视图,它对于高速缓存是非常理想的。每一个集群成员会从分布式的map中保存一份entry到本地种。这减少了经常需要读取时的网络缓存。但是,如果entry需要经常更新的话,因为其他集群成员的减少,就会导致性能的下降。
决定是否释放缓存的entry,如果entry更新或者移除了。
<near-cache>
<max-size>1000</max-size>
<time-to-live-seconds>0</time-to-live-seconds>
<max-idle-seconds>600</max-idle-seconds>
<eviction-policy>LRU</eviction-policy>
<invalidate-on-change>true</invalidate-on-change>
</near-cache>