<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.java
<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.node
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.react
<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須要常常更新的話,由於其餘集羣成員的減小,就會致使性能的降低。
invalidate-on-change
決定是否釋放緩存的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>