Class SharedResourceManager
java.lang.Object
org.apache.bookkeeper.common.util.SharedResourceManager
A holder for shared resource singletons.
Components like clients and servers need certain resources, e.g. a scheduler, to run. If the user has not provided such resources, these components will use a default one, which is shared as a static resource. This class holds these default resources and manages their lifecycles.
A resource is identified by the reference of a SharedResourceManager.Resource object, which
is typically a singleton, provided to the get() and release() methods. Each resource
object (not its class) maps to an object cached in the holder.
Resources are ref-counted and shut down after a delay when the refcount reaches zero.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceDefines a resource, and the way to create and destroy instances of it. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic SharedResourceManagercreate()static SharedResourceManagercreate(Supplier<ScheduledExecutorService> destroyerFactory) <T> Tget(SharedResourceManager.Resource<T> resource) <T> voidrelease(SharedResourceManager.Resource<T> resource, T instance) static SharedResourceManagershared()
-
Field Details
-
DESTROY_DELAY_SECONDS
static final long DESTROY_DELAY_SECONDS- See Also:
-
-
Method Details
-
create
-
create