The GridGain Distributed Data Structures

Use Data Structures from java.util.concurrent

The GridGain Distributed Data Structures feature allows most of the data structures from the 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. The GridGain Distributed Data Structure would also allow you to have a distributed Primary Key generator, which would guarantee uniqueness on all nodes.

Features:

  • Concurrent Map
  • Distributed Queues and Sets
  • AtomicLong
  • AtomicSequence
  • AtomicReference
  • CountDownLatch
  • ExecutorService
Examples:

Distributed Queue example.


Ignite ignite = Ignition.ignite();
 
CollectionConfiguration colCfg = new CollectionConfiguration();
 
colCfg.setCacheName("cacheName");
 
// Non-colocated queue which will be distributed
// across all data nodes.
IgniteQueue queue = ignite.queue("queueName", 20, colCfg);
 
// 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());

Distributed Set example.


Ignite ignite = Ignition.ignite();
 
// Initialize new set.
IgniteSet 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);

Distributed AtomicSequence example.


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());

Learn More