Hot Rod C++ Client Guide

Red Hat Data Grid 8.4

Configure and use Hot Rod C++ clients

Red Hat Customer Content Services

Abstract

Hot Rod C++ clients allow C++ runtime applications to connect and interact with remote Data Grid clusters.

Red Hat Data Grid

Data Grid is a high-performance, distributed in-memory data store.

Schemaless data structure
Flexibility to store different objects as key-value pairs.
Grid-based data storage
Designed to distribute and replicate data across clusters.
Elastic scaling
Dynamically adjust the number of nodes to meet demand without service disruption.
Data interoperability
Store, retrieve, and query data in the grid from different endpoints.

Data Grid documentation

Documentation for Data Grid is available on the Red Hat customer portal.

Data Grid downloads

Access the Data Grid Software Downloads on the Red Hat customer portal.

Note

You must have a Red Hat account to access and download Data Grid software.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. We are beginning with these four terms: master, slave, blacklist, and whitelist. Because of the enormity of this endeavor, these changes will be implemented gradually over several upcoming releases. For more details, see our CTO Chris Wright’s message.

Chapter 1. Installing the Hot Rod C++ client

Install the Hot Rod C++ client on your host system as a dynamic library.

1.1. C++ compiler requirements

Operating systemRequired compiler

Red Hat Enterprise Linux (RHEL) 8

C++ 11 compiler (GCC 8.5.0)

RHEL 9

C++ 11 compiler (GCC 11.3.1)

Microsoft Windows 7 x64

C++ 11 compiler (Visual Studio 14 2015 Win64, Microsoft Visual C++ 2013 Redistributable Package for the x64 platform)

1.2. Installing Hot Rod C++ clients on Red Hat Enterprise Linux (RHEL)

Data Grid provides an RPM distribution of the Hot Rod C++ client for RHEL.

Procedure

  1. Enable the repository for the Hot Rod C++ client on RHEL.

    RHEL versionRepository

    RHEL 8

    jb-datagrid-8.4-for-rhel-8-x86_64-rpms

    RHEL 9

    jb-datagrid-8.4-for-rhel-9-x86_64-rpms

  2. Install the Hot Rod C++ client.

    # yum install jdg-cpp-client

1.3. Installing Hot Rod C++ clients on Microsoft Windows

Data Grid provides an archived version of the Hot Rod C++ client for installation on Windows.

Procedure

  1. Download the ZIP archive for the Hot Rod C++ client from the Data Grid Software Downloads.
  2. Extract the ZIP archive to your file system.

Chapter 2. Compiling Protobuf Schema

Data Grid uses the ProtoStream API to store data as Protobuf-encoded entries.

Protobuf is a language-neutral format that allows clients to create and retrieve entries in remote caches using both Hot Rod and REST endpoints.

2.1. Compiling Protobuf schema on Red Hat Enterprise Linux (RHEL)

Compile Protobuf schema, .proto files, into C++ header and source files to describe your data to Data Grid.

Prerequisites

  • Install the Protobuf library and protobuf-devel package.

    # yum install protobuf
    # yum install protobuf-devel

Procedure

  1. Set the LD_LIBRARY_PATH environment variable, if it is not already set.

    # export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/lib64
  2. Compile Protobuf schema for the Hot Rod C++ client as required.

    # /bin/protoc --cpp_out dllexport_decl=HR_PROTO_EXPORT:/path/to/output/ $FILE

    HR_PROTO_EXPORT is a macro that the Hot Rod C++ client expands when it compiles the Protobuf schema.

  3. Register your Protobuf schema with Data Grid if you plan to use queries.

Additional resources

2.2. Compiling Protobuf schema on Microsoft Windows

Compile Protobuf schema, .proto files, into C++ header and source files to describe your data to Data Grid.

Procedure

  1. Open a command prompt to the installation directory for the Hot Rod C++ client.
  2. Compile Protobuf schema for the Hot Rod C++ client as required.

    bin\protoc --cpp_out dllexport_decl=HR_PROTO_EXPORT:path\to\output\ $FILE

    HR_PROTO_EXPORT is a macro that the Hot Rod C++ client expands when it compiles the Protobuf schema.

  3. Register your Protobuf schema with Data Grid if you plan to use queries.

Additional resources

Chapter 3. Configuring the Hot Rod C++ client

Hot Rod C++ clients interact with remote Data Grid clusters via the RemoteCache API.

3.1. Configuration and Remote Cache Manager APIs

Use the ConfigurationBuilder API to configure Hot Rod C++ client connections and the RemoteCacheManager API to obtain and configure remote caches.

Configuration builder

#include "infinispan/hotrod/ConfigurationBuilder.h"
#include "infinispan/hotrod/RemoteCacheManager.h"
#include <infinispan/hotrod/RemoteCache.h>
#include <iostream>
int main () {
  ConfigurationBuilder builder;
    // Configure a cache manager to connect with Hot Rod version 2.8
    builder.protocolVersion(Configuration::PROTOCOL_VERSION_28);
    // Connect to a server at localhost with the default port.
    builder.addServer().host("127.0.0.1").port(11222);
    // Create and start a RemoteCacheManager to interact with caches.
    RemoteCacheManager cacheManager(builder.build(), false);
    cacheManager.start();
    ...
}

Cross-site replication

ConfigurationBuilder builder;
  builder.addServer().host("127.0.0.1").port(11222);
  // Configure a remote cluster and node when using cross-site replication.
  builder.addCluster("NYC").addClusterNode("192.0.2.0", 11322);

Near caching

ConfigurationBuilder builder;
  builder.addServer().host("127.0.0.1").port(11222);
  // Enable near-caching for the client.
  builder.nearCache().mode(NearCacheMode::INVALIDATED).maxEntries(4);

Additional resources

Legal Notice

Copyright © 2024 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.