Hot Rod C++ クライアントガイド

Red Hat Data Grid 8.3

Hot Rod C++ クライアントの設定および使用

Red Hat Customer Content Services

概要

Hot Rod .NET/C# クライアントを使用すると、C# ランタイムアプリケーションがリモートの Data Grid クラスターに接続し、対話できます。

Red Hat Data Grid

Data Grid は、高性能の分散型インメモリーデータストアです。

スキーマレスデータ構造
さまざまなオブジェクトをキーと値のペアとして格納する柔軟性があります。
グリッドベースのデータストレージ
クラスター間でデータを分散および複製するように設計されています。
エラスティックスケーリング
サービスを中断することなく、ノードの数を動的に調整して要件を満たします。
データの相互運用性
さまざまなエンドポイントからグリッド内のデータを保存、取得、およびクエリーします。

Data Grid のドキュメント

Data Grid のドキュメントは、Red Hat カスタマーポータルで入手できます。

Data Grid のダウンロード

Red Hat カスタマーポータルで Data Grid Software Downloads にアクセスします。

注記

Data Grid ソフトウェアにアクセスしてダウンロードするには、Red Hat アカウントが必要です。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。まずは、マスター (master)、スレーブ (slave)、ブラックリスト (blacklist)、ホワイトリスト (whitelist) の 4 つの用語の置き換えから始めます。この取り組みは膨大な作業を要するため、今後の複数のリリースで段階的に用語の置き換えを実施して参ります。詳細は、Red Hat CTO である Chris Wright のメッセージ をご覧ください。

第1章 Hot Rod C++ クライアントのインストール

ホストシステムに Hot Rod C++ クライアントを動的ライブラリーとしてインストールします。

1.1. C++ コンパイラー要件

オペレーティングシステム必須コンパイラー

Red Hat Enterprise Linux(RHEL)7、64 ビット

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 スキーマのコンパイル

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++ クライアントの設定

Hot 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.