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

Asynchronous Support

Overview

A majority of Apache Ignite APIs can be used in both synchronous or asynchronous fashion. The asynchronous methods' names have an Async suffix.

// Synchronous get
V get(K key);

// Asynchronous get
IgniteFuture<V> getAsync(K key);

The asynchronous operations return an instance of IgniteFuture or one of its subclasses. You can wait for the result of an asynchronous operation by either calling a blocking IgniteFuture.get() method or registering a closure using the IgniteFuture.listen() or IgniteFuture.chain() method and wait while the closure gets called upon the operation completion.

Supported Interfaces

The interfaces listed below can be used in synchronous or asynchronous modes:

  • IgniteCompute
  • IgniteCache
  • Transaction
  • IgniteServices
  • IgniteMessaging
  • IgniteEvents

Listeners and Chaining Futures

To wait for the result of an asynchronous operation in a non-blocking fashion (IgniteFuture.get()), register a closure using the IgniteFuture.listen() or IgniteFuture.chain() method. Once the operation gets completed, the closure will be called. For example:

IgniteCompute compute = ignite.compute();

// Execute a closure asynchronously.
IgniteFuture<String> fut = compute.callAsync(() -> {
    return "Hello World";
});

// Listen for completion and print out the result.
fut.listen(f -> System.out.println("Job result: " + f.get()));

Closures Execution and Thread Pools

If an asynchronous operation has been completed by the time the closure is passed to either the IgniteFuture.listen() or IgniteFuture.chain() method, then the closure will be executed synchronously by the calling thread. Otherwise, the closure will be executed asynchronously upon the operation completion.

Depending on the type of operation, the closure might be called by a thread from the system pool (asynchronous cache operations) or by a thread from the public pool (asynchronous Ignite Compute operations). Therefore, you should avoid calling synchronous cache and compute operations from the closure implementation. Otherwise, it may lead to a deadlock due to pools starvation.

To achieve nested execution of asynchronous Ignite Compute operations, you can take advantage of custom thread pools.

Asynchronous Support


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.