Book Image

Getting Started with Hazelcast

By : Matthew Johns
Book Image

Getting Started with Hazelcast

By: Matthew Johns

Overview of this book

Table of Contents (18 chapters)
Getting Started with Hazelcast
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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>