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

Primary & Backup Copies

Overview

In PARTITIONED mode, the nodes to which the keys are assigned are called primary nodes for those keys. You can also optionally configure any number of backup nodes for cached data. If the number of backups is greater than 0, then Ignite will automatically assign backup nodes for each individual key. For example if the number of backups is 1, then every key cached in the data grid will have 2 copies, 1 primary and 1 backup.

By default, backups are turned off for better performance.

Configuring Backups

Backups can be configured by setting the backups property of CacheConfiguration, like so:

<bean class="org.apache.ignite.configuration.IgniteConfiguration">
  	...
    <property name="cacheConfiguration">
        <bean class="org.apache.ignite.configuration.CacheConfiguration">
            <!-- Set a cache name. -->
            <property name="name" value="cacheName"/>
            <!-- Set cache mode. -->
            <property name="cacheMode" value="PARTITIONED"/>
            <!-- Number of backup nodes. -->
            <property name="backups" value="1"/>
            ... 
        </bean>
    </property>
</bean>
CacheConfiguration cacheCfg = new CacheConfiguration();

cacheCfg.setName("cacheName");

cacheCfg.setCacheMode(CacheMode.PARTITIONED);

cacheCfg.setBackups(1);

IgniteConfiguration cfg = new IgniteConfiguration();

cfg.setCacheConfiguration(cacheCfg);

// Start Ignite node.
Ignition.start(cfg);

Synchronous and Asynchronous Backups

CacheWriteSynchronizationMode enum can be used to configure synchronous or asynchronous update of primary and backup copies. Write synchronization mode tells Ignite whether the client node should wait for responses from remote nodes, before completing a write or commit.

Write synchronization mode can be set in one of following 3 modes:

FULL_SYNC

Client node will wait for write or commit to complete on all participating remote nodes (primary and backup).

FULL_ASYNC

In this mode, client node does not wait for responses from participating nodes, in which case remote nodes may get their state updated slightly after any of the cache write methods complete or after Transaction.commit() method completes.

PRIMARY_SYNC

This is the default mode. Client node will wait for write or commit to complete on primary node, but will not wait for backups to be updated.

Cache Data Consistency

Note that regardless of write synchronization mode, cache data will always remain fully consistent across all participating nodes when using transactions.

Write synchronization mode may be configured by setting writeSynchronizationMode property of CacheConfiguration, like so:

<bean class="org.apache.ignite.configuration.IgniteConfiguration">
   ...
   <property name="cacheConfiguration">
      <bean class="org.apache.ignite.configuration.CacheConfiguration">
          <!-- Set a cache name. -->
          <property name="name" value="cacheName"/>
          <!-- Set write synchronization mode. -->
          <property name="writeSynchronizationMode" value="FULL_SYNC"/> 
          ... 
        </bean>
    </property>
</bean>
CacheConfiguration cacheCfg = new CacheConfiguration();

cacheCfg.setName("cacheName");

cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);

IgniteConfiguration cfg = new IgniteConfiguration();

cfg.setCacheConfiguration(cacheCfg);

// Start Ignite node.
Ignition.start(cfg);