Getting Started
This page will help you get started with Apache Ignite C++. You'll be up and running in a jiffy!
This is a legacy Apache Ignite documentation
The new documentation is hosted here: https://ignite.apache.org/docs/latest/
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 a folder in your system.
Building From Source
You can build Apache Ignite C++ from either source or binary distribution. In the former case you will need to build Java portion first before building C++. Please refer to Apache Ignite Getting Started page: https://apacheignite.readme.io/docs/getting-started
Dependencies
On Linux, you will need certain development environment dependencies, listed below for several popular distributions and their package systems:
apt-get install libtool autoconf make g++ libssl1.0-dev
# If ODBC enabled (disable with --disable-core):
apt-get install unixodbc-dev
# If thick client enabled (disable with --disable-odbc):
apt-get install openjdk-11-jdk
zypper install libtool autoconf make gcc-c++ libopenssl-1_0_0-devel
# If ODBC enabled (disable it with --disable-core):
zypper install unixODBC-devel
# If thick client enabled (enable it with --enable-odbc):
zypper install java-11-openjdk-devel
yum install libtool autoconf make gcc-c++ compat-openssl10-devel
# If ODBC enabled (disable it with --disable-core):
yum install unixODBC-devel
# If thick client enabled (enable it with --enable-odbc):
yum install java-11-openjdk-devel
Also, to build tests you will need Boost (has been tested with 1.58 и 1.68 versions). On Windows you will need to properly set up the 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.
OpenSSL
Currently, Apache Ignite C++ will only build against OpenSSL 1.0 development headers. You can have both OpenSSL 1.0 and 1.1 libraries installed to your system at the same time, so this should not cause dependency conflicts.
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
# To build ODBC driver only, use:
./configure --enable-odbc --disable-node --disable-core
make
#The following step is optional if you want to install Ignite
#for your system. It would probably require root:
sudo make install
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
#
# Specify a target subdirectory in your user's home dir:
./configure --prefix=/home/user/ignite
# To build ODBC driver only, use:
./configure --prefix=/home/user/ignite \
--enable-odbc --disable-node --disable-core
make
#The following step is needed if you want to install Ignite
#under specified prefix directory.
make install
You need boost.test library if you want to build the 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
configurescript.
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= 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.GetOrCreateCache<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
Updated about 5 years ago
