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

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));