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

Hazelcast IMDG C++ Client

Extend the benefits of operational in-memory computing to your C++ applications running in Linux, Windows, and macOS.

  • Use the Hazelcast Near Cache feature to store frequently read data in your C++ process. This provides faster read speeds than traditional caches such as Redis or Memcached.
  • Access all of the Hazelcast data structures plus distributed queues, topics, and more with the Hazelcast IMDG C++ Client.
  • Provides SSL support for your enterprise-level security requirements.
  • Ability to discover the existing Hazelcast clusters in an AWS environment.
  • Asynchronously execute your tasks in the cluster, such as database queries, complex calculations, and image rendering.
  • Non-Blocking asynchronous methods for more powerful operations like batched writing or reading.
  • Ability to send multiple requests in parallel using a single thread via Pipelining API, which increases the throughput.
Download
Code Samples

Code Samples

Map Queue Topic List ReplicatedMap Set MultiMap RingBuffer
Enable Code Wrap
#include <hazelcast/client/hazelcast.h>

using namespace hazelcast::client;
int main() {
    // Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
    hazelcast_client hz;
    // Get the Distributed Map from Cluster.
    auto map = hz.get_map("my-distributed-map").get();
    //Standard Put and Get.
    map->put("key", "value").get();
    map->get("key").get();
    //Concurrent Map methods, optimistic updating
    map->put_if_absent("somekey", "somevalue").get();
    // use deferred future continuation
    auto future = map->replace("key", "value", "newvalue").then(
            boost::launch::deferred, [] (boost::future f) {
        if (f.get()) {
            std::cout << "Replaced successfully\n";
            return;
        }
        std::cerr << "Failed to replace\n";
    });

    // Wait until replace is completed
    future.get();

    // Shutdown this Hazelcast Client
    hz.shutdown();

    return 0;
}
Get this code sample on Github
#include <hazelcast/client/hazelcast.h>

using namespace hazelcast::client;
int main() {
    // Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
    hazelcast_client hz;
    // Get a Blocking Queue called "my-distributed-queue"
    auto queue = hz.get_queue("my-distributed-queue").get();
    // Offer a String into the Distributed Queue
    queue->offer("item").get();
    // Poll the Distributed Queue and return the String
    auto item = queue->poll().get();
    //Timed blocking Operations
    queue->offer("anotheritem", std::chrono::milliseconds(500)).get();
    auto anotherItem = queue->poll(std::chrono::seconds(5)).get();
    //Indefinitely blocking Operations
    queue->put("yetanotheritem");
    std::cout <take().get() << std::endl;
    // Shutdown this Hazelcast Client
    hz.shutdown();

    return 0;
}
Get this code sample on Github
#include <hazelcast/client/hazelcast.h>

using namespace hazelcast::client;

int main() {
    // Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
    hazelcast_client hz;
    // Get a Topic called "my-distributed-topic"
    auto topic = hz.get_topic("my-distributed-topic").get();
    // Add a Listener to the Topic
    topic->add_message_listener(
        topic::listener().
            on_received([](topic::message &&message) {
                std::cout << "Got message " << message.get_message_object().get().value_or("null") <publish("Hello to distributed world").get();
    // Shutdown this Hazelcast Client
    hz.shutdown();

    return 0;
}
Get this code sample on Github
#include <hazelcast/client/hazelcast.h>

using namespace hazelcast::client;
int main() {
    // Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
    hazelcast_client hz;
    // Get the Distributed List from Cluster.
    auto list = hz.get_list("my-distributed-list").get();
    // Add elements to the list
    list->add("item1").get();
    // Using future continuation here so that the calls are not blocking
    auto f = list->add("item2").then(boost::launch::deferred, [=] (boost::future f) {
       if (!f.get()) {
           std::cerr << "Element 2 could not be added !!!\n";
           return;
       }

        std::cout << std::boolalpha;
        // Remove the first element
        std::cout << "Removed: " <remove(0).get();
        // There is only one element left
        std::cout << "Current size is " <size().get() <clear().get();
    });

    // make the deferred future execute
    f.get();

    // Shutdown this Hazelcast Client
    hz.shutdown();

    return 0;
}
Get this code sample on Github
#include <hazelcast/client/hazelcast.h>

using namespace hazelcast::client;
int main() {
    // Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
    hazelcast_client hz;
    // Get a Replicated Map called "my-replicated-map"
    auto map = hz.get_replicated_map("my-replicated-map").get();
    // Add items to the set with duplicates
    // Put and Get a value from the Replicated Map
    auto replacedValue = map->put("key", "value").get();
    // key/value replicated to all members
    std::cout << "replacedValue = " <get("key").get();
    // the value is retrieved from a random member in the cluster
    std::cout << "value for key = " << value.value_or("null");
    // Shutdown this Hazelcast Client
    hz.shutdown();

    return 0;
}
Get this code sample on Github
#include <hazelcast/client/hazelcast.h>

using namespace hazelcast::client;
int main() {
    // Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
    hazelcast_client hz;
    // Get the Distributed Set from Cluster.
    auto set = hz.get_set("my-distributed-set").get();
    // Add items to the set with duplicates
    set->add("item1").get();
    set->add("item1").get();
    set->add("item2").get();
    set->add("item2").get();
    set->add("item2").get();
    set->add("item3").get();
    // Get the items. Note that there are no duplicates.
    auto future = set->to_array().then(boost::launch::deferred, [] (boost::future<std::vector> f) {
        for(auto &v : f.get()) {
            std::cout << v << '\n';
        }
    });

    // do something else
    //...
    // print the output
    future.get();

    // Shutdown this Hazelcast Client
    hz.shutdown();

    return 0;
}
Get this code sample on Github
#include <hazelcast/client/hazelcast.h>

using namespace hazelcast::client;
int main() {
    // Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
    hazelcast_client hz;
    // Get the Distributed MultiMap from Cluster.
    auto multiMap = hz.get_multi_map("my-distributed-multimap").get();
    // Put values in the map against the same key
    multiMap->put("my-key", "value1").get();
    multiMap->put("my-key", "value2").get();
    multiMap->put("my-key", "value3").get();
    // Print out all the values for associated with key called "my-key"
    multiMap->get("my-key").then(boost::launch::deferred,[] (boost::future<std::vector> f) {
        for (auto &value : f.get()) {
            std::cout << value <remove("my-key", "value2").get();    // Shutdown this Hazelcast Client
    hz.shutdown();

    return 0;
}
Get this code sample on Github
#include <hazelcast/client/hazelcast.h>

using namespace hazelcast::client;
int main() {
    // Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
    hazelcast_client hz;
    auto rb = hz.get_ringbuffer("rb").get();
    // add two items into ring buffer
    rb->add(100).get();
    rb->add(200).get();
    // we start from the oldest item.
    // if you want to start from the next item, call rb.tailSequence()+1
    int64_t sequence = rb->head_sequence().get();
    std::cout <read_one(sequence).get() << std::endl;
    sequence++;
    std::cout <read_one(sequence).get() << std::endl;
    // Shutdown this Hazelcast Client
    hz.shutdown();
}
Get this code sample on Github
Roadmap

Roadmap

C++ Client 4.0 (Mid January 2021)

  • Hazelcast IMDG 4.0 Changes: Client protocol enhancements, architectural improvements, Serialization improvements.
  • C++11 Support: The client code has been upgraded to use the C++11 features. The API has been changed to reflect the C++11 usages.
  • Idiomatic API: Redesign of the API in a way that C++ developers used to.
  • Fully Async API: Almost all API methods now return boost::future which allows async programming for all the API calls.
  • CP Subsystem Support: New Concurrency APIs including FencedLock, AtomicLong, Semaphore, CountDownLatch, and AtomicReference.
  • Backup Acknowledgment: Significantly improved client performance by eliminating the sync backup wait from the client and send the backup ACK to the client.
  • Ownerless Client: Simpler design to track member leaves and joins to the cluster.

C++ Client Backlog

  • Hazelcast Cloud Discovery: Ability to connect to your cluster on Hazelcast Cloud with a C++ client.
  • Mutual Authentication: Allows the clients to have their keyStores and members to have their trustStores so that the members can know which clients they can trust.
  • Envoy Proxy Caching: Utilize Hazelcast for microservices behind an Envoy Proxy.
  • Configuration Improvements: Declarative configuration, client configuration import, Fail Fast on Invalid Configuration
  • Blue/Green Deployments: Ability to divert the client automatically to another cluster on demand or when the intended cluster becomes unavailable.
Client Features

Features Implemented for this Client

DATA STRUCTURES

C++ Client

Map

Queue

Set

List

MultiMap

Replicated Map

Ring Buffer

Topic

Reliable Topic

JCache

N/A

Cardinality Estimator


CONCURRENCY PRIMITIVES

C++ Client

Lock

Condition

Semaphore

AtomicLong

AtomicReference

ID Generator

CountDownLatch

CRDT PN Counter

Flake ID Generator

DISTRIBUTED PROCESSING

C++ Client

Distributed Executor Service

Event Listeners

Sub-Listener Interfaces for Map Listener

Entry Processor

TRANSACTIONS

C++ Client

TxnMap

TxnMultiMap

TxnQueue

TxnList

TxnSet

QUERY

C++ Client

Query (Predicates)

Paging predicates

Partition predicate

Built-in Predicates

Continuous Query Caching

N/A

Listener with Predicate

Projections

Fast Aggregations

NEAR CACHE

C++ Client

Near Cache Support

HD Memory

N/A

Preload Cache from Last Used

Eventual Consistency Control

CONFIGURATION

C++ Client

Declarative Config (XML/JSON/YAML)

Programmatic Configuration

Client Configuration Import

Fail Fast on Invalid Configuration

SECURITY

C++ Client

SSL Support

XA Transactions

Mutual Authentication

Authorization

Custom Authentication Modules

MANAGEMENT CENTER

C++ Client

Management Center Integration / Awareness

Client Near Cache Stats

Client Runtime Stats

Client Operating Systems Stats

CLOUD

C++ Client

Hazelcast Cloud

Kubernetes

AWS

Azure

Google Cloud Platform

Pivotal Cloud Foundry

Docker

Apache jclouds

Consul

etcd

Eureka

Heroku

Zookeeper

INFRASTRUCTURE

C++ Client

Smart Client

Unisocket Client

Lifecycle Service

HeartBeat

Backup Acknowledgement to Client

Diagnostics

SERIALIZATION

C++ Client

DataSerializable

N/A

IdentifiedDataSerializable

Portable Serialization

Portable Serialization

Global Serializers

CLIENT CONNECTIVITY

C++ Client

Connection Strategy

Connection Retry

Blue/Green Deployments and Disaster Recovery

Support for Clients & Languages

Jump into the discussion on our groups.

Join Us On Slack