Interface LookupCache<K,V>
- Type Parameters:
K- key of the storeV- value of the store
- All Superinterfaces:
AutoCloseable,Store<K,V>
- All Known Implementing Classes:
InMemoryCache
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 Summary
Modifier and TypeMethodDescriptionassociationByGuid(String guid) Returns the association for the given association guid.voidassociationRegistered(AssociationKey key, AssociationValue value, AssociationValue oldValue) Callback that is invoked when an association is registered.associationsByResourceId(String resourceId) Returns associations for the given resource id.associationsBySubject(String subject) Returns associations for the given subject.voidassociationTombstoned(AssociationKey key, AssociationValue value) Callback that is invoked when an association is tombstoned.clearSubjects(String subject) Clears the cache of deleted schemas that match the given subject.default CompatibilityLevelcompatibilityLevel(String subject, boolean returnTopLevelIfNotFound, CompatibilityLevel defaultForTopLevel) Retrieves the config for a subject.Retrieves the config for a subject.booleancontainsSchema(Schema schema) Checks if a schema is registered in any subject.booleanhasSubjects(String subject, boolean lookupDeletedSubjects) Returns whether there exist schemas (that are not deleted) that match the given subject.Provides the id for the provided guid and context.Retrieves the mode for a subject.referencesSchema(SchemaKey schema) Returns schemas that reference the given schema.voidschemaDeleted(SchemaKey schemaKey, SchemaValue schemaValue, SchemaValue oldSchemaValue) Callback that is invoked when a schema is deleted.schemaIdAndSubjects(Schema schema) Provides SchemaIdAndSubjects associated with the schema.schemaKeyById(Integer id, String subject) Provides theSchemaKeyfor the provided schema id.voidschemaRegistered(SchemaKey schemaKey, SchemaValue schemaValue, SchemaValue oldSchemaValue) Callback that is invoked when a schema is registered.voidschemaTombstoned(SchemaKey schemaKey, SchemaValue schemaValue) Callback that is invoked when a schema is tombstoned.default voidCan be used by subclasses to implement multi-tenancyReturns subjects that have schemas (that are not deleted) that match the given subject.default Stringtenant()
-
Method Details
-
schemaIdAndSubjects
Provides SchemaIdAndSubjects associated with the schema.- Parameters:
schema- schema object; nevernull- Returns:
- the schema id and subjects associated with the schema, null otherwise.
- Throws:
StoreException
-
containsSchema
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
Returns schemas that reference the given schema.- Parameters:
schema- schema object- Returns:
- the ids of schemas that reference the given schema
- Throws:
StoreException
-
schemaKeyById
Provides theSchemaKeyfor the provided schema id.- Parameters:
id- the schema id; nevernullsubject- the qualified context or subject- Returns:
- the
SchemaKeyif found, otherwise null. - Throws:
StoreException
-
idByGuid
Provides the id for the provided guid and context.- Parameters:
guid- the schema guid; nevernullcontext- the qualified context- Returns:
- the id if found, otherwise null.
- Throws:
StoreException
-
schemaRegistered
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; nevernullschemaValue- the registered SchemaValue; nevernulloldSchemaValue- the previous SchemaValue
-
schemaDeleted
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; nevernullschemaValue- the deleted SchemaValue; nevernulloldSchemaValue- the previous SchemaValue
-
schemaTombstoned
Callback that is invoked when a schema is tombstoned.- Parameters:
schemaKey- the tombstoned SchemaKey; nevernullschemaValue- the tombstoned SchemaValue
-
associationByGuid
Returns the association for the given association guid.- Parameters:
guid- the association guid; nevernull- Returns:
- the association for the association guid
- Throws:
StoreException
-
associationsBySubject
Returns associations for the given subject.- Parameters:
subject- the subject; nevernull- 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; nevernull- Returns:
- the associations for the resource id
- Throws:
StoreException
-
associationRegistered
Callback that is invoked when an association is registered.- Parameters:
key- the registered AssociationKey; nevernullvalue- the registered AssociationValue; nevernulloldValue- the previous AssociationValue
-
associationTombstoned
Callback that is invoked when an association is tombstoned.- Parameters:
key- the tombstoned AssociationKey; nevernullvalue- the tombstoned AssociationValue
-
compatibilityLevel
default CompatibilityLevel compatibilityLevel(String subject, boolean returnTopLevelIfNotFound, CompatibilityLevel defaultForTopLevel) throws StoreException Retrieves the config for a subject.- Parameters:
subject- the subjectreturnTopLevelIfNotFound- whether to return the top level scope if not founddefaultForTopLevel- 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 subjectreturnTopLevelIfNotFound- whether to return the top level scope if not founddefaultForTopLevel- 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 subjectreturnTopLevelIfNotFound- whether to return the top level scope if not founddefaultForTopLevel- default value for the top level scope- Returns:
- the mode if found, otherwise null.
- Throws:
StoreException
-
subjects
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
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
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
-
setTenant
Can be used by subclasses to implement multi-tenancy- Parameters:
tenant- the tenant
-