Interface RealmStore


public interface RealmStore
Interface to be implemented by persistence-specific implementations (NoSQL or metastore manager based).

Implementations must not perform any validation of the realm definitions unless explicitly stated below.

  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.polaris.persistence.nosql.realms.api.RealmDefinition
    create(String realmId, org.apache.polaris.persistence.nosql.realms.api.RealmDefinition definition)
    Create a new realm.
    void
    delete(String realmId, Consumer<org.apache.polaris.persistence.nosql.realms.api.RealmDefinition> callback)
    Deletes a realm definition.
    Optional<org.apache.polaris.persistence.nosql.realms.api.RealmDefinition>
    get(String realmId)
    Returns a realm definition if it exists.
    Stream<org.apache.polaris.persistence.nosql.realms.api.RealmDefinition>
    Returns a stream of all realm definitions.
    org.apache.polaris.persistence.nosql.realms.api.RealmDefinition
    update(String realmId, Function<org.apache.polaris.persistence.nosql.realms.api.RealmDefinition,org.apache.polaris.persistence.nosql.realms.api.RealmDefinition> updater)
    Updates a realm definition.
  • Method Details

    • list

      @MustBeClosed Stream<org.apache.polaris.persistence.nosql.realms.api.RealmDefinition> list()
      Returns a stream of all realm definitions. The returned stream must be closed.
    • get

      Optional<org.apache.polaris.persistence.nosql.realms.api.RealmDefinition> get(String realmId)
      Returns a realm definition if it exists.

      Unlike the updating functions, this function does not throw an exception if a realm does not exist.

    • delete

      void delete(String realmId, Consumer<org.apache.polaris.persistence.nosql.realms.api.RealmDefinition> callback)
      Deletes a realm definition.
      Parameters:
      callback - receives the persisted realm definition that is being deleted. If the callback throws any exception, the delete operation must not be persisted. All thrown exceptions must be propagated to the caller.
      Throws:
      org.apache.polaris.persistence.nosql.realms.api.RealmNotFoundException - if a realm with the given ID does not exist
    • update

      org.apache.polaris.persistence.nosql.realms.api.RealmDefinition update(String realmId, Function<org.apache.polaris.persistence.nosql.realms.api.RealmDefinition,org.apache.polaris.persistence.nosql.realms.api.RealmDefinition> updater)
      Updates a realm definition.

      Implementations update the persisted state of the realm definition. The created timestamp must be carried forwards from the persisted state.

      RealmManagement implementations, which call this function, take care of "properly" populating the attributes of the realm definition to persist.

      Parameters:
      updater - receives the current definition and returns the updated definition. If the updated throws any exception, the update operation must not be persisted. All thrown exceptions must be propagated to the caller.
      Returns:
      the persisted realm definition
      Throws:
      org.apache.polaris.persistence.nosql.realms.api.RealmNotFoundException - if a realm with the given ID does not exist
    • create

      org.apache.polaris.persistence.nosql.realms.api.RealmDefinition create(String realmId, org.apache.polaris.persistence.nosql.realms.api.RealmDefinition definition)
      Create a new realm.

      RealmManagement implementations, which call this function, take care of "properly" populating the attributes of the realm definition to persist.

      Parameters:
      definition - the realm definition of the realm to be created, to be persisted as given.
      Returns:
      the persisted realm definition
      Throws:
      org.apache.polaris.persistence.nosql.realms.api.RealmAlreadyExistsException - if the realm already exists