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

ID Generator

Sequentially generate unique Ids across the cluster.

Overview

Distributed atomic sequence provided by IgniteCacheAtomicSequence interface is similar to distributed atomic long, but its value can only go up. It also supports reserving a range of values to avoid costly network trips or cache updates every time a sequence must provide a next value. That is, when you perform incrementAndGet() (or any other atomic operation) on an atomic sequence, the data structure reserves ahead a range of values, which are guaranteed to be unique across the cluster for this sequence instance.

Here is an example of how atomic sequence can be created:

Ignite ignite = Ignition.ignite();
 
IgniteAtomicSequence seq = ignite.atomicSequence(
    "seqName", // Sequence name.
    0,       // Initial value for sequence.
    true     // Create if it does not exist.
);

Below is a simple usage example:

Ignite ignite = Ignition.ignite();

// Initialize atomic sequence.
final IgniteAtomicSequence seq = ignite.atomicSequence("seqName", 0, true);

// Increment atomic sequence.
for (int i = 0; i < 20; i++) {
  long currentValue = seq.get();
  long newValue = seq.incrementAndGet();
  
  ...
}

Sequence Reserve Size

The key parameter of IgniteAtomicSequence is atomicSequenceReserveSize which is the number of sequence values reserved, per node . When a node tries to obtain an instance of IgniteAtomicSequence, a number of sequence values will be reserved for that node and consequent increments of sequence will happen locally without communication with other nodes, until the next reservation has to be made.

The default value for atomicSequenceReserveSize is 1000. This default setting can be changed by modifying the atomicSequenceReserveSize property of AtomicConfiguration.

Refer to Atomic Configuration for more information on various atomic configuration properties, and examples on how to configure them.