Class MetadataCacheImpl<T>
java.lang.Object
org.apache.pulsar.metadata.cache.impl.MetadataCacheImpl<T>
- All Implemented Interfaces:
Consumer<Notification>,MetadataCache<T>
public class MetadataCacheImpl<T>
extends Object
implements MetadataCache<T>, Consumer<Notification>
-
Constructor Summary
ConstructorsConstructorDescriptionMetadataCacheImpl(MetadataStore store, com.fasterxml.jackson.core.type.TypeReference<T> typeRef, MetadataCacheConfig cacheConfig) MetadataCacheImpl(MetadataStore store, com.fasterxml.jackson.databind.JavaType type, MetadataCacheConfig cacheConfig) MetadataCacheImpl(MetadataStore store, MetadataSerde<T> serde, MetadataCacheConfig cacheConfig) -
Method Summary
Modifier and TypeMethodDescriptionvoidCreate a new object in the metadata store.Delete an object from the metadata store.Read whether a specific path exists.Tries to fetch one item from the cache or fallback to the store if not present.getChildren(String path) Return all the nodes (lexicographically sorted) that are children to the specific path.getIfCached(String path) Check if an object is present in cache without triggering a load from the metadata store.getWithStats(String path) Tries to fetch one item from the cache or fallback to the store if not present.voidinvalidate(String path) Force the invalidation of an object in the metadata cache.voidreadModifyUpdate(String path, Function<T, T> modifyFunction) Perform an atomic read-modify-update of the value.Perform an atomic read-modify-update of the value.voidInvalidate and reload an object in the metadata cache.
-
Constructor Details
-
MetadataCacheImpl
public MetadataCacheImpl(MetadataStore store, com.fasterxml.jackson.core.type.TypeReference<T> typeRef, MetadataCacheConfig cacheConfig) -
MetadataCacheImpl
public MetadataCacheImpl(MetadataStore store, com.fasterxml.jackson.databind.JavaType type, MetadataCacheConfig cacheConfig) -
MetadataCacheImpl
public MetadataCacheImpl(MetadataStore store, MetadataSerde<T> serde, MetadataCacheConfig cacheConfig)
-
-
Method Details
-
get
Description copied from interface:MetadataCacheTries to fetch one item from the cache or fallback to the store if not present.If the key is not found, the
Optionalwill be empty.- Specified by:
getin interfaceMetadataCache<T>- Parameters:
path- the path of the object in the metadata store- Returns:
- a future to track the completion of the operation
-
getWithStats
Description copied from interface:MetadataCacheTries to fetch one item from the cache or fallback to the store if not present.If the key is not found, the
Optionalwill be empty.- Specified by:
getWithStatsin interfaceMetadataCache<T>- Parameters:
path- the path of the object in the metadata store- Returns:
- a future to track the completion of the operation
-
getIfCached
Description copied from interface:MetadataCacheCheck if an object is present in cache without triggering a load from the metadata store.- Specified by:
getIfCachedin interfaceMetadataCache<T>- Parameters:
path- the path of the object in the metadata store- Returns:
- the cached object or an empty
Optionalis the cache doesn't have the object
-
readModifyUpdateOrCreate
public CompletableFuture<T> readModifyUpdateOrCreate(String path, Function<Optional<T>, T> modifyFunction) Description copied from interface:MetadataCachePerform an atomic read-modify-update of the value.The modify function can potentially be called multiple times if there are concurrent updates happening.
If the object does not exist yet, the
modifyFunctionwill get passed anOptional.empty()object.- Specified by:
readModifyUpdateOrCreatein interfaceMetadataCache<T>- Parameters:
path- the path of the object in the metadata storemodifyFunction- a function that will be passed the current value and returns a modified value to be stored- Returns:
- a future to track the completion of the operation
-
readModifyUpdate
Description copied from interface:MetadataCachePerform an atomic read-modify-update of the value.The modify function can potentially be called multiple times if there are concurrent updates happening.
- Specified by:
readModifyUpdatein interfaceMetadataCache<T>- Parameters:
path- the path of the object in the metadata storemodifyFunction- a function that will be passed the current value and returns a modified value to be stored- Returns:
- a future to track the completion of the operation
-
create
Description copied from interface:MetadataCacheCreate a new object in the metadata store.This operation will make sure to keep the cache consistent.
- Specified by:
createin interfaceMetadataCache<T>- Parameters:
path- the path of the object in the metadata storevalue- the object to insert in metadata store- Returns:
- a future to track the completion of the operation
-
delete
Description copied from interface:MetadataCacheDelete an object from the metadata store.This operation will make sure to keep the cache consistent.
- Specified by:
deletein interfaceMetadataCache<T>- Parameters:
path- the path of the object in the metadata store- Returns:
- a future to track the completion of the operation
-
exists
Description copied from interface:MetadataCacheRead whether a specific path exists. Note: In case of keys with multiple levels (eg: '/a/b/c'), checking the existence of a parent (eg. '/a') might not necessarily return true, unless the key had been explicitly created.- Specified by:
existsin interfaceMetadataCache<T>- Parameters:
path- the path of the key to check on the store- Returns:
- a future to track the async request
-
getChildren
Description copied from interface:MetadataCacheReturn all the nodes (lexicographically sorted) that are children to the specific path. If the path itself does not exist, it will return an empty list.- Specified by:
getChildrenin interfaceMetadataCache<T>- Parameters:
path- the path of the key to get from the store- Returns:
- a future to track the async request
-
invalidate
Description copied from interface:MetadataCacheForce the invalidation of an object in the metadata cache.- Specified by:
invalidatein interfaceMetadataCache<T>- Parameters:
path- the path of the object in the metadata store
-
refresh
Description copied from interface:MetadataCacheInvalidate and reload an object in the metadata cache.- Specified by:
refreshin interfaceMetadataCache<T>- Parameters:
path- the path of the object in the metadata store
-
invalidateAll
public void invalidateAll() -
accept
-