17.5. バッチ操作の例
これらのバッチ操作の例を、Batch
CR で Data Grid リソースを作成および変更する際の開始点として使用します。
設定ファイルは、ConfigMap
を介してのみ、Data Grid Operator に渡すことができます。
ConfigMap
は、/etc/batch
の Data Grid Pod にマウントされるため、すべての --file=
ディレクティブの前にそのパスを追加する必要があります。
17.5.1. キャッシュ
- 設定ファイルから複数のキャッシュを作成します。
echo "creating caches..." create cache sessions --file=/etc/batch/infinispan-prod-sessions.xml create cache tokens --file=/etc/batch/infinispan-prod-tokens.xml create cache people --file=/etc/batch/infinispan-prod-people.xml create cache books --file=/etc/batch/infinispan-prod-books.xml create cache authors --file=/etc/batch/infinispan-prod-authors.xml echo "list caches in the cluster" ls caches
- ファイルからテンプレートを作成してから、テンプレートからキャッシュを作成します。
echo "creating caches..." create cache mytemplate --file=/etc/batch/mycache.xml create cache sessions --template=mytemplate create cache tokens --template=mytemplate echo "list caches in the cluster" ls caches
17.5.2. カウンター
Batch
CR を使用して、オブジェクトの数を記録するためにインクリメントおよびデクリメントできる複数のカウンターを作成します。
カウンターを使用して、識別子を生成したり、レートリミッターとして機能したり、リソースがアクセスされた回数を追跡したりできます。
echo "creating counters..." create counter --concurrency-level=1 --initial-value=5 --storage=PERSISTENT --type=weak mycounter1 create counter --initial-value=3 --storage=PERSISTENT --type=strong mycounter2 create counter --initial-value=13 --storage=PERSISTENT --type=strong --upper-bound=10 mycounter3 echo "list counters in the cluster" ls counters
17.5.3. Protobuf スキーマ
Protobuf スキーマを登録して、キャッシュ内の値をクエリーします。Protobuf スキーマ (.proto
files) は、カスタムエンティティーに関するメタデータを提供し、フィールドのインデックス作成を制御します。
echo "creating schema..." schema --upload=person.proto person.proto schema --upload=book.proto book.proto schema --upload=author.proto book.proto echo "list Protobuf schema" ls schemas
17.5.4. タスク
org.infinispan.tasks.ServerTask
を実装するタスク、または javax.script
スクリプト API と互換性のあるスクリプトをアップロードします。
echo "creating tasks..." task upload --file=/etc/batch/myfirstscript.js myfirstscript task upload --file=/etc/batch/mysecondscript.js mysecondscript task upload --file=/etc/batch/mythirdscript.js mythirdscript echo "list tasks" ls tasks
関連情報