Apache Ignite

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

Getting Started

This page will help you get started with Apache Ignite. You'll be up and running in a jiffy!

Prerequisites

Apache Ignite was officially tested on:

Name
Value

JDK

Oracle JDK 7 and above
Open JDK 7 and above
IBM JDK 7 and above

OS

Linux (any flavor),
Mac OSX (10.6 and up)
Windows (XP and up),
Windows Server (2008 and up)
Oracle Solaris

ISA

x86, x64, SPARC, PowerPC

Network

No restrictions (10G recommended)

Installation

Here is the quick summary on installation of Apache Ignite:

  • Download Apache Ignite as ZIP archive from https://ignite.apache.org/
  • Unzip ZIP archive into the installation folder in your system
  • (Optional) Set the IGNITE_HOME environment variable to point to the installation folder and ensure there is no trailing / in the path

Building From Source

If you downloaded the source package, you can build the binary using the following commands:

# Unpack the source package
$ unzip -q apache-ignite-{version}-src.zip
$ cd apache-ignite-{version}-src
 
# Build In-Memory Data Fabric release (without LGPL dependencies)
$ mvn clean package -DskipTests
 
# Build In-Memory Data Fabric release (with LGPL dependencies)
$ mvn clean package -DskipTests -Prelease,lgpl
 
# Build In-Memory Hadoop Accelerator release
# (optionally specify version of hadoop to use)
$ mvn clean package -DskipTests -Dignite.edition=hadoop [-Dhadoop.version=X.X.X]

Start from the Command Line

An Ignite node can be started from the command line either with a default configuration or by using a configuration file. You can start as many nodes as you like and they will all automatically discover each other.

With Default Configuration

To start a grid node with a default configuration, open the command shell and, assuming you are in IGNITE_HOME (Ignite installation folder), type the following:

bin/ignite.sh
bin\ignite.bat

and you will see output similar to the following:

[08:22:05] Ignite node started OK (id=7c31bfa9)
[08:22:05] Topology snapshot [ver=1, servers=1, clients=0, CPUs=1, heap=1.0GB]

By default ignite.sh or ignite.bat starts an Ignite node with the default configuration config/default-config.xml or config\default-config.xml, respectively.

Passing a Configuration File

To pass a configuration file explicitly, from the command line, you can type ignite.sh or ignite.bat followed by the path to the configuration file from within your Ignite installation folder, as follows:

bin/ignite.sh examples/config/example-ignite.xml
bin\ignite.bat examples\config\example-ignite.xml

The path to the configuration file can be absolute or relative to either IGNITE_HOME (Ignite installation folder) or the META-INF folder in your classpath.

Interactive Mode

To pick a configuration file in interactive mode just pass the -i flag, as follows: ignite.sh -i.

Get It With Maven

Another easy way to get started with Apache Ignite in your project is to use Maven 2 dependency management.

Ignite requires only one ignite-core mandatory dependency. Usually you will also need to add ignite-spring for spring-based XML configuration and ignite-indexing for SQL querying.

Replace ${ignite-version} with actual Ignite version.

<dependency>
    <groupId>org.apache.ignite</groupId>
    <artifactId>ignite-core</artifactId>
    <version>${ignite.version}</version>
</dependency>
<dependency>
    <groupId>org.apache.ignite</groupId>
    <artifactId>ignite-spring</artifactId>
    <version>${ignite.version}</version>
</dependency>
<dependency>
    <groupId>org.apache.ignite</groupId>
    <artifactId>ignite-indexing</artifactId>
    <version>${ignite.version}</version>
</dependency>

Maven Setup

See Maven Setup for more information on how to include individual Ignite maven artifacts.

Use an IDE

From within an IDE, after the Ignite code examples have been loaded, it is possible to launch a node directly from within the IDE. This is achieved by running ExampleNodeStartup. This is highlighted below.

ExampleNodeStartup uses the configuration file examples/config/example-ignite.xml.

First Ignite Compute Application

Let's write our first grid application which will count a number of non-white-space characters in a sentence. As an example, we will take a sentence, split it into multiple words, and have every compute job count number of characters in each individual word. At the end we simply add up results received from individual jobs to get our total count.

try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
  Collection<IgniteCallable<Integer>> calls = new ArrayList<>();

  // Iterate through all the words in the sentence and create Callable jobs.
  for (final String word : "Count characters using callable".split(" "))
    calls.add(word::length);

  // Execute collection of Callables on the grid.
  Collection<Integer> res = ignite.compute().call(calls);

  // Add up all the results.
  int sum = res.stream().mapToInt(Integer::intValue).sum();
 
	System.out.println("Total number of characters is '" + sum + "'.");
}
try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
    Collection<IgniteCallable<Integer>> calls = new ArrayList<>();
 
    // Iterate through all the words in the sentence and create Callable jobs.
    for (final String word : "Count characters using callable".split(" ")) {
        calls.add(new IgniteCallable<Integer>() {
            @Override public Integer call() throws Exception {
                return word.length();
            }
        });
    }
 
    // Execute collection of Callables on the grid.
    Collection<Integer> res = ignite.compute().call(calls);
 
    int sum = 0;
 
    // Add up individual word lengths received from remote nodes.
    for (int len : res)
        sum += len;
 
    System.out.println(">>> Total number of characters in the phrase is '" + sum + "'.");
}

Zero Deployment

Note that because of Zero Deployment feature, when running the above application from your IDE, remote nodes will execute received jobs without explicit deployment.

First Ignite Data Grid Application

Now let's write a simple set of mini-examples which will put and get values to/from distributed cache, and perform basic transactions.

Since we are using cache in this example, we should make sure that it is configured. Let's use example configuration shipped with Ignite that already has several caches configured:

$ bin/ignite.sh examples/config/example-cache.xml
try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
    IgniteCache<Integer, String> cache = ignite.getOrCreateCache("myCacheName");
 
    // Store keys in cache (values will end up on different cache nodes).
    for (int i = 0; i < 10; i++)
        cache.put(i, Integer.toString(i));
 
    for (int i = 0; i < 10; i++)
        System.out.println("Got [key=" + i + ", val=" + cache.get(i) + ']');
}
// Put-if-absent which returns previous value.
Integer oldVal = cache.getAndPutIfAbsent("Hello", 11);
  
// Put-if-absent which returns boolean success flag.
boolean success = cache.putIfAbsent("World", 22);
  
// Replace-if-exists operation (opposite of getAndPutIfAbsent), returns previous value.
oldVal = cache.getAndReplace("Hello", 11);
 
// Replace-if-exists operation (opposite of putIfAbsent), returns boolean success flag.
success = cache.replace("World", 22);
  
// Replace-if-matches operation.
success = cache.replace("World", 2, 22);
  
// Remove-if-matches operation.
success = cache.remove("Hello", 1);
try (Transaction tx = ignite.transactions().txStart()) {
    Integer hello = cache.get("Hello");
  
    if (hello == 1)
        cache.put("Hello", 11);
  
    cache.put("World", 22);
  
    tx.commit();
}
// Lock cache key "Hello".
Lock lock = cache.lock("Hello");
 
lock.lock();
 
try {
    cache.put("Hello", 11);
    cache.put("World", 22);
}
finally {
    lock.unlock();
} 

Ignite Visor Admin Console

The easiest way to examine the content of the data grid as well as perform a long list of other management and monitoring operations is to use Ignite Visor Command Line Utility.

To start Visor simply run:

$ bin/ignitevisorcmd.sh

Getting Started

This page will help you get started with Apache Ignite. You'll be up and running in a jiffy!