Book Image

Getting Started with Hazelcast, Second Edition

By : Matthew Johns
Book Image

Getting Started with Hazelcast, Second Edition

By: Matthew Johns

Overview of this book

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

Cluster discovery (multicast-, unicast-, or EC2-based)


This is used to discover peers to form a cluster; remember that only one of these three options can be used for each node and ideally, should be common for the cluster as a whole.

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

NetworkConfig nc = config.getNetworkConfig();
JoinConfig jc = nc.getJoin();

jc.getMulticastConfig()
 .setMulticastGroup("224.2.2.3")
 .setMulticastPort(54327)
 .setEnabled(true);

jc.getTcpIpConfig()
 .addMember("127.0.0.1")
 .setEnabled(true);

jc.getAwsConfig()
 .setAccessKey("ourApiAccessKey")
 .setSecretKey("ourApiSecretKey")
 .setRegion("eu-west-1")
 .setEnabled(true);