0% found this document useful (0 votes)
37 views2 pages

Hazel Cast

This document provides instructions and examples for installing and using Hazelcast, an open-source distributed map and computing platform. It describes how to add Hazelcast dependencies to a Maven project, run a simple "Hello World" example to create a map on the server and access it from the client, and how to configure and instantiate a Hazelcast client to connect to the server and retrieve map data.

Uploaded by

anilkd11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views2 pages

Hazel Cast

This document provides instructions and examples for installing and using Hazelcast, an open-source distributed map and computing platform. It describes how to add Hazelcast dependencies to a Maven project, run a simple "Hello World" example to create a map on the server and access it from the client, and how to configure and instantiate a Hazelcast client to connect to the server and retrieve map data.

Uploaded by

anilkd11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Hazelcast

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
}

2 HAZELCAST CLIENT CLIENT


public static void main(String[] args) {
ClientConfig clientConfig = new ClientConfig();
clientConfig.addAddress("127.0.0.1:5701");
HazelcastInstance client =
HazelcastClient.newHazelcastClient(clientConfig);

IMap map = client.getMap("customers");


System.out.println("Map Size:" + map.size());

You might also like