Skip to main content
Version: 3.12

Getting Started with the Administrative API in the ScalarDB Cluster .NET Client SDK

The ScalarDB Cluster .NET Client SDK supports the Administrative API of ScalarDB Cluster. By using this API, you can manage ScalarDB Cluster from .NET applications.

note

Although we recommend using asynchronous methods as in the following examples, you can use synchronous methods instead.

Get a transaction manager

First, you need to get an object for interacting with the Administrative API. To get the object, you can use TransactionFactory as follows, replacing <HOSTNAME_OR_IP_ADDRESS> with the FQDN or the IP address, and <PORT> with the port number (60053 by default) of your cluster:

var scalarDbOptions = new ScalarDbOptions
{
Address = "http://<HOSTNAME_OR_IP_ADDRESS>:<PORT>",
HopLimit = 10
};
var factory = TransactionFactory.Create(scalarDbOptions);

using var admin = factory.GetTransactionAdmin();

Manage ScalarDB Cluster

The following operations can be performed by using the ScalarDB Cluster .NET Client SDK.

Create a new namespace

await admin.CreateNamespaceAsync("ns", ifNotExists: true);

Drop a namespace

await admin.DropNamespaceAsync("ns", ifExists: true);

Check if a namespace exists

var namespaceExists = await admin.IsNamespacePresentAsync("ns");

Create a new table

using Scalar.Db.Cluster.Rpc.V1;
// ...
using ScalarDB.Net.Client.Builders;

// ...

var tableMetadata =
new TableMetadataBuilder()
.AddPartitionKey("pk", DataType.Int)
.AddClusteringKey("ck", DataType.Double)
.AddSecondaryIndex("index", DataType.Float)
.AddColumn("ordinary", DataType.Text)
.Build();

await admin.CreateTableAsync("ns", "table_name", tableMetadata, ifNotExists: true);

Drop a table

await admin.DropTableAsync("ns", "table_name", ifExists: true);

Checking if a table exists

var tableExists = await admin.IsTablePresentAsync("ns", "table_name");

Get the names of existing tables

var tablesList = await admin.GetTableNamesAsync("ns");

Create the Coordinator table

await admin.CreateCoordinatorTablesAsync();

Drop the Coordinator table

await admin.DropCoordinatorTablesAsync();

Check if the Coordinator table exist

var exists = await admin.AreCoordinatorTablesPresentAsync();