com.scalar.db.api.DistributedStorageAdmin Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scalardb Show documentation
Show all versions of scalardb Show documentation
A universal transaction manager that achieves database-agnostic transactions and distributed transactions that span multiple databases
package com.scalar.db.api;
import com.scalar.db.exception.storage.ExecutionException;
import com.scalar.db.io.DataType;
/**
* An administrative interface for distributed storage implementations. The user can execute
* administrative operations with it like createNamespace/createTable/getTableMetadata.
*
* Usage Examples
*
* Here is a simple example to demonstrate how to use it. (Exception handling is omitted for
* readability.)
*
* {@code
* StorageFactory factory = StorageFactory.create(configFilePath);
* DistributedStorageAdmin admin = factory.getAdmin();
*
* // Create a namespace
* // Assumes that the namespace name is NAMESPACE
* admin.createNamespace(NAMESPACE);
*
* // Create a table
* // Assumes that the namespace name and the table name are NAMESPACE and TABLE respectively
* TableMetadata tableMetadata = TableMetadata.newBuilder()
* ...
* .build();
* admin.createTable(NAMESPACE, TABLE, tableMetadata);
*
* // Get a table metadata
* tableMetadata = admin.getTableMetadata(NAMESPACE, TABLE);
*
* // Truncate a table
* admin.truncateTable(NAMESPACE, TABLE);
*
* // Drop a table
* admin.dropTable(NAMESPACE, TABLE);
*
* // Drop a namespace
* admin.dropNamespace(NAMESPACE);
* }
*/
public interface DistributedStorageAdmin extends Admin {
/**
* Get import table metadata in the ScalarDB format.
*
* @param namespace namespace name of import table
* @param table import table name
* @throws IllegalArgumentException if the table does not exist
* @throws IllegalStateException if the table does not meet the requirement of ScalarDB table
* @throws ExecutionException if the operation fails
*/
TableMetadata getImportTableMetadata(String namespace, String table) throws ExecutionException;
/**
* Add a column in the table without updating the metadata table in ScalarDB.
*
* @param namespace namespace name of import table
* @param table import table name
* @throws IllegalArgumentException if the table does not exist
* @throws ExecutionException if the operation fails
*/
void addRawColumnToTable(String namespace, String table, String columnName, DataType columnType)
throws ExecutionException;
/** Closes connections to the storage. */
void close();
}