voldemort.utils.pool
Class KeyedResourcePool.Pool<V>

java.lang.Object
  extended by voldemort.utils.pool.KeyedResourcePool.Pool<V>
Enclosing class:
KeyedResourcePool<K,V>

protected static class KeyedResourcePool.Pool<V>
extends java.lang.Object

A fixed size pool that uses an ArrayBlockingQueue. The pool grows to no more than some specified maxPoolSize. The pool creates new resources in the face of existing resources being destroyed.


Constructor Summary
KeyedResourcePool.Pool(ResourcePoolConfig resourcePoolConfig)
           
 
Method Summary
<K> boolean
attemptGrow(K key, ResourceFactory<K,V> objectFactory)
          If there is room in the pool, attempt to to create a new resource and add it to the pool.
 V blockingGet(long timeoutNs)
           
 java.util.List<V> close()
           
 V nonBlockingGet()
           
 boolean nonBlockingPut(V v)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyedResourcePool.Pool

public KeyedResourcePool.Pool(ResourcePoolConfig resourcePoolConfig)
Method Detail

attemptGrow

public <K> boolean attemptGrow(K key,
                               ResourceFactory<K,V> objectFactory)
                    throws java.lang.Exception
If there is room in the pool, attempt to to create a new resource and add it to the pool. This method is cheap to call even if the pool is full (i.e., the first thing it does is looks a the current size of the pool relative to the max pool size.

Parameters:
key -
objectFactory -
Returns:
True if and only if a resource was successfully added to the pool.
Throws:
java.lang.Exception - if there are issues creating a new object, or destroying newly created object that could not be added to the pool.

nonBlockingGet

public V nonBlockingGet()

blockingGet

public V blockingGet(long timeoutNs)
              throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

nonBlockingPut

public boolean nonBlockingPut(V v)

close

public java.util.List<V> close()


Jay Kreps, Roshan Sumbaly, Alex Feinberg, Bhupesh Bansal, Lei Gao, Chinmay Soman, Vinoth Chandar, Zhongjie Wu