Reader small image

You're reading from  Getting Started with Hazelcast

Product typeBook
Published inAug 2013
Reading LevelBeginner
Publisher
ISBN-139781782167303
Edition1st Edition
Languages
Right arrow
Author (1)
Matthew Johns
Matthew Johns
author image
Matthew Johns

contacted on 6 may '16 ________ Matthew Johns is an agile software engineer and hands-on technical/solution architect; specialising in designing and delivering highly scaled and available distributed systems, with broad experience across the whole stack. He is the solution architect and lead engineer at Sky.
Read more about Matthew Johns

Right arrow

Appendix A. Configuration Summary

Throughout this book we have progressively listed a number of configurations used to customize and modify the behavior of the Hazelcast cluster; here we bring them together as a quick reference.

XML configuration


The following is a complete example of the hazelcast.xml configuration file with an overview of each section within it:

<hazelcast>

Cluster name

  <group>
    <name>dev</name>
    <password>dev-pass</password>
  </group>
Management Center
  <management-center enabled="true" update-interval="5">
    http://manager-center-host:8080/mancenter
  </management-center>

General Properties
  <properties>
    <property name="hazelcast.map.partition.count">271</property>
  </properties>

WAN replication configuration

  <wan-replication name="our-global-cluster">
    <target-cluster group-name="paris" group-password="paris-pass">

      <replication-impl>
        com.hazelcast.impl.wan.WanNoDelayReplication
      </replication-impl>
      <end-points>
        <address>12.34.56.78:5701</address>
      </end-points>

    </target-cluster>
  </wan-replication>

Local network/interface binding

  <network>
    <port auto-increment="false">5701</port>

    <interfaces enabled="true">
      <interface>192.168.0.*</interface>
    </interfaces>

Cluster discovery

Multicast, Unicast, or EC2-based

    <join>
      <multicast enabled="true">
        <multicast-group>224.2.2.3</multicast-group>
        <multicast-port>54327</multicast-port>
      </multicast>
      <tcp-ip enabled="true">
        <interface>127.0.0.1</interface>
      </tcp-ip>
      <aws enabled="true">
        <access-key>ourApiAccessKey</access-key>
        <secret-key>ourApiSecretKey</secret-key>
        <region>eu-west-1</region>
      </aws>
    </join>
  </network>

Per map or default map configuration

  <map name="capitals">

cluster_wide_map_size
partitions_wide_map_size
max_size_per_jvm
used_heap_size
used_heap_percentage
    <max-size policy="cluster_wide_map_size">10</max-size>

LRU: Least Recently Used

LFU: Least Frequently Used

NONE

    <eviction-policy>LFU</eviction-policy>
    <eviction-percentage>20</eviction-percentage>

Backup = Synchronous copies
Async = Asynchronous copies
Total copies = 1 Main + Backup + Async
    <backup-count>1</backup-count>
    <async-backup-count>1</async-backup-count>

Age expiry and idle expiry times

    <time-to-live-seconds>86400</time-to-live-seconds>
    <max-idle-seconds>3600</max-idle-seconds>

hz.NO_MERGE
hz.ADD_NEW_ENTRY
hz.HIGHER_HITS
hz.LATEST_UPDATE
    <merge-policy>hz.LATEST_UPDATE</merge-policy>

Selected WAN replication configuration

    <wan-replication-ref name="our-global-cluster">
      <merge-policy> hz.LATEST_UPDATE </merge-policy>
    </wan-replication-ref>

Indexes on values

    <indexes>
      <index ordered="false">name</index>
      <index ordered="true">population</index>
    </indexes>

Listeners notified on map events

    <entry-listeners>
      <entry-listener include-value="true" local="false">
        com.packtpub.hazelcast.listeners.MapEntryListener
      </entry-listener>
    </entry-listeners>

  </map>

Listener notified on topic broadcast

  <topic name="default">
    <message-listeners>
      <message-listener>
        com.hazelcast.examples.MessageListener
      </message-listener>
    </message-listeners>
  </topic>

Cluster-wide listener registration

  <listeners>
    <listener>
      com.packtpub.hazelcast.listeners.TopicListener
    </listener>
  </listeners>

</hazelcast>

Programmatic configuration


As we saw within the book, it is also possible to configure Hazelcast programmatically, this can provide for a higher application control of the cluster.

Set general properties

Config conf = new Config();
 conf.setProperty("hazelcast.map.partition.count", "271");

Set instance name

conf.setInstanceName("my-instance");

Set as lite member

conf.setLiteMember(true);

Get reference to map configuration

MapConfig citiesConf = conf.getMapConfig("cities");

Modify default behavior

citiesConf.setBackupCount(2);
citiesConf.setAsyncBackupCount(1);

Add map index

citiesConf.addMapIndexConfig(
  new MapIndexConfig("country", false));
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Getting Started with Hazelcast
Published in: Aug 2013Publisher: ISBN-13: 9781782167303
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Matthew Johns

contacted on 6 may '16 ________ Matthew Johns is an agile software engineer and hands-on technical/solution architect; specialising in designing and delivering highly scaled and available distributed systems, with broad experience across the whole stack. He is the solution architect and lead engineer at Sky.
Read more about Matthew Johns