Interface LookupCache<K,V>

Type Parameters:
K - key of the store
V - value of the store
All Superinterfaces:
AutoCloseable, Store<K,V>
All Known Implementing Classes:
InMemoryCache

public interface LookupCache<K,V> extends Store<K,V>
Internal interface that provides various indexed methods that help lookup the underlying schemas. The interface has also callback methods for various schema lifecycle events like register, delete, etc. It is important to note that these callbacks block the corresponding API that lead to the callback. Hence sufficient care must be taken to ensure that the callbacks are light weight.
  • Method Details

    • schemaIdAndSubjects

      SchemaIdAndSubjects schemaIdAndSubjects(Schema schema) throws StoreException
      Provides SchemaIdAndSubjects associated with the schema.
      Parameters:
      schema - schema object; never null
      Returns:
      the schema id and subjects associated with the schema, null otherwise.
      Throws:
      StoreException
    • containsSchema

      boolean containsSchema(Schema schema) throws StoreException
      Checks if a schema is registered in any subject.
      Parameters:
      schema - schema object
      Returns:
      true if the schema is already registered else false
      Throws:
      StoreException
    • referencesSchema

      Set<ContextId> referencesSchema(SchemaKey schema) throws StoreException
      Returns schemas that reference the given schema.
      Parameters:
      schema - schema object
      Returns:
      the ids of schemas that reference the given schema
      Throws:
      StoreException
    • schemaKeyById

      SchemaKey schemaKeyById(Integer id, String subject) throws StoreException
      Provides the SchemaKey for the provided schema id.
      Parameters:
      id - the schema id; never null
      subject - the qualified context or subject
      Returns:
      the SchemaKey if found, otherwise null.
      Throws:
      StoreException
    • idByGuid

      Integer idByGuid(String guid, String context) throws StoreException
      Provides the id for the provided guid and context.
      Parameters:
      guid - the schema guid; never null
      context - the qualified context
      Returns:
      the id if found, otherwise null.
      Throws:
      StoreException
    • schemaRegistered

      void schemaRegistered(SchemaKey schemaKey, SchemaValue schemaValue, SchemaValue oldSchemaValue)
      Callback that is invoked when a schema is registered. This can be used to update any internal data structure. This is invoked synchronously during register.
      Parameters:
      schemaKey - the registered SchemaKey; never null
      schemaValue - the registered SchemaValue; never null
      oldSchemaValue - the previous SchemaValue
    • schemaDeleted

      void schemaDeleted(SchemaKey schemaKey, SchemaValue schemaValue, SchemaValue oldSchemaValue)
      Callback that is invoked when a schema is deleted. This can be used to update any internal data structure. This is invoked synchronously during delete.
      Parameters:
      schemaKey - the deleted SchemaKey; never null
      schemaValue - the deleted SchemaValue; never null
      oldSchemaValue - the previous SchemaValue
    • schemaTombstoned

      void schemaTombstoned(SchemaKey schemaKey, SchemaValue schemaValue)
      Callback that is invoked when a schema is tombstoned.
      Parameters:
      schemaKey - the tombstoned SchemaKey; never null
      schemaValue - the tombstoned SchemaValue
    • associationByGuid

      AssociationValue associationByGuid(String guid) throws StoreException
      Returns the association for the given association guid.
      Parameters:
      guid - the association guid; never null
      Returns:
      the association for the association guid
      Throws:
      StoreException
    • associationsBySubject

      CloseableIterator<AssociationValue> associationsBySubject(String subject) throws StoreException
      Returns associations for the given subject.
      Parameters:
      subject - the subject; never null
      Returns:
      the associations for the subject
      Throws:
      StoreException
    • associationsByResourceId

      CloseableIterator<AssociationValue> associationsByResourceId(String resourceId) throws StoreException
      Returns associations for the given resource id.
      Parameters:
      resourceId - the resource id; never null
      Returns:
      the associations for the resource id
      Throws:
      StoreException
    • associationRegistered

      void associationRegistered(AssociationKey key, AssociationValue value, AssociationValue oldValue)
      Callback that is invoked when an association is registered.
      Parameters:
      key - the registered AssociationKey; never null
      value - the registered AssociationValue; never null
      oldValue - the previous AssociationValue
    • associationTombstoned

      void associationTombstoned(AssociationKey key, AssociationValue value)
      Callback that is invoked when an association is tombstoned.
      Parameters:
      key - the tombstoned AssociationKey; never null
      value - the tombstoned AssociationValue
    • compatibilityLevel

      default CompatibilityLevel compatibilityLevel(String subject, boolean returnTopLevelIfNotFound, CompatibilityLevel defaultForTopLevel) throws StoreException
      Retrieves the config for a subject.
      Parameters:
      subject - the subject
      returnTopLevelIfNotFound - whether to return the top level scope if not found
      defaultForTopLevel - default value for the top level scope
      Returns:
      the compatibility level if found, otherwise null
      Throws:
      StoreException
    • config

      Config config(String subject, boolean returnTopLevelIfNotFound, Config defaultForTopLevel) throws StoreException
      Retrieves the config for a subject.
      Parameters:
      subject - the subject
      returnTopLevelIfNotFound - whether to return the top level scope if not found
      defaultForTopLevel - default value for the top level scope
      Returns:
      the compatibility level if found, otherwise null
      Throws:
      StoreException
    • mode

      Mode mode(String subject, boolean returnTopLevelIfNotFound, Mode defaultForTopLevel) throws StoreException
      Retrieves the mode for a subject.
      Parameters:
      subject - the subject
      returnTopLevelIfNotFound - whether to return the top level scope if not found
      defaultForTopLevel - default value for the top level scope
      Returns:
      the mode if found, otherwise null.
      Throws:
      StoreException
    • subjects

      Set<String> subjects(String subject, boolean lookupDeletedSubjects) throws StoreException
      Returns subjects that have schemas (that are not deleted) that match the given subject.
      Parameters:
      subject - the subject, or null for all subjects
      Returns:
      the subjects with matching schemas
      Throws:
      StoreException
    • hasSubjects

      boolean hasSubjects(String subject, boolean lookupDeletedSubjects) throws StoreException
      Returns whether there exist schemas (that are not deleted) that match the given subject.
      Parameters:
      subject - the subject, or null for all subjects
      Returns:
      whether there exist matching schemas
      Throws:
      StoreException
    • clearSubjects

      Map<String,Integer> clearSubjects(String subject) throws StoreException
      Clears the cache of deleted schemas that match the given subject.
      Parameters:
      subject - the subject, or null for all subjects
      Returns:
      the number of schemas cleared by schema type
      Throws:
      StoreException
    • tenant

      default String tenant()
    • setTenant

      default void setTenant(String tenant)
      Can be used by subclasses to implement multi-tenancy
      Parameters:
      tenant - the tenant