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

ODBC Driver

Overview

Ignite includes ODBC driver that allows you both select and modify data, stored in a distributed cache, using standard SQL queries and native ODBC API.

For detailed info on ODBC please refer to ODBC Programmer's Reference.

Apache Ignite ODBC driver implements version 3.0 of the ODBC API.

Cluster Configuration

ODBC driver is treated as a dynamic library on Windows and a shared object on Linux. An application does not load it directly. Instead, it uses a Driver Manager API that loads and unloads ODBC drivers whenever required.

Internally, Ignite ODBC driver uses TCP protocol to connect to an Ignite cluster. The connection works over an Ignite component called OdbcProcessor. By default, OdbcProcessor is not enabled and not started when an Ignite node is being launched​. To enable the processor, you need to set the OdbcConfiguration property in your IgniteConfiguration:

<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
  ...
  <!-- Enabling ODBC. -->
  <property name="odbcConfiguration">
    <bean class="org.apache.ignite.configuration.OdbcConfiguration"/>
  </property>
  ...
</bean>
IgniteConfiguration cfg = new IgniteConfiguration();
...
OdbcConfiguration odbcCfg = new OdbcConfiguration();
cfg.setOdbcConfiguration(odbcCfg);
...

After OdbcProcessor is configured, it will be started with default settings; some of which are listed below:

  • endpointAddress - Address to bind to, in the format - hostname[:port_from[..port_to]]. Default value is 0.0.0.0:10800..10810. If you specify host name but do not specify a port range then the default port range will be used.
  • maxOpenCursors - Maximum number of cursors that can be opened simultaneously. The default value is 128.
  • socketSendBufferSize - Size of the TCP socket send buffer. The default value is 0 which instructs to use a system default value.
  • socketReceiveBufferSize - Size of the TCP socket receive buffer. The default value is 0 which instructs to use a system default value.
  • threadPoolSize - Number of request-handling threads in the thread pool. The default value is IgniteConfiguration.DFLT_PUBLIC_THREAD_CNT.

It's always possible to change these parameters as shown in the example below:

<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
  ...
  <!-- Enabling ODBC. -->
  <property name="odbcConfiguration">
    <bean class="org.apache.ignite.configuration.OdbcConfiguration">
      <property name="endpointAddress" value="127.0.0.1:12345..12346"/>
      <property name="maxOpenCursors" value="512"/>
      <property name="socketSendBufferSize" value="65536"/>
      <property name="socketReceiveBufferSize" value="131072"/>
      <property name="threadPoolSize" value="4"/>
    </bean>
  </property>
  ...
</bean>
IgniteConfiguration cfg = new IgniteConfiguration();
...
OdbcConfiguration odbcCfg = new OdbcConfiguration();

odbcCfg.setEndpointAddress("127.0.0.1:12345..12346");
odbcCfg.setMaxOpenCursors(512);
odbcCfg.setSocketSendBufferSize(65536);
odbcCfg.setSocketReceiveBufferSize(131072);
odbcCfg.setThreadPoolSize(4);

cfg.setOdbcConfiguration(odbcCfg);
...

A connection that is established from the ODBC driver side to the cluster via OdbcProcessor is also configurable. Here you can find more details on how to alter connection settings from the driver side.

Thread-Safety

The current implementation of Ignite ODBC driver only provides thread-safety at the connections level. It means that you should not access the same connection from multiple threads without additional synchronization, though you can create separate connections for every thread and use them simultaneously.

Prerequisites

Apache Ignite ODBC Driver was officially tested on:

OS

Windows (XP and up, both 32-bit and 64-bit versions),
Windows Server (2008 and up, both 32-bit and 64-bit versions)
Ubuntu (14.x and 15.x 64-bit)

C++ compiler

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

Visual Studio

2010 and above

Building ODBC Driver

Ignite ODBC Driver is shipped with the source code as part of the Apache Ignite package and should be built before the usage. For instructions on how to download and set up Apache Ignite, please refer to Getting Started page.

Since the ODBC Driver is written in C++, it is shipped as part of the Apache Ignite C++ and depends on some of the C++ libraries. More specifically, it depends on utils and binary Ignite libraries. It means that you will need to build them prior to building the ODBC driver itself.

Building on Windows

You will need MS Visual Studio 2010 or later to be able to build the ODBC driver on Windows. Once you have it, open Ignite solution %IGNITE_HOME%\platforms\cpp\project\vs\ignite.sln (or ignite_86.sln if you are running 32-bit platform), left-click on odbc project in the "Solution Explorer" and choose "Build". Visual Studio will automatically detect and build all the necessary dependencies.

If you are using VS 2015 or later (MSVC 14.0 or later), you need to add legacy_stdio_definitions.lib as an additional library to odbc project linker's settings in order to be able to build the project. To add this library to the linker input in the IDE, open the context menu for the project node, choose Properties, then in the Project Properties dialog box, choose Linker, and edit the Linker Input to add legacy_stdio_definitions.lib to the semi-colon-separated list.

Once the build process is over, you can find ignite.odbc.dll in %IGNITE_HOME%\platforms\cpp\project\vs\x64\Release.

Building on Linux

On a Linux-based operating system, you will need to install an ODBC Driver Manager of your choice to be able to build and use the Ignite ODBC Driver. The Apache Ignite ODBC Driver has been tested with UnixODBC.

Additionally, you will need GCC, G++, and Make to build the driver and its dependencies.

Once all the above mentioned are installed, you can build the Ignite ODBC driver:

cd $IGNITE_HOME/platforms/cpp
libtoolize && aclocal && autoheader && automake --add-missing && autoreconf
./configure --enable-odbc --disable-node --disable-core
make

#The following step will most probably require root privileges:
make install

After the build process is over, you can find out where your ODBC driver has been placed by running the following command:

whereis libignite-odbc

The path should look like - /usr/local/lib/libignite-odbc.so

Installing ODBC driver

In order to use ODBC driver, you need to register it in your system so that your ODBC Driver Manager will be able to locate it.

Installing on Windows

For 32-bit Windows, you should use 32-bit version of the driver. For the
64-bit Windows, you can use 64-bit driver as well as 32-bit. You may want to install both 32-bit and 64-bit drivers on 64-bit Windows to be able to use your driver from both 32-bit and 64-bit applications.

To install driver on Windows, you should first choose a directory on your
file system where your driver or drivers will be located. Once you have
chosen the location, you have to put your driver there and ensure that all driver
dependencies can be resolved as well, i.e., they can be found either in the %PATH% or
in the same directory where the driver DLL resides.

After that, you have to use one of the install scripts from the following directory
%IGNITE_HOME%/platforms/cpp/odbc/install. Note, that you may need OS administrator privileges to execute these scripts.

install_x86 <absolute_path_to_32_bit_driver>
install_amd64 <absolute_path_to_64_bit_driver> [<absolute_path_to_32_bit_driver>]

Installing on Linux

To be able to build and install ODBC driver on Linux, you need to first install
ODBC Driver Manager. Apache Ignite ODBC driver has been tested with [UnixODBC]
(http://www.unixodbc.org).

Once you have built and performed "make install" command, the Ignite ODBC Driver i.e. libignite-odbc.so will be placed in the /usr/local/lib folder. To install it as an ODBC driver in your Driver Manager and be able to use it, you should perform the following steps:

  • Ensure linker is able to locate all dependencies of the ODBC driver. You can check this by using ldd command like so (assuming ODBC driver is located under /usr/local/lib):
    ldd /usr/local/lib/libignite-odbc.so
    If there are unresolved links to other libraries, you may want to add directories with these libraries to the LD_LIBRARY_PATH.

  • Edit file $IGNITE_HOME/platforms/cpp/odbc/install/ignite-odbc-install.ini and ensure that Driver parameter of the Apache Ignite section points to the right location where libignite-odbc.so is located.

  • To install Apache Ignite ODBC driver, use the following command:
    odbcinst -i -d -f $IGNITE_HOME/platforms/cpp/odbc/install/ignite-odbc-install.ini
    To perform this command, you may need root privileges.

Now the Apache Ignite ODBC driver is installed and ready for use. You can connect to it and use it just like any other ODBC driver.

ODBC Driver