Class SchemaTransformations


  • public class SchemaTransformations
    extends java.lang.Object
    Factory and utility methods to create simple schema transformation.
    • Constructor Detail

      • SchemaTransformations

        public SchemaTransformations()
    • 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 - if true, the transformation is a no-op if a keyspace of the same name than keyspace already exists in the schema the transformation is applied on. Otherwise, the transformation throws an AlreadyExistsException 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 - if true, the transformation is a no-op if a table of the same name than table already exists in the schema the transformation is applied on. Otherwise, the transformation throws an AlreadyExistsException in that case.
        Returns:
        the created transformation.
      • 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 - if true, the transformation is a no-op if a view of the same name than view already exists in the schema the transformation is applied on. Otherwise, the transformation throws an AlreadyExistsException 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. (see SchemaConstants.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.