Hot Rod C++ Client Guide
Configure and use Hot Rod C++ clients
Abstract
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.
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.
Providing feedback on Red Hat documentation
We appreciate your feedback on our technical content and encourage you to tell us what you think. If you’d like to add comments, provide insights, correct a typo, or even ask a question, you can do so directly in the documentation.
You must have a Red Hat account and be logged in to the customer portal.
To submit documentation feedback from the customer portal, do the following:
- Select the Multi-page HTML format.
- Click the Feedback button at the top-right of the document.
- Highlight the section of text where you want to provide feedback.
- Click the Add Feedback dialog next to your highlighted text.
- Enter your feedback in the text box on the right of the page and then click Submit.
We automatically create a tracking issue each time you submit feedback. Open the link that is displayed after you click Submit and start watching the issue or add more comments.
Thank you for the valuable feedback.
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 system | Required compiler |
---|---|
Red Hat Enterprise Linux (RHEL) 7, 64-bit | C++ 11 compiler (GCC 4.8.1) |
RHEL 8, 64-bit | C++ 11 compiler (GCC 4.8.1) |
Microsoft Windows 7 x64 | C 11 compiler (Visual Studio 2015, 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
Enable the repository for the Hot Rod C++ client on RHEL.
RHEL version Repository RHEL 7
jb-datagrid-8.1-for-rhel-7-server-rpms
RHEL 8
jb-datagrid-8.1-for-rhel-8-x86_64-rpms
Install the Hot Rod C++ client.
# yum install jdg-cpp-client
Additional resources
- Enabling or disabling a repository using Red Hat Subscription Management (Red Hat Knowledgebase)
- Red Hat Package Browser
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
- Download the ZIP archive for the Hot Rod C++ client from the Data Grid Software Downloads.
- 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
Set the
LD_LIBRARY_PATH
environment variable, if it is not already set.# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/lib64
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.- 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
- Open a command prompt to the installation directory for the Hot Rod C++ client.
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.- 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