Package org.apache.cassandra.schema
Class SchemaTransformations
java.lang.Object
org.apache.cassandra.schema.SchemaTransformations
Factory and utility methods to create simple schema transformation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SchemaTransformationaddKeyspace(KeyspaceMetadata keyspace, boolean ignoreIfExists) Creates a schema transformation that adds the provided keyspace.static SchemaTransformationaddTable(TableMetadata table, boolean ignoreIfExists) Creates a schema transformation that adds the provided table.static SchemaTransformationstatic SchemaTransformationaddView(ViewMetadata view, boolean ignoreIfExists) Creates a schema transformation that adds the provided view.static SchemaTransformationupdateSystemKeyspace(KeyspaceMetadata keyspace, long generation) We have a set of non-local, distributed system keyspaces, e.g.
-
Constructor Details
-
SchemaTransformations
public SchemaTransformations()
-
-
Method Details
-
addKeyspace
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 thankeyspacealready exists in the schema the transformation is applied on. Otherwise, the transformation throws anAlreadyExistsExceptionin that case.- Returns:
- the created transformation.
-
addTable
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 thantablealready exists in the schema the transformation is applied on. Otherwise, the transformation throws anAlreadyExistsExceptionin that case.- Returns:
- the created transformation.
-
addTypes
-
addView
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 thanviewalready exists in the schema the transformation is applied on. Otherwise, the transformation throws anAlreadyExistsExceptionin that case.- Returns:
- the created transformation.
-
updateSystemKeyspace
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.
-