@ThreadSafe public class CosmosAdmin extends java.lang.Object implements DistributedStorageAdmin
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_NO_SCALING |
static java.lang.String |
DEFAULT_REQUEST_UNIT |
static java.lang.String |
METADATA_CONTAINER |
static java.lang.String |
NO_SCALING |
static java.lang.String |
REQUEST_UNIT |
static java.lang.String |
STORED_PROCEDURE_FILE_NAME |
Constructor and Description |
---|
CosmosAdmin(DatabaseConfig databaseConfig) |
Modifier and Type | Method and Description |
---|---|
void |
addNewColumnToTable(java.lang.String namespace,
java.lang.String table,
java.lang.String columnName,
DataType columnType)
Adds a new column to an existing table.
|
void |
addRawColumnToTable(java.lang.String namespace,
java.lang.String table,
java.lang.String columnName,
DataType columnType)
Add a column in the table without updating the metadata table in ScalarDB.
|
void |
close()
Closes connections to the storage.
|
void |
createIndex(java.lang.String namespace,
java.lang.String table,
java.lang.String columnName,
java.util.Map<java.lang.String,java.lang.String> options)
Creates a secondary index for the specified column of the specified table.
|
void |
createNamespace(java.lang.String namespace,
java.util.Map<java.lang.String,java.lang.String> options)
Creates a namespace.
|
void |
createTable(java.lang.String namespace,
java.lang.String table,
TableMetadata metadata,
java.util.Map<java.lang.String,java.lang.String> options)
Creates a new table.
|
void |
dropIndex(java.lang.String namespace,
java.lang.String table,
java.lang.String columnName)
Drops a secondary index for the specified column of the specified table.
|
void |
dropNamespace(java.lang.String namespace)
Drops the specified namespace.
|
void |
dropTable(java.lang.String namespace,
java.lang.String table)
Drops the specified table.
|
TableMetadata |
getImportTableMetadata(java.lang.String namespace,
java.lang.String table,
java.util.Map<java.lang.String,DataType> overrideColumnsType)
Get import table metadata in the ScalarDB format.
|
java.util.Set<java.lang.String> |
getNamespaceNames()
Returns the names of the existing namespaces.
|
java.util.Set<java.lang.String> |
getNamespaceTableNames(java.lang.String namespace)
Returns the names of the table belonging to the given namespace.
|
StorageInfo |
getStorageInfo(java.lang.String namespace)
Returns the storage information.
|
TableMetadata |
getTableMetadata(java.lang.String namespace,
java.lang.String table)
Retrieves the table metadata of the specified table.
|
void |
importTable(java.lang.String namespace,
java.lang.String table,
java.util.Map<java.lang.String,java.lang.String> options,
java.util.Map<java.lang.String,DataType> overrideColumnsType)
Imports an existing table that is not managed by ScalarDB.
|
boolean |
namespaceExists(java.lang.String namespace)
Returns true if the namespace exists.
|
void |
repairTable(java.lang.String namespace,
java.lang.String table,
TableMetadata metadata,
java.util.Map<java.lang.String,java.lang.String> options)
Repairs a table which may be in an unknown state.
|
void |
truncateTable(java.lang.String namespace,
java.lang.String table)
Truncates the specified table.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getImportTableMetadata
addNewColumnToTable, createIndex, createIndex, createIndex, createNamespace, createNamespace, createNamespace, createTable, createTable, createTable, dropIndex, dropNamespace, dropTable, importTable, indexExists, tableExists
public static final java.lang.String REQUEST_UNIT
public static final java.lang.String DEFAULT_REQUEST_UNIT
public static final java.lang.String NO_SCALING
public static final java.lang.String DEFAULT_NO_SCALING
public static final java.lang.String METADATA_CONTAINER
public static final java.lang.String STORED_PROCEDURE_FILE_NAME
@Inject public CosmosAdmin(DatabaseConfig databaseConfig)
public void createTable(java.lang.String namespace, java.lang.String table, TableMetadata metadata, java.util.Map<java.lang.String,java.lang.String> options) throws ExecutionException
Admin
createTable
in interface Admin
namespace
- a namespace already createdtable
- a table to createmetadata
- a metadata to createoptions
- options to createExecutionException
- if the operation failspublic void createNamespace(java.lang.String namespace, java.util.Map<java.lang.String,java.lang.String> options) throws ExecutionException
Admin
createNamespace
in interface Admin
namespace
- the namespace to createoptions
- namespace creation optionsExecutionException
- if the operation failspublic void dropTable(java.lang.String namespace, java.lang.String table) throws ExecutionException
Admin
dropTable
in interface Admin
namespace
- a namespace to droptable
- a table to dropExecutionException
- if the operation failspublic void dropNamespace(java.lang.String namespace) throws ExecutionException
Admin
dropNamespace
in interface Admin
namespace
- a namespace to dropExecutionException
- if the operation failspublic void truncateTable(java.lang.String namespace, java.lang.String table) throws ExecutionException
Admin
truncateTable
in interface Admin
namespace
- a namespace to truncatetable
- a table to truncateExecutionException
- if the operation failspublic void createIndex(java.lang.String namespace, java.lang.String table, java.lang.String columnName, java.util.Map<java.lang.String,java.lang.String> options) throws ExecutionException
Admin
createIndex
in interface Admin
namespace
- a namespace to create a secondary indextable
- a table to create a secondary indexcolumnName
- a name of the target columnoptions
- options to create a secondary indexExecutionException
- if the operation failspublic void dropIndex(java.lang.String namespace, java.lang.String table, java.lang.String columnName) throws ExecutionException
Admin
dropIndex
in interface Admin
namespace
- a namespace to drop a secondary indextable
- a table to drop a secondary indexcolumnName
- a name of the target columnExecutionException
- if the operation failspublic TableMetadata getTableMetadata(java.lang.String namespace, java.lang.String table) throws ExecutionException
Admin
getTableMetadata
in interface Admin
namespace
- a namespace to retrievetable
- a table to retrieveExecutionException
- if the operation failspublic void close()
DistributedStorageAdmin
close
in interface DistributedStorageAdmin
close
in interface java.lang.AutoCloseable
public boolean namespaceExists(java.lang.String namespace) throws ExecutionException
Admin
namespaceExists
in interface Admin
namespace
- a namespaceExecutionException
- if the operation failspublic void repairTable(java.lang.String namespace, java.lang.String table, TableMetadata metadata, java.util.Map<java.lang.String,java.lang.String> options) throws ExecutionException
Admin
repairTable
in interface Admin
namespace
- an existing namespacetable
- an existing tablemetadata
- the metadata associated to the table to repairoptions
- options to repairExecutionException
- if the operation failspublic java.util.Set<java.lang.String> getNamespaceTableNames(java.lang.String namespace) throws ExecutionException
Admin
getNamespaceTableNames
in interface Admin
namespace
- a namespaceExecutionException
- if the operation failspublic void addNewColumnToTable(java.lang.String namespace, java.lang.String table, java.lang.String columnName, DataType columnType) throws ExecutionException
Admin
addNewColumnToTable
in interface Admin
namespace
- the table namespacetable
- the table namecolumnName
- the name of the new columncolumnType
- the type of the new columnExecutionException
- if the operation failspublic TableMetadata getImportTableMetadata(java.lang.String namespace, java.lang.String table, java.util.Map<java.lang.String,DataType> overrideColumnsType)
DistributedStorageAdmin
getImportTableMetadata
in interface DistributedStorageAdmin
namespace
- namespace name of import tabletable
- import table nameoverrideColumnsType
- a map of column data type by column name. Only set the column for
which you want to override the default data type mapping.public void addRawColumnToTable(java.lang.String namespace, java.lang.String table, java.lang.String columnName, DataType columnType)
DistributedStorageAdmin
addRawColumnToTable
in interface DistributedStorageAdmin
namespace
- namespace name of import tabletable
- import table namecolumnName
- name of the column to be addedcolumnType
- type of the column to be addedpublic void importTable(java.lang.String namespace, java.lang.String table, java.util.Map<java.lang.String,java.lang.String> options, java.util.Map<java.lang.String,DataType> overrideColumnsType)
Admin
importTable
in interface Admin
namespace
- an existing namespacetable
- an existing tableoptions
- options to importoverrideColumnsType
- a map of column data type by column name. Only set the column for
which you want to override the default data type mapping.public java.util.Set<java.lang.String> getNamespaceNames() throws ExecutionException
Admin
getNamespaceNames
in interface Admin
ExecutionException
- if the operation failspublic StorageInfo getStorageInfo(java.lang.String namespace)
DistributedStorageAdmin
getStorageInfo
in interface DistributedStorageAdmin
namespace
- the namespace to get the storage information for