Package com.atlan.cache
Class AbstractMassCache<T extends AtlanObject>
java.lang.Object
com.atlan.cache.AbstractMassCache<T>
- Direct Known Subclasses:
AtlanTagCache,CustomMetadataCache,GroupCache,RoleCache,UserCache
Base class for reusable components that are common to all caches, where
a cache is populated en-masse through batch refreshing.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AtomicBooleanWhether to refresh the cache by retrieving all objects up-front (true) or lazily, on-demand (false).protected final ReadWriteLock -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdd an entry to the cache.voidWraps a single object lookup for the cache with necessary concurrency controls.voidcacheByName(String name) Wraps a single object lookup for the cache with necessary concurrency controls.entrySet()Retrieve an iterable set of entries for the object-storing portion of the cache.Whether to refresh the cache by retrieving all objects up-front (true) or lazily, on-demand (false).Retrieve the actual object by Atlan-internal ID string.Retrieve the actual object by Atlan-internal ID string.Retrieve the actual object by human-readable name.Retrieve the actual object by human-readable name.getIdForName(String name) Translate the provided human-readable name to its Atlan-internal ID string.getIdForName(String name, boolean allowRefresh) Translate the provided human-readable name to its Atlan-internal ID string.protected StringgetIdFromName(String name) Thread-safe cache retrieval of the ID of an object by its name.getNameForId(String id) Translate the provided Atlan-internal ID string to the human-readable name for the object.getNameForId(String id, boolean allowRefresh) Translate the provided Atlan-internal ID string to the human-readable name for the object.protected StringgetNameFromId(String id) Thread-safe cache retrieval of the name of an object by its ID.protected TgetObjectById(String id) Thread-safe cache retrieval of the object itself, by its ID.protected booleanisEmpty()Whether the object-storing portion of the cache is empty (true) or not (false).booleanChecks whether the provided Atlan-internal ID string is known.booleanisNameKnown(String name) Checks whether the provided human-readable name is known.protected abstract voidlookupById(String id) Logic to look up a single object for the cache.protected abstract voidlookupByName(String name) Logic to look up a single object for the cache.voidrefresh()Wraps the cache refresh with necessary concurrency controls.protected abstract voidLogic to refresh a specific cache en-masse (must be implemented).
-
Field Details
-
lock
-
bulkRefresh
Whether to refresh the cache by retrieving all objects up-front (true) or lazily, on-demand (false).
-
-
Constructor Details
-
AbstractMassCache
public AbstractMassCache()
-
-
Method Details
-
refresh
Wraps the cache refresh with necessary concurrency controls. Always call this method to actually update a cache, not the directly-implemented, cache-specificrefreshCache.- Throws:
AtlanException- on any error communicating with Atlan to refresh the cache of objects
-
cacheById
Wraps a single object lookup for the cache with necessary concurrency controls.- Parameters:
id- unique internal identifier for the object- Throws:
AtlanException- on any error communicating with Atlan
-
cacheByName
Wraps a single object lookup for the cache with necessary concurrency controls.- Parameters:
name- unique name for the object- Throws:
AtlanException- on any error communicating with Atlan
-
refreshCache
Logic to refresh a specific cache en-masse (must be implemented).- Throws:
AtlanException- on any error communicating with Atlan to refresh the cache of objects
-
lookupById
Logic to look up a single object for the cache.- Parameters:
id- unique internal identifier for the object- Throws:
AtlanException- on any error communicating with Atlan
-
lookupByName
Logic to look up a single object for the cache.- Parameters:
name- unique name for the object- Throws:
AtlanException- on any error communicating with Atlan
-
cache
Add an entry to the cache. This should only be called by the lookup methods, which themselves should never directly be invoked.- Parameters:
id- Atlan-internal IDname- human-readable nameobject- the object to cache (if any)
-
isEmpty
protected boolean isEmpty()Whether the object-storing portion of the cache is empty (true) or not (false).- Returns:
- true if no objects are cached, otherwise false
-
entrySet
Retrieve an iterable set of entries for the object-storing portion of the cache.- Returns:
- an iterable set of entries of objects that are cached
-
isNameKnown
Checks whether the provided human-readable name is known. (Note: will not refresh the cache itself to determine this.)- Parameters:
name- human-readable name of the object- Returns:
- true if the object is known, false otherwise
-
isIdKnown
Checks whether the provided Atlan-internal ID string is known. (Note: will not refresh the cache itself to determine this.)- Parameters:
id- Atlan-internal ID string of the object- Returns:
- true if the object is known, false otherwise
-
getIdFromName
Thread-safe cache retrieval of the ID of an object by its name.- Parameters:
name- of the object- Returns:
- the ID of the object (if cached), or null
-
getNameFromId
Thread-safe cache retrieval of the name of an object by its ID.- Parameters:
id- of the object- Returns:
- the name of the object (if cached), or null
-
getObjectById
Thread-safe cache retrieval of the object itself, by its ID.- Parameters:
id- of the object- Returns:
- the object itself (if cached), or null
-
getIdForName
Translate the provided human-readable name to its Atlan-internal ID string.- Parameters:
name- human-readable name of the object- Returns:
- unique Atlan-internal ID string for the object
- Throws:
AtlanException- on any API communication problem if the cache needs to be refreshedNotFoundException- if the object cannot be found (does not exist) in AtlanInvalidRequestException- if no name was provided for the object to retrieve
-
getIdForName
Translate the provided human-readable name to its Atlan-internal ID string.- Parameters:
name- human-readable name of the objectallowRefresh- whether to allow a refresh of the cache (true) or not (false)- Returns:
- unique Atlan-internal ID string for the object
- Throws:
AtlanException- on any API communication problem if the cache needs to be refreshedNotFoundException- if the object cannot be found (does not exist) in AtlanInvalidRequestException- if no name was provided for the object to retrieve
-
getNameForId
Translate the provided Atlan-internal ID string to the human-readable name for the object.- Parameters:
id- Atlan-internal ID string- Returns:
- human-readable name of the object
- Throws:
AtlanException- on any API communication problem if the cache needs to be refreshedNotFoundException- if the object cannot be found (does not exist) in AtlanInvalidRequestException- if no name was provided for the object to retrieve
-
getNameForId
Translate the provided Atlan-internal ID string to the human-readable name for the object.- Parameters:
id- Atlan-internal ID stringallowRefresh- whether to allow a refresh of the cache (true) or not (false)- Returns:
- human-readable name of the object
- Throws:
AtlanException- on any API communication problem if the cache needs to be refreshedNotFoundException- if the object cannot be found (does not exist) in AtlanInvalidRequestException- if no name was provided for the object to retrieve
-
getById
Retrieve the actual object by Atlan-internal ID string.- Parameters:
id- Atlan-internal ID string- Returns:
- the object with that ID
- Throws:
AtlanException- on any API communication problem if the cache needs to be refreshedNotFoundException- if the object cannot be found (does not exist) in AtlanInvalidRequestException- if no ID was provided for the object to retrieve
-
getById
Retrieve the actual object by Atlan-internal ID string.- Parameters:
id- Atlan-internal ID stringallowRefresh- whether to allow a refresh of the cache (true) or not (false)- Returns:
- the object with that ID
- Throws:
AtlanException- on any API communication problem if the cache needs to be refreshedNotFoundException- if the object cannot be found (does not exist) in AtlanInvalidRequestException- if no ID was provided for the object to retrieve
-
getByName
Retrieve the actual object by human-readable name.- Parameters:
name- human-readable name of the object- Returns:
- the object with that name
- Throws:
AtlanException- on any API communication problem if the cache needs to be refreshedNotFoundException- if the object cannot be found (does not exist) in AtlanInvalidRequestException- if no name was provided for the object to retrieve
-
getByName
Retrieve the actual object by human-readable name.- Parameters:
name- human-readable name of the objectallowRefresh- whether to allow a refresh of the cache (true) or not (false)- Returns:
- the object with that name
- Throws:
AtlanException- on any API communication problem if the cache needs to be refreshedNotFoundException- if the object cannot be found (does not exist) in AtlanInvalidRequestException- if no name was provided for the object to retrieve
-
getBulkRefresh
Whether to refresh the cache by retrieving all objects up-front (true) or lazily, on-demand (false).
-