Class SchemaManager

java.lang.Object
io.stargate.sgv2.api.common.schema.SchemaManager

@ApplicationScoped public class SchemaManager extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>
    cacheKeyspace(String keyspaceName, Optional<String> tenantId, io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe keyspace)
     
    protected io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>
    fetchKeyspace(String keyspaceName, Optional<String> tenantId, StargateBridge bridge)
     
    io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>
    getKeyspace(String keyspace)
    Get the keyspace from the bridge.
    io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>
    getKeyspace(String keyspace, boolean validateHash)
    Get the keyspace from the bridge.
    io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>
    Get the keyspace from the bridge.
    io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>
    getKeyspaceAuthorized(String keyspace, boolean validateHash)
    Get the keyspace from the bridge.
    io.smallrye.mutiny.Multi<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>
    Get all keyspace from the bridge.
    io.smallrye.mutiny.Multi<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>
    Get all keyspace from the bridge.
    io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlTable>
    getTable(String keyspace, String table, Function<String,io.smallrye.mutiny.Uni<? extends io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>> missingKeyspace)
    Get the table from the bridge.
    io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlTable>
    getTableAuthorized(String keyspace, String table, Function<String,io.smallrye.mutiny.Uni<? extends io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>> missingKeyspace)
    Get the table from the bridge.
    io.smallrye.mutiny.Multi<io.stargate.bridge.proto.Schema.CqlTable>
    getTables(String keyspace, Function<String,io.smallrye.mutiny.Uni<? extends io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>> missingKeyspace)
    Get all tables of a keyspace from the bridge.
    io.smallrye.mutiny.Multi<io.stargate.bridge.proto.Schema.CqlTable>
    getTablesAuthorized(String keyspace, Function<String,io.smallrye.mutiny.Uni<? extends io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>> missingKeyspace)
    Get all authorized tables from the bridge.
    protected io.smallrye.mutiny.Uni<Void>
    invalidateKeyspace(String keyspaceName, Optional<String> tenantId)
     
    io.smallrye.mutiny.Uni<io.stargate.bridge.proto.QueryOuterClass.Response>
    queryWithSchema(String keyspace, String table, Function<String,io.smallrye.mutiny.Uni<? extends io.stargate.bridge.proto.QueryOuterClass.Response>> missingKeyspace, Function<io.stargate.bridge.proto.Schema.CqlTable,io.smallrye.mutiny.Uni<io.stargate.bridge.proto.QueryOuterClass.Query>> queryFunction)
    Executes the optimistic query, by fetching the keyspace without authorization from the @SchemaManager.
    io.smallrye.mutiny.Uni<io.stargate.bridge.proto.QueryOuterClass.Response>
    queryWithSchemaAuthorized(String keyspace, String table, Function<String,io.smallrye.mutiny.Uni<? extends io.stargate.bridge.proto.QueryOuterClass.Response>> missingKeyspace, Function<io.stargate.bridge.proto.Schema.CqlTable,io.smallrye.mutiny.Uni<io.stargate.bridge.proto.QueryOuterClass.Query>> queryFunction)
    Executes the optimistic query, by fetching the keyspace with authorization from the @SchemaManager.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SchemaManager

      public SchemaManager()
  • Method Details

    • getKeyspace

      public io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe> getKeyspace(String keyspace)
      Get the keyspace from the bridge. Note that this method is not doing any authorization. The check that the keyspace has correct hash on the bridge will be done.
      Parameters:
      keyspace - Keyspace name
      Returns:
      Uni containing Schema.CqlKeyspaceDescribe or null item in case keyspace does not exist.
    • getKeyspace

      public io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe> getKeyspace(String keyspace, boolean validateHash)
      Get the keyspace from the bridge. Note that this method is not doing any authorization.
      Parameters:
      keyspace - Keyspace name
      validateHash - If hash validation should be done for the keyspace. If false and the keyspace is already cached, then no calls to the bridge are executed.
      Returns:
      Uni containing Schema.CqlKeyspaceDescribe or null item in case keyspace does not exist.
    • getKeyspaces

      public io.smallrye.mutiny.Multi<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe> getKeyspaces()
      Get all keyspace from the bridge. Note that this method is not doing any authorization. The check that each keyspace has correct hash on the bridge will be done.
      Returns:
      Multi containing Schema.CqlKeyspaceDescribe
    • getTable

      public io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlTable> getTable(String keyspace, String table, Function<String,io.smallrye.mutiny.Uni<? extends io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>> missingKeyspace)
      Get the table from the bridge. Note that this method is not doing any authorization. The check that the keyspace has correct hash on the bridge will be done.
      Parameters:
      keyspace - Keyspace name
      table - Table name
      missingKeyspace - Function of the keyspace in case it's not existing. Usually there to provide a failure.
      Returns:
      Uni containing Schema.CqlTable or null item in case the table does not exist.
    • getTables

      public io.smallrye.mutiny.Multi<io.stargate.bridge.proto.Schema.CqlTable> getTables(String keyspace, Function<String,io.smallrye.mutiny.Uni<? extends io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>> missingKeyspace)
      Get all tables of a keyspace from the bridge. The check that the keyspace has correct hash on the bridge will be done.
      Parameters:
      keyspace - Keyspace name
      missingKeyspace - Function of the keyspace in case it's not existing. Usually there to provide a failure.
      Returns:
      Multi of Schema.CqlTable
    • getKeyspaceAuthorized

      public io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe> getKeyspaceAuthorized(String keyspace)
      Get the keyspace from the bridge. Prior to getting the keyspace it will execute the schema authorization request. The check that the keyspace has correct hash on the bridge will be done.

      Emits a failure in case:

      1. Not authorized, with UnauthorizedKeyspaceException
      Parameters:
      keyspace - Keyspace name
      Returns:
      Uni containing Schema.CqlKeyspaceDescribe or null item in case keyspace does not exist.
    • getKeyspaceAuthorized

      public io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe> getKeyspaceAuthorized(String keyspace, boolean validateHash)
      Get the keyspace from the bridge. Prior to getting the keyspace it will execute the schema authorization request.

      Emits a failure in case:

      1. Not authorized, with UnauthorizedKeyspaceException
      Parameters:
      keyspace - Keyspace name
      validateHash - If hash validation should be done for the keyspace. If false and the keyspace is already cached, then no calls to the bridge are executed.
      Returns:
      Uni containing Schema.CqlKeyspaceDescribe or null item in case keyspace does not exist.
    • getKeyspacesAuthorized

      public io.smallrye.mutiny.Multi<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe> getKeyspacesAuthorized()
      Get all keyspace from the bridge. Prior to getting each keyspace it will execute the schema authorization request (single request for all available keyspace). The check that each keyspace has correct hash on the bridge will be done.
      Returns:
      Multi containing Schema.CqlKeyspaceDescribe
    • getTableAuthorized

      public io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlTable> getTableAuthorized(String keyspace, String table, Function<String,io.smallrye.mutiny.Uni<? extends io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>> missingKeyspace)
      Get the table from the bridge. Prior to getting the keyspace it will execute the schema authorization request. The check that the keyspace has correct hash on the bridge will be done.

      Emits a failure in case:

      1. Not authorized, with UnauthorizedTableException
      Parameters:
      keyspace - Keyspace name
      table - Table name
      missingKeyspace - Function of the keyspace in case it's not existing. Usually there to provide a failure.
      Returns:
      Uni containing Schema.CqlTable or null item in case the table does not exist.
    • getTablesAuthorized

      public io.smallrye.mutiny.Multi<io.stargate.bridge.proto.Schema.CqlTable> getTablesAuthorized(String keyspace, Function<String,io.smallrye.mutiny.Uni<? extends io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe>> missingKeyspace)
      Get all authorized tables from the bridge. The check that the keyspace has correct hash on the bridge will be done.

      Emits a failure in case:

      1. Not authorized, with UnauthorizedTableException
      Parameters:
      keyspace - Keyspace name
      missingKeyspace - Function of the keyspace in case it's not existing. Usually there to provide a failure.
      Returns:
      Multi of Schema.CqlTable
    • queryWithSchema

      public io.smallrye.mutiny.Uni<io.stargate.bridge.proto.QueryOuterClass.Response> queryWithSchema(String keyspace, String table, Function<String,io.smallrye.mutiny.Uni<? extends io.stargate.bridge.proto.QueryOuterClass.Response>> missingKeyspace, Function<io.stargate.bridge.proto.Schema.CqlTable,io.smallrye.mutiny.Uni<io.stargate.bridge.proto.QueryOuterClass.Query>> queryFunction)
      Executes the optimistic query, by fetching the keyspace without authorization from the @SchemaManager.
      Parameters:
      keyspace - Keyspace name.
      table - Table name.
      missingKeyspace - Function in case the keyspace in case it's not existing. Usually there to * provide a failure.
      queryFunction - Function that creates the query from the Schema.CqlTable. Note that the table can be null.
      Returns:
      Response when optimistic query is executed correctly.
    • queryWithSchemaAuthorized

      public io.smallrye.mutiny.Uni<io.stargate.bridge.proto.QueryOuterClass.Response> queryWithSchemaAuthorized(String keyspace, String table, Function<String,io.smallrye.mutiny.Uni<? extends io.stargate.bridge.proto.QueryOuterClass.Response>> missingKeyspace, Function<io.stargate.bridge.proto.Schema.CqlTable,io.smallrye.mutiny.Uni<io.stargate.bridge.proto.QueryOuterClass.Query>> queryFunction)
      Executes the optimistic query, by fetching the keyspace with authorization from the @SchemaManager.
      Parameters:
      keyspace - Keyspace name.
      table - Table name.
      missingKeyspace - Function in case the keyspace in case it's not existing. Usually there to provide a failure.
      queryFunction - Function that creates the query from the Schema.CqlTable. Note that the table can be null.
      Returns:
      Response when optimistic query is executed correctly.
    • fetchKeyspace

      protected io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe> fetchKeyspace(String keyspaceName, Optional<String> tenantId, StargateBridge bridge)
    • cacheKeyspace

      protected io.smallrye.mutiny.Uni<io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe> cacheKeyspace(String keyspaceName, Optional<String> tenantId, io.stargate.bridge.proto.Schema.CqlKeyspaceDescribe keyspace)
    • invalidateKeyspace

      protected io.smallrye.mutiny.Uni<Void> invalidateKeyspace(String keyspaceName, Optional<String> tenantId)