public final class Schema extends java.lang.Object implements SchemaProvider
| Modifier and Type | Class and Description |
|---|---|
static class |
Schema.TransformationResult |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clear all KS/CF metadata and reset version.
|
java.util.Optional<Function> |
findFunction(FunctionName name,
java.util.List<AbstractType<?>> argTypes)
Find the function with the specified name
|
ColumnFamilyStore |
getColumnFamilyStoreInstance(TableId id) |
java.util.Collection<Function> |
getFunctions(FunctionName name)
Get all function overloads with the specified name
|
TableMetadataRef |
getIndexTableMetadataRef(java.lang.String keyspace,
java.lang.String index) |
Keyspace |
getKeyspaceInstance(java.lang.String keyspaceName)
Get keyspace instance by name
|
KeyspaceMetadata |
getKeyspaceMetadata(java.lang.String keyspaceName)
Get metadata about keyspace by its name
|
java.util.Set<java.lang.String> |
getKeyspaces() |
java.util.List<java.lang.String> |
getNonLocalStrategyKeyspaces() |
com.google.common.collect.ImmutableList<java.lang.String> |
getNonSystemKeyspaces() |
int |
getNumberOfTables() |
static KeyspaceMetadata |
getSystemKeyspaceMetadata() |
TableMetadata |
getTableMetadata(Descriptor descriptor) |
TableMetadata |
getTableMetadata(java.lang.String keyspace,
java.lang.String table)
Given a keyspace name and table name, get the table
meta data.
|
TableMetadata |
getTableMetadata(TableId id) |
TableMetadataRef |
getTableMetadataRef(Descriptor descriptor) |
TableMetadataRef |
getTableMetadataRef(java.lang.String keyspace,
java.lang.String table)
Given a keyspace name and table/view name, get the table metadata
reference.
|
TableMetadataRef |
getTableMetadataRef(TableId id)
Get Table metadata by its identifier
|
java.lang.Iterable<TableMetadata> |
getTablesAndViews(java.lang.String keyspaceName)
Get metadata about keyspace inner ColumnFamilies
|
java.util.List<java.lang.String> |
getUserKeyspaces() |
java.util.UUID |
getVersion() |
ViewMetadata |
getView(java.lang.String keyspaceName,
java.lang.String viewName) |
boolean |
isEmpty()
Checks whether the current schema is empty.
|
boolean |
isSameVersion(java.util.UUID schemaVersion)
Checks whether the given schema version is the same as the current local schema.
|
void |
load(KeyspaceMetadata ksm)
Update (or insert) new keyspace definition
|
void |
loadFromDisk()
load keyspace (keyspace) definitions, but do not initialize the keyspace instances.
|
void |
loadFromDisk(boolean updateVersion)
Load schema definitions from disk.
|
void |
mergeAndAnnounceVersion(java.util.Collection<Mutation> mutations)
Merge remote schema in form of mutations with local and mutate ks/cf metadata objects
(which also involves fs operations on add/drop ks/cf)
|
void |
registerListener(SchemaChangeListener listener) |
void |
reloadSchemaAndAnnounceVersion() |
Keyspace |
removeKeyspaceInstance(java.lang.String keyspaceName)
Remove keyspace from schema
|
void |
saveSystemKeyspace()
Add entries to system_schema.* for the hardcoded system keyspaces
See CASSANDRA-16856/16996.
|
java.util.Collection<Mutation> |
schemaKeyspaceAsMutations()
See CASSANDRA-16856/16996.
|
static java.lang.String |
schemaVersionToString(java.util.UUID version)
Converts the given schema version to a string.
|
Keyspaces |
snapshot() |
void |
storeKeyspaceInstance(Keyspace keyspace)
Store given Keyspace instance to the schema
|
Schema.TransformationResult |
transform(SchemaTransformation transformation,
boolean locally,
long now)
See CASSANDRA-16856/16996.
|
void |
truncateSchemaKeyspace()
See CASSANDRA-16856/16996.
|
void |
unregisterListener(SchemaChangeListener listener) |
void |
updateVersion()
Read schema from system keyspace and calculate MD5 digest of every row, resulting digest
will be converted into UUID which would act as content-based version of the schema.
|
void |
updateVersionAndAnnounce() |
TableMetadata |
validateTable(java.lang.String keyspaceName,
java.lang.String tableName) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetExistingTableMetadatapublic static final Schema instance
public void saveSystemKeyspace()
public void truncateSchemaKeyspace()
public java.util.Collection<Mutation> schemaKeyspaceAsMutations()
public static KeyspaceMetadata getSystemKeyspaceMetadata()
public void loadFromDisk()
public void loadFromDisk(boolean updateVersion)
updateVersion - true if schema version needs to be updatedpublic void load(KeyspaceMetadata ksm)
ksm - The metadata about keyspacepublic void registerListener(SchemaChangeListener listener)
public void unregisterListener(SchemaChangeListener listener)
public Keyspace getKeyspaceInstance(java.lang.String keyspaceName)
getKeyspaceInstance in interface SchemaProviderkeyspaceName - The name of the keyspacepublic ColumnFamilyStore getColumnFamilyStoreInstance(TableId id)
public void storeKeyspaceInstance(Keyspace keyspace)
storeKeyspaceInstance in interface SchemaProviderkeyspace - The Keyspace instance to storejava.lang.IllegalArgumentException - if Keyspace is already storedpublic Keyspace removeKeyspaceInstance(java.lang.String keyspaceName)
keyspaceName - The name of the keyspace to removepublic Keyspaces snapshot()
public int getNumberOfTables()
public ViewMetadata getView(java.lang.String keyspaceName, java.lang.String viewName)
public KeyspaceMetadata getKeyspaceMetadata(java.lang.String keyspaceName)
getKeyspaceMetadata in interface SchemaProviderkeyspaceName - The name of the keyspacepublic com.google.common.collect.ImmutableList<java.lang.String> getNonSystemKeyspaces()
public java.util.List<java.lang.String> getNonLocalStrategyKeyspaces()
public java.util.List<java.lang.String> getUserKeyspaces()
public java.lang.Iterable<TableMetadata> getTablesAndViews(java.lang.String keyspaceName)
keyspaceName - The name of the keyspacepublic java.util.Set<java.lang.String> getKeyspaces()
public TableMetadataRef getTableMetadataRef(java.lang.String keyspace, java.lang.String table)
getTableMetadataRef in interface SchemaProviderpublic TableMetadataRef getIndexTableMetadataRef(java.lang.String keyspace, java.lang.String index)
public TableMetadataRef getTableMetadataRef(TableId id)
getTableMetadataRef in interface SchemaProviderid - table or view identifierpublic TableMetadataRef getTableMetadataRef(Descriptor descriptor)
getTableMetadataRef in interface SchemaProviderpublic TableMetadata getTableMetadata(java.lang.String keyspace, java.lang.String table)
getTableMetadata in interface SchemaProviderkeyspace - The keyspace nametable - The table namepublic TableMetadata getTableMetadata(TableId id)
getTableMetadata in interface SchemaProviderpublic TableMetadata validateTable(java.lang.String keyspaceName, java.lang.String tableName)
public TableMetadata getTableMetadata(Descriptor descriptor)
public java.util.Collection<Function> getFunctions(FunctionName name)
name - fully qualified function nameFunction otherwisepublic java.util.Optional<Function> findFunction(FunctionName name, java.util.List<AbstractType<?>> argTypes)
name - fully qualified function nameargTypes - function argument typesOptional if the keyspace or the function name are not found;
a non-empty optional of Function otherwisepublic java.util.UUID getVersion()
public boolean isSameVersion(java.util.UUID schemaVersion)
public boolean isEmpty()
public void updateVersion()
public void updateVersionAndAnnounce()
public void clear()
public void reloadSchemaAndAnnounceVersion()
public void mergeAndAnnounceVersion(java.util.Collection<Mutation> mutations)
mutations - the schema changes to applyConfigurationException - If one of metadata attributes has invalid valuepublic Schema.TransformationResult transform(SchemaTransformation transformation, boolean locally, long now) throws java.net.UnknownHostException
java.net.UnknownHostExceptionpublic static java.lang.String schemaVersionToString(java.util.UUID version)
unknown, if version is null
or "(empty)", if version refers to an {@link SchemaConstants#emptyVersion empty) schema.Copyright © 2009-2022 The Apache Software Foundation