|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectvoldemort.utils.pool.KeyedResourcePool<K,V>
public class KeyedResourcePool<K,V>
A simple implementation of a per-key resource pool.
Nested Class Summary | |
---|---|
protected static class |
KeyedResourcePool.Pool<V>
A fixed size pool that uses an ArrayBlockingQueue. |
Constructor Summary | |
---|---|
KeyedResourcePool(ResourceFactory<K,V> objectFactory,
ResourcePoolConfig resourcePoolConfig)
|
Method Summary | ||
---|---|---|
protected V |
attemptNonBlockingCheckout(K key,
KeyedResourcePool.Pool<V> pool)
Get a free resource if one exists. |
|
void |
checkin(K key,
V resource)
Check the given resource back into the pool |
|
protected void |
checkNotClosed()
Check that the pool is not closed, and throw an IllegalStateException if it is. |
|
V |
checkout(K key)
Checkout a resource if one is immediately available. |
|
void |
close()
Close the pool. |
|
static
|
create(ResourceFactory<K,V> factory)
Create a new pool using the defaults |
|
static
|
create(ResourceFactory<K,V> factory,
ResourcePoolConfig config)
Create a new pool |
|
protected void |
destroyResource(K key,
KeyedResourcePool.Pool<V> resourcePool,
V resource)
|
|
int |
getBlockingGetsCount()
Count the total number of blocking gets across all pools. |
|
int |
getBlockingGetsCount(K key)
Count the number of blocking gets for a specific key. |
|
int |
getCheckedInResourceCount()
Count the total number of checked in (idle) resources across all pools. |
|
int |
getCheckedInResourcesCount(K key)
Count the number of checked in (idle) resources for a specific pool. |
|
protected KeyedResourcePool.Pool<V> |
getResourcePoolForExistingKey(K key)
Get the pool for the given key. |
|
protected KeyedResourcePool.Pool<V> |
getResourcePoolForKey(K key)
Get the pool for the given key. |
|
int |
getTotalResourceCount()
Count the total number of existing resources for all pools. |
|
int |
getTotalResourceCount(K key)
Count the number of existing resources for a specific pool. |
|
protected boolean |
internalClose()
|
|
protected boolean |
isOpenAndValid(K key,
V resource)
|
|
void |
reset(K key)
Reset a specific resource pool. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public KeyedResourcePool(ResourceFactory<K,V> objectFactory, ResourcePoolConfig resourcePoolConfig)
Method Detail |
---|
public static <K,V> KeyedResourcePool<K,V> create(ResourceFactory<K,V> factory, ResourcePoolConfig config)
K
- The type of the keysV
- The type of the valuesfactory
- The factory that creates objectsconfig
- The pool config
public static <K,V> KeyedResourcePool<K,V> create(ResourceFactory<K,V> factory)
K
- The type of the keysV
- The type of the valuesfactory
- The factory that creates objects
public V checkout(K key) throws java.lang.Exception
key
- The key to checkout the resource for
java.lang.Exception
protected V attemptNonBlockingCheckout(K key, KeyedResourcePool.Pool<V> pool) throws java.lang.Exception
java.lang.Exception
protected KeyedResourcePool.Pool<V> getResourcePoolForKey(K key)
protected KeyedResourcePool.Pool<V> getResourcePoolForExistingKey(K key)
protected void destroyResource(K key, KeyedResourcePool.Pool<V> resourcePool, V resource)
public void checkin(K key, V resource) throws java.lang.Exception
key
- The key for the resourceresource
- The resource
java.lang.Exception
protected boolean isOpenAndValid(K key, V resource) throws java.lang.Exception
java.lang.Exception
protected boolean internalClose()
public void close()
public void reset(K key)
key
- The key for the pool to reset.public int getTotalResourceCount(K key)
key
- The key
public int getTotalResourceCount()
public int getCheckedInResourcesCount(K key)
key
- The key
public int getCheckedInResourceCount()
public int getBlockingGetsCount(K key)
key
- The key
public int getBlockingGetsCount()
protected void checkNotClosed()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |