Hot Rod C++ Client Guide
Configure and use Hot Rod C++ clients
Abstract
Red Hat Data Grid Copy linkLink copied to clipboard!
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 Copy linkLink copied to clipboard!
Documentation for Data Grid is available on the Red Hat customer portal.
Data Grid downloads Copy linkLink copied to clipboard!
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 Copy linkLink copied to clipboard!
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 Copy linkLink copied to clipboard!
Install the Hot Rod C++ client on your host system as a dynamic library.
1.1. C++ compiler requirements Copy linkLink copied to clipboard!
| 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) |
1.2. Installing Hot Rod C++ clients on Red Hat Enterprise Linux (RHEL) Copy linkLink copied to clipboard!
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.
Expand RHEL version Repository RHEL 7
jb-datagrid-8.1-for-rhel-7-server-rpmsRHEL 8
jb-datagrid-8.1-for-rhel-8-x86_64-rpmsInstall the Hot Rod C++ client.
yum install jdg-cpp-client
# yum install jdg-cpp-clientCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 2. Compiling Protobuf Schema Copy linkLink copied to clipboard!
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) Copy linkLink copied to clipboard!
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-develpackage.yum install protobuf yum install protobuf-devel
# yum install protobuf # yum install protobuf-develCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure
Set the
LD_LIBRARY_PATHenvironment variable, if it is not already set.export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/lib64
# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/lib64Copy to Clipboard Copied! Toggle word wrap Toggle overflow Compile Protobuf schema for the Hot Rod C++ client as required.
/bin/protoc --cpp_out dllexport_decl=HR_PROTO_EXPORT:/path/to/output/ $FILE
# /bin/protoc --cpp_out dllexport_decl=HR_PROTO_EXPORT:/path/to/output/ $FILECopy to Clipboard Copied! Toggle word wrap Toggle overflow HR_PROTO_EXPORTis 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.
Chapter 3. Configuring the Hot Rod C++ client Copy linkLink copied to clipboard!
Hot Rod C++ clients interact with remote Data Grid clusters via the RemoteCache API.
3.1. Configuration and Remote Cache Manager APIs Copy linkLink copied to clipboard!
Use the ConfigurationBuilder API to configure Hot Rod C++ client connections and the RemoteCacheManager API to obtain and configure remote caches.
Configuration builder
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);
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);
ConfigurationBuilder builder;
builder.addServer().host("127.0.0.1").port(11222);
// Enable near-caching for the client.
builder.nearCache().mode(NearCacheMode::INVALIDATED).maxEntries(4);