Class ResourcePool<K,V>
java.lang.Object
org.apache.druid.java.util.http.client.pool.ResourcePool<K,V>
- All Implemented Interfaces:
Closeable,AutoCloseable
A resource pool based on
LoadingCache. When a resource is first requested for a new key,
If the flag: eagerInitialization is true: use ResourcePool.EagerCreationResourceHolder
ResourcePoolConfig.getMaxPerKey() resources are initialized and cached in the pool.
Else:
Initialize a single resource and further lazily using ResourcePool.LazyCreationResourceHolder
The individual resource in ResourcePool.ResourceHolderPerKey is valid while (current time - last access time)
<= ResourcePoolConfig.getUnusedConnectionTimeoutMillis().
A resource is closed and reinitialized if ResourceFactory.isGood(V) returns false or it's expired based on
ResourcePoolConfig.getUnusedConnectionTimeoutMillis().
is a hard limit for the max number of resources per cache entry. The total
number of resources in {@link ResourceHolderPerKey} cannot be larger than the limit in any case.-
Constructor Summary
ConstructorsConstructorDescriptionResourcePool(ResourceFactory<K, V> factory, ResourcePoolConfig config, boolean eagerInitialization) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Returns aResourceContainerfor the given key or null if this pool is already closed.
-
Constructor Details
-
ResourcePool
public ResourcePool(ResourceFactory<K, V> factory, ResourcePoolConfig config, boolean eagerInitialization)
-
-
Method Details
-
take
Returns aResourceContainerfor the given key or null if this pool is already closed. -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-