Apache Ignite C++ Documentation

The apacheignite-cpp Developer Hub

Welcome to the apacheignite-cpp developer hub. You'll find comprehensive guides and documentation to help you start working with apacheignite-cpp as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Getting Started

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

Prerequisites

Apache Ignite C++ was officially tested on:

Name
Value

JDK

Oracle JDK 8 and later
Open JDK 8 and later
IBM JDK 8 and later

OS

Windows (Vista and up),
Windows Server (2008 and up)
Ubuntu (14.x and 15.x)

Network

No restrictions (10G recommended)

Hardware

No restrictions

C++ compiler

MS Visual C++ (10.0 and up), g++ (4.4.0 and up)

Visual Studio

2010 and above

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

Building From Source

Apache Ignite С++ is based on Apache Ignite, and requires building Java sources first. Please refer to Apache Ignite Getting Started page: https://apacheignite.readme.io/docs/getting-started

Also, to build tests you will need Boost. In Windows you will need additionally properly set up BOOST_HOME environment variable. If you don't need tests, you can either exclude tests projects or don't build them at all. On Linux you can do that with configure script. Call ./configure --help for details.

You can build С++ binaries using the following commands:

cd modules\platforms\cpp\project\vs

msbuild ignite.sln /p:Configuration=Release /p:Platform=x64
cd modules/platforms/cpp
libtoolize && aclocal && autoheader && automake --add-missing && autoreconf

# You can call the following command to see all the available
# configuration options:
# ./configure --help
# To use default configuration just type:
./configure
make

#The following step is optional if you want to install Ignite
#for your system. It would probably require root:
sudo make install

You are going to need boost.test library if you will try to build entire project

If you are not going to run tests do not build entire project. Instead you can only build projects that you need. On Windows you can do that by clicking on the project of interest in the Solution Explorer and choosing "Build". On Linux you can enable/disable building of different components with configure script.

Start From Command Line

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

Platforms Interoperability Getting Started

If you are trying to deploy a cluster of both Java and C++ nodes make sure to look over Platform Interoperability getting started in order to do extra settings related to heterogeneous clusters.

With Default Configuration

To start a grid node with default configuration, open the command shell and, assuming you are in IGNITE_HOME (Ignite installation folder), and have built the binaries using the command above, just type this:

modules\platforms\cpp\project\vs\x64\Release\ignite.exe
./modules/platforms/cpp/ignite/ignite

and you will see the output similar to this:

[16:47:37] Ignite node started OK (id=ee97150d)
[16:47:37] Topology snapshot [ver=1, servers=1, clients=0, CPUs=2, heap=0.89GB]

By default ignite.exe starts Ignite C++ node with the default configuration: config/default-config.xml.

Passing Configuration File

To pass configuration file explicitly, from command line, you can type ignite.exe -springConfigUrl=<path to configuration file> from within your Ignite installation folder. For example:

modules\platforms\cpp\project\vs\x64\Release\ignite.exe -springConfigUrl=c:\work\my-config.xml
./modules/platforms/cpp/ignite/ignite -springConfigUrl=~/work/my-config.xml

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.

using namespace ignite;
using namespace cache;

IgniteConfiguration cfg;

// Start a node.
Ignite grid = Ignition::Start(cfg);

// Get cache instance.
Cache<int, std::string> cache = grid.GetCache<int, std::string>("myCache");

// Store keys in cache (values will end up on different cache nodes).
for (int i = 0; i < 10; ++i)
{
    std::stringstream value;
    value << i;

    cache.Put(i, value.str());
}

for (int i = 0; i < 10; ++i)
  	std::cout << "Got [key=" << i << ", val=" << cache.Get(i) << "]";
// Put-if-absent which returns previous value.
std::string oldVal = cache.GetAndPutIfAbsent(11, "Hello");

// Put-if-absent which returns boolean success flag.
bool success = cache.PutIfAbsent(22, "World");

// Replace-if-exists operation (opposite of getAndPutIfAbsent), returns previous value.
oldVal = cache.GetAndReplace(11, "Hello");

// Replace-if-exists operation (opposite of putIfAbsent), returns boolean success flag.
success = cache.Replace(22, "World");

// Replace-if-matches operation.
success = cache.Replace(22, "World", "World!");

// Remove-if-matches operation.
success = cache.Remove(1, "Hello");

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.bat