Hazel Cast
Hazel Cast
1 INSTALLATION
Please add the following maven dependencies to your maven project.
Hazel server
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast</artifactId>
<version>3.1.3</version>
</dependency>
Hazel client
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-client</artifactId>
<version>3.1.3</version>
</dependency>
1 HELLO WORLD-SERVER
public static void main(String[] args) {
Config cfg = new Config();
HazelcastInstance instance = Hazelcast.newHazelcastInstance(cfg);
Map<Integer, String> mapCustomers = instance.getMap("customers");
mapCustomers.put(1, "Joe");
mapCustomers.put(2, "Ali");
mapCustomers.put(3, "Avi");
System.out.println("Customer with key 1: " + mapCustomers.get(1));
System.out.println("Map Size:" + mapCustomers.size());
}
Note: Run the app twice
Output: cluster formation
Customer with key 1: Joe
Map Size:3
Members [2] {
Member [10.252.18.12]:5701 this
Member [10.252.18.12]:5702
}