For the complete documentation index, see llms.txt. This page is also available as Markdown.

Connecting to Your Cluster

Connecting to a GridGain 8 cluster from the Java, .NET, C++, Python, and Node.js thin clients, JDBC, ODBC, the Java thick client, and the REST API.

You can connect to your cluster by using the following clients:

Connection URI

All examples below contain the {connectionUri} value. You can get it from the template at the end of provisioning wizard, or

Java Thin Client

Java thin client is a lightweight client that connects to the cluster via a standard socket connection. It does not become a part of the cluster topology, never holds any data, and is not used as a destination for compute calculations. The thin client simply establishes a socket connection to a standard node​ and performs all operations through that node.

  1. Add the following dependencies to your Maven project:

    <repositories>
        <repository>
            <id>GridGain External Repository</id>
            <url>https://www.gridgainsystems.com/nexus/content/repositories/external</url>
        </repository>
    </repositories>
    
    <dependencies>
        <dependency>
            <groupId>org.gridgain</groupId>
            <artifactId>ignite-core</artifactId>
            <version>8.9.20</version>
        </dependency>
    </dependencies>
  2. Create a client configuration. Replace the USER_NAME placeholder with your cluster URL. Replace the USER_NAME and PASSWORD placeholders with your cluster credentials.

    ClientConfiguration cfg = new ClientConfiguration()
            .setAddresses("CONNECTION_URL")
            .setUserName("USER_NAME")
            .setUserPassword("PASSWORD")
            .setSslMode(SslMode.REQUIRED);
  3. Connect to the cluster.

    try (IgniteClient client = Ignition.startClient(cfg)) {
        // Use the API.
        ClientCache<Integer, String> cache =  client.getOrCreateCache(new ClientCacheConfiguration()
                .setName("Test")
                .setBackups(1)
        );
        cache.put(1, "foo");
        System.out.println(">>>    " + cache.get(1));
    }

For more information on thin clients, please see this article.

.NET Thin Client

Prerequisites:

  • Supported runtimes: .NET 4.0+, .NET Core 2.0+

  • Supported OS: Windows, Linux, macOS (any OS supported by .NET Core 2.0+)

  1. Install the GridGain package:

  2. Create client configuration: Replace the ${HIDDEN_LOGIN} and ${HIDDEN_PASSWORD} with your cluster credentials.

  3. Connect to the cluster.

For more information on .NET Thin Client, please see this article.

Python Thin Client

Please note the following client prerequisites: Python 3.4 or above.

Setting Up

You can install the Python thin client either using pip or from a zip archive.

Using PIP

The python thin client package is called pygridgain. You can install it using the following command:

Using ZIP Archive

The thin client can be installed from the zip archive available for download from the GridGain website:

  • Go to the website and download the GridGain Python Thin Client archive.

  • Unpack the archive and navigate to the root folder.

  • Install the client using the command below.

This will install pygridgain in your environment in the so-called "develop" or "editable" mode. Learn more about the mode from the official documentation.

After that, import the GridGain Python thin client:

Connecting to the Cluster

  1. Create client configuration: Replace the {login} and {password} with your cluster credentials.

  2. Connect to the cluster.

  3. Use the API.

For more information on Python Thin Client, please see this article.

C++ Thin Client

GridGain on-premise comes with a C++ thin client that you can use to work with GridGain clusters.

Setting Up

The source code of the C++ thin clien is available with the GridGain distribution package in the {GRIDGAIN_HOME}/platforms/cpp directory. To start working with it, install the client on your system:

Creating a Client Instance

For additional information on using C++ thin client, read the extended article in GridGain documentation.

Node.js Thin Client

Prerequisites: Node.js version 8 or higher.

  1. Install the GridGain package: npm install -g @gridgain/thin-client:

  2. Create client configuration: Replace the ${HIDDEN_LOGIN} and ${HIDDEN_PASSWORD} with your cluster credentials.

For more information on Node.js Thin Client, please see this article.

JDBC

GridGain is shipped with JDBC drivers that allow processing of distributed data using standard SQL statements like SELECT, INSERT, UPDATE or DELETE directly from the JDBC side.

  1. Open a JDBC connection: Replace the ${HIDDEN_LOGIN} and ${HIDDEN_PASSWORD} with your cluster credentials.

  2. Use the API:

For more information on JDBC driver, please see this article.

ODBC

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

Installation

GridGain comes with an ODBC driver. If you use Windows, you can install it immediately. On Linux you will need to build it first. You can find installation and build instructions in GridGain documentation.

Connecting to Cluster

To connect to cluster, use the following connection template. Below we will walk through the template step by step:

  • Make sure to include the required dependencies in your code:

  • We will be using the following code to handle possible issues:

  • Allocate environment and connection handles:

  • Specify that ODBC 3 will be used to connect to the cluster:

  • Connect to the server:

  • Allocate a statement handle:

  • Create a table in the cluster:

You can find more information on working with ODBC driver in GridGain Documentation.

Java Thick Client

Java thick client (client node) joins the cluster via an internal protocol, receives all of the cluster-wide updates such as topology changes, is aware of data distribution, and can direct a query/operation to a server node that owns a required data set. Plus, Java thick client supports all of the GridGain APIs.

  1. Add the following dependencies to your Maven project:

  2. Create client configuration: Replace the {login} and {password} with your cluster credentials.

  3. Connect to the cluster.

REST API

GridGain provides an HTTP REST client that gives you the ability to communicate with the grid over HTTP and HTTPS protocols using the REST approach.

Run the following to test your connection:

  1. Replace the {login} and {password} with your cluster credentials. The response will contain a sessionToken.

  2. Use the sessionToken in subsequent requests to avoid authenticating every time.

Last updated

Was this helpful?