热 Rod C++ 客户端指南


Red Hat Data Grid 8.2

配置和使用 Hot Rod C++ 客户端

Red Hat Customer Content Services

摘要

热 Rod C++ 客户端允许 C++ 运行时应用程序与远程 Data Grid 集群连接和交互。

Red Hat Data Grid

Data Grid 是一个高性能分布式内存数据存储。

无架构数据结构
将不同对象存储为键值对的灵活性。
基于网格的数据存储
旨在在集群中分发和复制数据。
弹性扩展
动态调整节点数量,以便在不中断服务的情况下满足需求。
数据互操作性
从不同端点在网格中存储、检索和查询数据。

Data Grid 文档

红帽客户门户网站中提供了 Data Grid 的文档。

Data Grid 下载

访问红帽客户门户上的 Data Grid 软件下载

注意

您必须有一个红帽帐户才能访问和下载数据中心软件。

使开源包含更多

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。我们从这四个术语开始:master、slave、黑名单和白名单。由于此项工作十分艰巨,这些更改将在即将推出的几个发行版本中逐步实施。有关更多详情,请参阅我们的首席技术官 Chris Wright 提供的消息

第 1 章 安装 Hot Rod C++ 客户端

在您的主机系统上作为动态库安装 Hot Rod C++ 客户端。

1.1. C++ 编译器要求

操作系统所需的编译器

Red Hat Enterprise Linux (RHEL) 7, 64-bit

C++ 11 编译器(GCC 4.8.1)

RHEL 8、64 位

C++ 11 编译器(GCC 4.8.1)

1.2. 在 Red Hat Enterprise Linux (RHEL)上安装 Hot Rod C++ 客户端

Data Grid 为 RHEL 提供 Hot Rod C++ 客户端的 RPM 分发。

流程

  1. 在 RHEL 上为 Hot Rod C++ 客户端启用存储库。

    RHEL 版本软件仓库

    RHEL 7

    jb-datagrid-8.1-for-rhel-7-server-rpms

    RHEL 8

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

  2. 安装 Hot Rod C++ 客户端。

    # yum install jdg-cpp-client

第 2 章 编译 Protobuf Schema

Data Grid 使用 ProtoStream API 将数据存储为 Protobuf 编码的条目。

protobuf 是一种语言中立的格式,允许客户端使用 Hot Rod 和 REST 端点在远程缓存中创建和检索条目。

2.1. 在 Red Hat Enterprise Linux (RHEL)上编译 Protobuf 模式

将 Protobuf 模式 .proto 文件编译到 C++ 标头和源文件,以描述您的数据到 Data Grid。

先决条件

  • 安装 Protobuf 库和 protobuf-devel 软件包。

    # yum install protobuf
    # yum install protobuf-devel

流程

  1. 设置 LD_LIBRARY_PATH 环境变量(如果尚未设置)。

    # export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/lib64
  2. 根据需要为 Hot Rod C++ 客户端编译 Protobuf 模式。

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

    HR_PROTO_EXPORT 是一个宏,在编译 Protobuf 模式时,Hot Rod C++ 客户端会展开。

  3. 如果您计划使用查询,请将您的 Protobuf 模式注册到 Data Grid。

第 3 章 配置 Hot Rod C++ 客户端

热 Rod C++ 客户端通过 RemoteCache API 与远程 Data Grid 集群交互。

3.1. 配置和远程缓存管理器 API

使用 ConfigurationBuilder API 配置 Hot Rod C++ 客户端连接和 RemoteCacheManager API,以获取和配置远程缓存。

配置构建器

#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();
    ...
}

跨站点复制

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);
  // Enable near-caching for the client.
  builder.nearCache().mode(NearCacheMode::INVALIDATED).maxEntries(4);

法律通告

Copyright © 2023 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.
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.