voldemort.utils.pool
Class ResourcePoolConfig

java.lang.Object
  extended by voldemort.utils.pool.ResourcePoolConfig

public class ResourcePoolConfig
extends java.lang.Object

Resource pool config class.


Constructor Summary
ResourcePoolConfig()
           
 
Method Summary
 int getMaximumInvalidResourceCreationLimit()
          Get the maximum number of invalid resources that can be created before throwing an exception.
 int getMaxPoolSize()
          Get the size of the pool
 long getTimeout(java.util.concurrent.TimeUnit unit)
          Get the the pool timeout in the given units
 boolean isFair()
          Controls whether the pool gives resources to threads in the order they arrive or not
 ResourcePoolConfig setIsFair(boolean isFair)
          Controls whether the pool gives resources to threads in the order they arrive or not.
 ResourcePoolConfig setMaxInvalidAttempts(int limit)
          The maximum number of successive invalid resources that can be created in a single checkout.
 ResourcePoolConfig setMaxPoolSize(int poolSize)
          The size of the pool to maintain for each key.
 ResourcePoolConfig setTimeout(long timeout, java.util.concurrent.TimeUnit unit)
          The timeout which we block for when a resource is not available
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourcePoolConfig

public ResourcePoolConfig()
Method Detail

getMaxPoolSize

public int getMaxPoolSize()
Get the size of the pool


setMaxPoolSize

public ResourcePoolConfig setMaxPoolSize(int poolSize)
The size of the pool to maintain for each key. The default pool size is 20

Parameters:
poolSize - The desired per-key pool size

getTimeout

public long getTimeout(java.util.concurrent.TimeUnit unit)
Get the the pool timeout in the given units

Parameters:
unit - The units in which to fetch the timeout
Returns:
The timeout

setTimeout

public ResourcePoolConfig setTimeout(long timeout,
                                     java.util.concurrent.TimeUnit unit)
The timeout which we block for when a resource is not available

Parameters:
timeout - The timeout
unit - The units of the timeout

setMaxInvalidAttempts

public ResourcePoolConfig setMaxInvalidAttempts(int limit)
The maximum number of successive invalid resources that can be created in a single checkout. The purpose of this parameter is to avoid churning the created objects in the case that the created object is immediately invalid. Default is unlimited.

Parameters:
limit - The desired limit

getMaximumInvalidResourceCreationLimit

public int getMaximumInvalidResourceCreationLimit()
Get the maximum number of invalid resources that can be created before throwing an exception.


isFair

public boolean isFair()
Controls whether the pool gives resources to threads in the order they arrive or not


setIsFair

public ResourcePoolConfig setIsFair(boolean isFair)
Controls whether the pool gives resources to threads in the order they arrive or not. An unfair pool is approximately 10x faster, but gives not guarantee on the order in which waiting threads get a resource.



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