Package org.apache.cassandra.schema
Class SchemaTransformations
- java.lang.Object
-
- org.apache.cassandra.schema.SchemaTransformations
-
public class SchemaTransformations extends java.lang.Object
Factory and utility methods to create simple schema transformation.
-
-
Constructor Summary
Constructors Constructor Description SchemaTransformations()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SchemaTransformation
addKeyspace(KeyspaceMetadata keyspace, boolean ignoreIfExists)
Creates a schema transformation that adds the provided keyspace.static SchemaTransformation
addTable(TableMetadata table, boolean ignoreIfExists)
Creates a schema transformation that adds the provided table.static SchemaTransformation
addTypes(Types toAdd, boolean ignoreIfExists)
static SchemaTransformation
addView(ViewMetadata view, boolean ignoreIfExists)
Creates a schema transformation that adds the provided view.static SchemaTransformation
updateSystemKeyspace(KeyspaceMetadata keyspace, long generation)
We have a set of non-local, distributed system keyspaces, e.g.
-
-
-
Method Detail
-
addKeyspace
public static SchemaTransformation addKeyspace(KeyspaceMetadata keyspace, boolean ignoreIfExists)
Creates a schema transformation that adds the provided keyspace.- Parameters:
keyspace
- the keyspace to add.ignoreIfExists
- iftrue
, the transformation is a no-op if a keyspace of the same name thankeyspace
already exists in the schema the transformation is applied on. Otherwise, the transformation throws anAlreadyExistsException
in that case.- Returns:
- the created transformation.
-
addTable
public static SchemaTransformation addTable(TableMetadata table, boolean ignoreIfExists)
Creates a schema transformation that adds the provided table.- Parameters:
table
- the table to add.ignoreIfExists
- iftrue
, the transformation is a no-op if a table of the same name thantable
already exists in the schema the transformation is applied on. Otherwise, the transformation throws anAlreadyExistsException
in that case.- Returns:
- the created transformation.
-
addTypes
public static SchemaTransformation addTypes(Types toAdd, boolean ignoreIfExists)
-
addView
public static SchemaTransformation addView(ViewMetadata view, boolean ignoreIfExists)
Creates a schema transformation that adds the provided view.- Parameters:
view
- the view to add.ignoreIfExists
- iftrue
, the transformation is a no-op if a view of the same name thanview
already exists in the schema the transformation is applied on. Otherwise, the transformation throws anAlreadyExistsException
in that case.- Returns:
- the created transformation.
-
updateSystemKeyspace
public static SchemaTransformation updateSystemKeyspace(KeyspaceMetadata keyspace, long generation)
We have a set of non-local, distributed system keyspaces, e.g. system_traces, system_auth, etc. (seeSchemaConstants.REPLICATED_SYSTEM_KEYSPACE_NAMES
), that need to be created on cluster initialisation, and later evolved on major upgrades (sometimes minor too). This method compares the current known definitions of the tables (if the keyspace exists) to the expected, most modern ones expected by the running version of C*. If any changes have been detected, a schema transformation returned by this method should make cluster's view of that keyspace aligned with the expected modern definition.- Parameters:
keyspace
- the metadata of the keyspace as it should be after application.generation
- timestamp to use for the table changes in the schema mutation- Returns:
- the transformation.
-
-