Get Started

Get Started

These guides demonstrate how to get started quickly with Hazelcast IMDG and Hazelcast Jet.

Hazelcast IMDG

Learn how to store and retrieve data from a distributed key-value store using Hazelcast IMDG. In this guide you’ll learn how to:

  • Create a cluster of 3 members.
  • Start Hazelcast Management Center
  • Add data to the cluster using a sample client in the language of your choice
  • Add and remove some cluster members to demonstrate data balancing capabilities of Hazelcast

Hazelcast Jet

Learn how to build a distributed data processing pipeline in Java using Hazelcast Jet. In this guide you’ll learn how to:

  • Install Hazelcast Jet and form a cluster on your computer
  • Build a simple pipeline that receives a stream of data, does some calculations and outputs some results
  • Submit the pipeline as a job to the cluster and observe the results
  • Scale the cluster up and down while the job is still running

Distribute Your Data

You’re an engineer who wants to distribute data for caching and sharing. Learn how to use Hazelcast data structures.

The quickest way to learn how to use Hazelcast IMDG is to start up a cluster and add some data to it. Check out the Getting Started Guide. Then we suggest you enroll in free training and take the Hazelcast IMDG Overview course. If you’re on the move, listen to a quick 10-minute podcast from one of the community engineers describing what Hazelcast is all about.

There are many caching technologies available, but we believe Hazelcast is the best, and here are seven reasons why.

Once you are ready to begin looking at the wider set of data structures, check out the extensive examples in all client languages. Links to each repository are below. For a quick start:

Here’s how you can add entries to a distributed map using a Java client

import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;

import java.util.Map;

public class FillMapMember {

    public static void main(String[] args) {
        HazelcastInstance hz = Hazelcast.newHazelcastInstance();
        Map<String, String> map = hz.getMap("map");
        map.put("1", "Tokyo");
        map.put("2", "Paris");
        map.put("3", "New York");
        System.out.println("Finished loading map");
    }
}

Here’s a simple predicate query over some data in Java

import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.map.IMap;
import com.hazelcast.query.Predicates;

import java.util.Set;

public class SqlQueryMember {

    public static void main(String[] args) {
        HazelcastInstance hz = Hazelcast.newHazelcastInstance();
        IMap<String, Customer> map = hz.getMap("map");

        map.put("1", new Customer("peter", true, 36));
        map.put("2", new Customer("john", false, 40));
        map.put("3", new Customer("roger", true, 20));

        Set employees = (Set) map.values(Predicates.sql("active AND age < 30"));
        System.out.println("Employees: " + employees);

        Hazelcast.shutdownAll();
    }
}

How about using a set in .NET?

using System;
using Hazelcast.Client;
using Hazelcast.Config;

namespace Hazelcast.Examples.Collections
{
    internal class SetExample
    {
        private static void Run(string[] args)
        {
            Environment.SetEnvironmentVariable("hazelcast.logging.level", "info");
            Environment.SetEnvironmentVariable("hazelcast.logging.type", "console");

            var config = new ClientConfig();
            config.GetNetworkConfig().AddAddress("127.0.0.1");
            var client = HazelcastClient.NewHazelcastClient(config);

            var set = client.GetSet("set-example");

            set.Add("item1");
            set.Add("item2");
            set.Add("item3");
            set.Add("item3");

            Console.WriteLine("Enumerator : " + string.Join(", ", set));

            Console.WriteLine("Contains: " + string.Join(", ", set.Contains("item2")));

            Console.WriteLine("Count: " + string.Join(", ", set.Count));

            set.Destroy();
            client.Shutdown();
        }
    }
}

Make use of the CRDT PN counter in Python

import hazelcast
import logging

if __name__ == "__main__":
    logging.basicConfig()
    logging.getLogger().setLevel(logging.INFO)

    client = hazelcast.HazelcastClient()

    pn_counter = client.get_pn_counter("pn-counter").blocking()

    print("Counter is initialized with {}".format(pn_counter.get()))

    for i in range(10):
        print("Added {} to the counter. Current value is {}".format(i, pn_counter.add_and_get(i)))

    print("Incremented the counter after getting the current value. "
          "Previous value is {}".format(pn_counter.get_and_increment()))

    print("Final value is {}".format(pn_counter.get()))

Generate a unique cluster-wide ID using Go

package main

import (
	"fmt"

	"github.com/hazelcast/hazelcast-go-client"
)

func main() {

	config := hazelcast.NewConfig()
	config.NetworkConfig().AddAddress("127.0.0.1:5701")
	client, err := hazelcast.NewClientWithConfig(config)
	if err != nil {
		fmt.Println(err)
		return
	}
	flakeIDGenerator, _ := client.GetFlakeIDGenerator("generator")
	id, _ := flakeIDGenerator.NewID()
	fmt.Printf("new id : %d", id)

	flakeIDGenerator.Destroy()
	client.Shutdown()

}

Free Hazelcast Online Training Center

Whether you're interested in learning the basics of in-memory systems, or you're looking for advanced, real-world production examples and best practices, we've got you covered.

Open Gitter Chat