Distributed Data Structures

Ignite allows for most of the data structures from java.util.concurrent framework to be used in a distributed fashion. For example, you can take java.util.concurrent.BlockingDeque and add something to it on one node and poll it from another node. Or have a distributed ID generator, which would guarantee uniqueness of IDs on all nodes.

Supported Data Structures:

Code Examples:
                            Ignite ignite = Ignition.ignite();

                            // Non-colocated queue which will be distributed
                            // across all data nodes.
                            IgniteQueue<String> queue = ignite.queue("queueName", 20, new CollectionConfiguration());

                            // Add queue elements.
                            for (int i = 0; i < 20; i++)
                                queue.add("Value " + Integer.toString(i));

                            // Poll queue elements.
                            for (int i = 0; i < 20; i++)
                                System.out.println("Polled value: " + queue.poll());

                        
                            Ignite ignite = Ignition.ignite();

                            // Initialize new set.
                            IgniteSet<String> set = ignite.set("setName", null);

                            // Add set elements.
                            for (int i = 0; i < 10; i++)
                                set.add(Integer.toString(i));

                            // Iterate over set.
                            for (String item : set)
                                System.out.println("Set item: " + item);
                        
                            Ignite ignite = Ignition.ignite();

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

                            for (int i = 0; i < 100; i++)
                                System.out.println("Next sequence value: " + seq.incrementAndGet());
                        
                            Ignite ignite = Ignition.ignite();

                            // Initialize atomic long.
                            IgniteAtomicLong atomicLong = ignite.atomicLong("myAtomicLong", 0, true);

                            for (int i = 0; i < 100; i++)
                                System.out.println("Incremented value: " + atomicLong.incrementAndGet());
                        
                            Ignite ignite = Ignition.ignite();

                            String val = "123";

                            // Initialize distributed atomic reference.
                            IgniteAtomicReference<String> ref = ignite.atomicReference(refName, val, true);

                            ref.compareAndSet(val, "456");
                        
                            Ignite ignite = Ignition.ignite();

                            // Initialize distributed count down latch.
                            final IgniteCountDownLatch latch = ignite.countDownLatch(latchName, 10, false, true);

                            IgniteCompute asyncCompute = ignite.compute().withAsync();

                            // Asynchronously execute closures on the cluster
                            // which will simply count down the latch on remote nodes.
                            for (int i = 0; i < 10; i++)
                                asyncCompute.run(() -> latch.countDown());

                            // Wait for all closures to complete.
                            latch.await();
                        
GitHub Examples:

Also see data structure examples available on GitHub.

Data Structure Features

Feature Description
Queue and Set

Ignite provides an implementation of a fast Distributed Blocking Queue and Distributed Set.

Collocated vs. Non-Collocated

Queues and Sets can be deployed in collocated or non-collocated mode. In collocated mode all the elements of a collection will reside on the same cluster node. This mode should be used for relatively small collections. In non-collocated mode, the elements of the collection will be equally distributed within the cluster allowing to keep very large collections in memory.

Bounded Queues

Bounded queues allow users to have queues with predefined maximum size which gives a better control over the overall cache capacity.

Atomic Types

Ignite supports distributed AtomicLong and AtomicReference.

CountDownLatch

Ignite CountDownLatch allows you to synchronize jobs on all Ignite nodes.

Reservation-based ID Generator

ID Generator is implemented with AtomicSequence. Whenever 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.

Semaphore

Ignite's distributed semaphore implementation and behavior is similar to java.util.concurrent.Semaphore.