ScalarDB Cluster Java API ガイド
このページは英語版のページが機械翻訳されたものです。英語版との間に矛盾または不一致がある場合は、英語版を正としてください。
ScalarDB Cluster Java API は、ScalarDB Core の一部である Administrative API と Transaction API に加えて、ScalarDB Cluster に固有の追加 API で構成されています。このガイドでは、どのような種類の API が存在するのか、それらの使用方法、例外の処理方法などの関連トピックについて説明します。
Administrative API
このセクションでは、ScalarDB の Administrative API を使用してプログラムで管理操作を実行する方法について説明します。
管理操作を実行する別の方法は、Schema Loader を使用することです。
DistributedTransactionAdmin インスタンスを取得する
管理操作を実行するには、まず DistributedTransactionAdmin インスタンスを取得する必要があります。
DistributedTransactionAdmin インスタンスを取得するには、次のように TransactionFactory を使用します。
TransactionFactory transactionFactory = TransactionFactory.create("<CONFIGURATION_FILE_PATH>");
DistributedTransactionAdmin admin = transactionFactory.getTransactionAdmin();
設定の詳細については、ScalarDB 設定を参照してください。
すべての管理操作を実行したら、次のように DistributedTransactionAdmin インスタンスを閉じる必要があります。
admin.close();
名前空間を作成する
テーブルは1つの名前空間に属するため、テーブルを作成する前に名前空間を作成する必要があります。
名前空間は次のように作成できます。
// Create the namespace "ns". If the namespace already exists, an exception will be thrown.
admin.createNamespace("ns");
// Create the namespace only if it does not already exist.
boolean ifNotExists = true;
admin.createNamespace("ns", ifNotExists);
// Create the namespace with options.
Map<String, String> options = ...;
admin.createNamespace("ns", options);
作成オプション
名前空間の作成操作では、オプション名と値のマップであるオプション (Map<String, String>) を指定できます。オプションを使用すると、ストレージアダプタ固有の設定ができます。
データベースを選択して、使用可能なオプションを確認します。
- JDBC データベース
- DynamoDB
- Cosmos DB for NoSQL
- Cassandra
- Object Storage
使用可能なオプションはありません。
使用可能なオプションはありません。
| 名前 | 説明 | デフォルト |
|---|---|---|
| ru | 基本リソース単位。 | 400 |
| no-scaling | Cosmos DB for NoSQL の自動スケーリングを無効にします。 | false |
| 名前 | 説明 | デフォルト |
|---|---|---|
| replication-strategy | Cassandra レプリケーション戦略。SimpleStrategy または NetworkTopologyStrategy である必要があります。 | SimpleStrategy |
| replication-factor | Cassandra の複製係数。 | 3 |
使用可能なオプションはありません。