Apache Ignite Documentation

GridGain Developer Hub - Apache Ignitetm

Welcome to the Apache Ignite developer hub run by GridGain. Here you'll find comprehensive guides and documentation to help you start working with Apache Ignite as quickly as possible, as well as support if you get stuck.

 

GridGain also provides Community Edition which is a distribution of Apache Ignite made available by GridGain. It is the fastest and easiest way to get started with Apache Ignite. The Community Edition is generally more stable than the Apache Ignite release available from the Apache Ignite website and may contain extra bug fixes and features that have not made it yet into the release on the Apache website.

 

Let's jump right in!

 

Documentation     Ask a Question     Download

 

Javadoc     Scaladoc     Examples

Leader Election

Automatically select oldest or youngest cluster nodes.

Overview

When working in distributed environments, sometimes you need to have a guarantee that you will always pick the same node, regardless of the cluster topology changes. Such nodes are usually called leaders.

In many systems, electing cluster leaders usually has to do with data consistency and is handled via collecting votes from cluster members. Since in Ignite the data consistency is handled by data grid affinity function (e.g. Rendezvous Hashing), picking leaders in the traditional sense for data consistency outside of the data grid is not needed.

However, you may still wish to have a coordinator node for certain tasks. For this purpose, Ignite lets you automatically always pick either the oldest or the youngest node in the cluster.

🚧

Use Service Grid

Note that for most leader or singleton-like use cases, you should use the Service Grid functionality, as it allows you to automatically deploy various Cluster Singleton Services and is usually easier to use.

Oldest Node

The oldest node has a property that it remains constant whenever new nodes are added. The only time when the oldest node in the cluster changes is when it leaves the cluster or crashes.

Here is an example of how to select Cluster Group with only the oldest node in it.

IgniteCluster cluster = ignite.cluster();

// Dynamic cluster group representing the oldest cluster node.
// Will automatically shift to the next oldest, if the oldest
// node crashes.
ClusterGroup oldestNode = cluster.forOldest();

Youngest Node

The youngest node, unlike the oldest node, constantly changes every time a new node joins a cluster. However, sometimes it may still be useful, especially if you need to execute some task only on the newly joined node.

Here is an example of how to select Cluster Group with only the youngest node in it.

IgniteCluster cluster = ignite.cluster();

// Dynamic cluster group representing the youngest cluster node.
// Will automatically shift to the next youngest, if the youngest
// node crashes.
ClusterGroup youngestNode = cluster.forYoungest();

👍

Once the cluster group is obtained, you can use it for executing tasks, deploying services, sending messages, and more.

Updated about a year ago

Leader Election


Automatically select oldest or youngest cluster nodes.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.