Class InMemoryCache<K,V>
java.lang.Object
io.confluent.kafka.schemaregistry.storage.InMemoryCache<K,V>
- All Implemented Interfaces:
LookupCache<K,,V> Store<K,,V> AutoCloseable
In-memory store based on maps
-
Constructor Summary
Constructors -
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.voidclose()Retrieves the config for a subject.booleancontainsSchema(Schema schema) Checks if a schema is registered in any subject.voidflush()Iterator over keys in the specified rangebooleanhasSubjects(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.voidinit()matchingSubjectPredicate(String subject) Retrieves the mode for a subject.voidreferencesSchema(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.Returns subjects that have schemas (that are not deleted) that match the given subject.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.confluent.kafka.schemaregistry.storage.LookupCache
compatibilityLevel, setTenant, tenantMethods inherited from interface io.confluent.kafka.schemaregistry.storage.Store
isPersistent
-
Constructor Details
-
InMemoryCache
-
-
Method Details
-
init
- Specified by:
initin interfaceStore<K,V> - Throws:
StoreInitializationException
-
get
- Specified by:
getin interfaceStore<K,V> - Throws:
StoreException
-
put
- Specified by:
putin interfaceStore<K,V> - Throws:
StoreException
-
getAll
Description copied from interface:StoreIterator over keys in the specified range- Specified by:
getAllin interfaceStore<K,V> - Parameters:
key1- If key1 is null, start from the first key in sorted orderkey2- If key2 is null, end at the last key- Returns:
- Iterator over keys in the half-open interval [key1, key2). If both keys are null, return an iterator over all keys in the database
- Throws:
StoreException
-
putAll
- Specified by:
putAllin interfaceStore<K,V> - Throws:
StoreException
-
delete
- Specified by:
deletein interfaceStore<K,V> - Throws:
StoreException
-
getAllKeys
- Specified by:
getAllKeysin interfaceStore<K,V> - Throws:
StoreException
-
flush
- Specified by:
flushin interfaceStore<K,V> - Throws:
StoreException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceStore<K,V> - Throws:
StoreException
-
schemaIdAndSubjects
Description copied from interface:LookupCacheProvides SchemaIdAndSubjects associated with the schema.- Specified by:
schemaIdAndSubjectsin interfaceLookupCache<K,V> - Parameters:
schema- schema object; nevernull- Returns:
- the schema id and subjects associated with the schema, null otherwise.
- Throws:
StoreException
-
containsSchema
Description copied from interface:LookupCacheChecks if a schema is registered in any subject.- Specified by:
containsSchemain interfaceLookupCache<K,V> - Parameters:
schema- schema object- Returns:
- true if the schema is already registered else false
- Throws:
StoreException
-
referencesSchema
Description copied from interface:LookupCacheReturns schemas that reference the given schema.- Specified by:
referencesSchemain interfaceLookupCache<K,V> - Parameters:
schema- schema object- Returns:
- the ids of schemas that reference the given schema
- Throws:
StoreException
-
schemaKeyById
Description copied from interface:LookupCacheProvides theSchemaKeyfor the provided schema id.- Specified by:
schemaKeyByIdin interfaceLookupCache<K,V> - Parameters:
id- the schema id; nevernullsubject- the qualified context or subject- Returns:
- the
SchemaKeyif found, otherwise null. - Throws:
StoreException
-
idByGuid
Description copied from interface:LookupCacheProvides the id for the provided guid and context.- Specified by:
idByGuidin interfaceLookupCache<K,V> - Parameters:
guid- the schema guid; nevernullcontext- the qualified context- Returns:
- the id if found, otherwise null.
- Throws:
StoreException
-
schemaDeleted
Description copied from interface:LookupCacheCallback that is invoked when a schema is deleted. This can be used to update any internal data structure. This is invoked synchronously during delete.- Specified by:
schemaDeletedin interfaceLookupCache<K,V> - Parameters:
schemaKey- the deleted SchemaKey; nevernullschemaValue- the deleted SchemaValue; nevernulloldSchemaValue- the previous SchemaValue
-
schemaTombstoned
Description copied from interface:LookupCacheCallback that is invoked when a schema is tombstoned.- Specified by:
schemaTombstonedin interfaceLookupCache<K,V> - Parameters:
schemaKey- the tombstoned SchemaKey; nevernullschemaValue- the tombstoned SchemaValue
-
schemaRegistered
public void schemaRegistered(SchemaKey schemaKey, SchemaValue schemaValue, SchemaValue oldSchemaValue) Description copied from interface:LookupCacheCallback that is invoked when a schema is registered. This can be used to update any internal data structure. This is invoked synchronously during register.- Specified by:
schemaRegisteredin interfaceLookupCache<K,V> - Parameters:
schemaKey- the registered SchemaKey; nevernullschemaValue- the registered SchemaValue; nevernulloldSchemaValue- the previous SchemaValue
-
associationByGuid
Description copied from interface:LookupCacheReturns the association for the given association guid.- Specified by:
associationByGuidin interfaceLookupCache<K,V> - Parameters:
guid- the association guid; nevernull- Returns:
- the association for the association guid
- Throws:
StoreException
-
associationsBySubject
public CloseableIterator<AssociationValue> associationsBySubject(String subject) throws StoreException Description copied from interface:LookupCacheReturns associations for the given subject.- Specified by:
associationsBySubjectin interfaceLookupCache<K,V> - Parameters:
subject- the subject; nevernull- Returns:
- the associations for the subject
- Throws:
StoreException
-
associationsByResourceId
public CloseableIterator<AssociationValue> associationsByResourceId(String resourceId) throws StoreException Description copied from interface:LookupCacheReturns associations for the given resource id.- Specified by:
associationsByResourceIdin interfaceLookupCache<K,V> - Parameters:
resourceId- the resource id; nevernull- Returns:
- the associations for the resource id
- Throws:
StoreException
-
associationRegistered
public void associationRegistered(AssociationKey key, AssociationValue value, AssociationValue oldValue) Description copied from interface:LookupCacheCallback that is invoked when an association is registered.- Specified by:
associationRegisteredin interfaceLookupCache<K,V> - Parameters:
key- the registered AssociationKey; nevernullvalue- the registered AssociationValue; nevernulloldValue- the previous AssociationValue
-
associationTombstoned
Description copied from interface:LookupCacheCallback that is invoked when an association is tombstoned.- Specified by:
associationTombstonedin interfaceLookupCache<K,V> - Parameters:
key- the tombstoned AssociationKey; nevernullvalue- the tombstoned AssociationValue
-
config
public Config config(String subject, boolean returnTopLevelIfNotFound, Config defaultForTopLevel) throws StoreException Description copied from interface:LookupCacheRetrieves the config for a subject.- Specified by:
configin interfaceLookupCache<K,V> - 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
public Mode mode(String subject, boolean returnTopLevelIfNotFound, Mode defaultForTopLevel) throws StoreException Description copied from interface:LookupCacheRetrieves the mode for a subject.- Specified by:
modein interfaceLookupCache<K,V> - 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
Description copied from interface:LookupCacheReturns subjects that have schemas (that are not deleted) that match the given subject.- Specified by:
subjectsin interfaceLookupCache<K,V> - Parameters:
subject- the subject, or null for all subjects- Returns:
- the subjects with matching schemas
- Throws:
StoreException
-
hasSubjects
Description copied from interface:LookupCacheReturns whether there exist schemas (that are not deleted) that match the given subject.- Specified by:
hasSubjectsin interfaceLookupCache<K,V> - Parameters:
subject- the subject, or null for all subjects- Returns:
- whether there exist matching schemas
- Throws:
StoreException
-
clearSubjects
Description copied from interface:LookupCacheClears the cache of deleted schemas that match the given subject.- Specified by:
clearSubjectsin interfaceLookupCache<K,V> - Parameters:
subject- the subject, or null for all subjects- Returns:
- the number of schemas cleared by schema type
- Throws:
StoreException
-
matchingSubjectPredicate
-