Ignite Quick Start Guide for C++
This chapter explains system requirements for running Ignite and how to install Ignite, start a cluster, and run a simple Hello World example in C++.
Prerequisites
Ignite C++ was officially tested on:
JDK |
Oracle JDK 8, 11 or 17, Open JDK 8, 11 or 17, IBM JDK 8, 11 or 17 |
OS |
Windows Vista, Windows Server 2008 and later versions, Ubuntu (18.04 64 bit) |
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 |
Installing Ignite
To get started with the Apache Ignite binary distribution:
-
Download the Ignite binary as a zip archive.
-
Unzip the zip archive into the installation folder in your system.
-
(Optional) Enable required modules.
-
(Optional) Set the
IGNITE_HOME
environment variable or Windows PATH to point to the installation folder and make sure there is no trailing/
(or\
for Windows) in the path.
Starting an Ignite Node
You can start a node from the command line using the default configuration or by passing a custom configuration file. You can start as many nodes as you like and they will all automatically discover each other.
Navigate into the bin
folder of the Ignite installation directory from the command shell.
Your command might look like this:
cd {IGNITE_HOME}/bin/
cd {IGNITE_HOME}\bin\
Start a node with a custom configuration file that is passed as a parameter to ignite.sh|bat
like this:
./ignite.sh ../examples/config/example-ignite.xml
ignite.bat ..\examples\config\example-ignite.xml
You will see output similar to this:
[08:53:45] Ignite node started OK (id=7b30bc8e) [08:53:45] Topology snapshot [ver=1, locNode=7b30bc8e, servers=1, clients=0, state=ACTIVE, CPUs=4, offheap=1.6GB, heap=2.0GB]
Open another tab from your command shell and run the same command again:
./ignite.sh ../examples/config/example-ignite.xml
ignite.bat ..\examples\config\example-ignite.xml
Check the Topology snapshot
line in the output.
Now you have a cluster of two server nodes with more CPUs and RAM available cluster-wide:
[08:54:34] Ignite node started OK (id=3a30b7a4) [08:54:34] Topology snapshot [ver=2, locNode=3a30b7a4, servers=2, clients=0, state=ACTIVE, CPUs=4, offheap=3.2GB, heap=4.0GB]
Note
|
By default, ignite.sh|bat starts a node with the default configuration file: config/default-config.xml .
|
Note
|
Ignite for C++ supports a thick client and a thin client. Because this guide focuses on the thin client, you can run the examples below, connecting to the Java-based nodes you just started. |
Once the cluster is started, you can use the Ignite C++ thin client to perform cache operations (things like getting or putting data, or using SQL).
Getting Started with Ignite and C++
Ignite ships with a robust C++ client. To get started with Ignite and C++, you will need to be familiar with building C++ applications.
-
If you haven’t already, download/install Apache Ignite.
-
Install
CMake 3.6+
and add it to the%Path%
. -
Install
OpenSSL
. -
Set
%JAVA_HOME%
environment variable. -
Navigate to the
%IGNITE_HOME%\platforms\cpp\
folder. -
Create build directory
%IGNITE_HOME%\platforms\cpp\cmake-build-release
. -
Build and install
Ignite C++
.
cd cmake-build-release
cmake .. -DWITH_THIN_CLIENT=ON -DCMAKE_GENERATOR_PLATFORM=Win32 -DOPENSSL_ROOT_DIR=<openssl install dir> -DCMAKE_INSTALL_PREFIX=<ignite cpp install dir>
cmake --build . --target install --config Release
cd cmake-build-release
cmake .. -DWITH_THIN_CLIENT=ON -DCMAKE_GENERATOR_PLATFORM=x64 -DOPENSSL_ROOT_DIR=<openssl install dir> -DCMAKE_INSTALL_PREFIX=<ignite cpp install dir>
cmake --build . --target install --config Release
CMake
by default generates on Windows Visual Studio projects. You can find generated projects in CMake
build directory and open Ignite.C++.sln
in Visual Studio.
From here, you can create your own code, or run one of the existing examples located in the {IGNITE_HOME}/platforms/cpp/examples/
directory.
There is much more information about how to build, test, and use Apache Ignite for C++ in the README.txt
and
DEVNOTES.txt
files located in the {IGNITE_HOME}/platforms/cpp
folder.
For information about the C++ thin client, see C++ Thin Client.
C++ for Unix
On unix systems, you can use the command line to build and run the examples included in the Ignite distribution.
Prerequisites
The following packages need to be installed:
-
C++ compiler
-
cmake 3.6+
-
jdk
-
openssl, including header files
-
unixODBC
Installation instructions for several popular distributions are listed below:
sudo apt-get install -y build-essential cmake openjdk-11-jdk unixodbc-dev libssl-dev
sudo yum install -y epel-release
sudo yum install -y java-11-openjdk-devel cmake3 unixODBC-devel openssl-devel make gcc-c++
sudo yum install -y java-11-openjdk-devel cmake3 unixODBC-devel openssl-devel make gcc-c++
Building C++ Ignite
-
Download and unzip the Ignite binary release. We’ll refer to a resulting directory as to
${IGNITE_HOME}
. -
Create a build directory for CMake. We’ll refer to this as
${CPP_BUILD_DIR}
-
Build and install Ignite.C++ by executing the following commands:
cd ${CPP_BUILD_DIR}
cmake -DCMAKE_BUILD_TYPE=Release -DWITH_THIN_CLIENT=ON ${IGNITE_HOME}/platforms/cpp
make
sudo make install
cd ${CPP_BUILD_DIR}
cmake3 -DCMAKE_BUILD_TYPE=Release -DWITH_THIN_CLIENT=ON ${IGNITE_HOME}/platforms/cpp
make
sudo make install
Building and running the Thick Client Example
-
Create a build directory for cmake. We’ll refer to it as
${CPP_EXAMPLES_BUILD_DIR}
-
Build the examples by executing the following commands:
cd ${CPP_EXAMPLES_BUILD_DIR}
cmake -DCMAKE_BUILD_TYPE=Release ${IGNITE_HOME}/platforms/cpp/examples && make
cd ./put-get-example
./ignite-put-get-example
cd ${CPP_EXAMPLES_BUILD_DIR}
cmake3 -DCMAKE_BUILD_TYPE=Release ${IGNITE_HOME}/platforms/cpp/examples && make
cd ./put-get-example
./ignite-put-get-example
Next Steps
From here, you may want to:
-
Check out the C++ thin client that provides a lightweight form of connectivity to Ignite clusters
-
Explore the additional C++ examples included with Ignite
-
Refer to the C++ specific section of the documentation to learn more about capabilities that are available for C++ applications
Apache, Apache Ignite, the Apache feather and the Apache Ignite logo are either registered trademarks or trademarks of The Apache Software Foundation.