Package redis.clients.jedis.util
Class Pool<T>
- java.lang.Object
-
- redis.clients.jedis.util.Pool<T>
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
JedisPoolAbstract
,ShardedJedisPool
public abstract class Pool<T> extends Object implements Closeable
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.commons.pool2.impl.GenericObjectPool<T>
internalPool
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addObjects(int count)
void
close()
protected void
closeInternalPool()
void
destroy()
long
getMaxBorrowWaitTimeMillis()
Returns the maximum waiting time spent by threads to obtain a resource from this pool.long
getMeanBorrowWaitTimeMillis()
Returns the mean waiting time spent by threads to obtain a resource from this pool.int
getNumActive()
Returns the number of instances currently borrowed from this pool.int
getNumIdle()
Returns the number of instances currently idle in this pool.int
getNumWaiters()
Returns an estimate of the number of threads currently blocked waiting for a resource from this pool.T
getResource()
void
initPool(org.apache.commons.pool2.impl.GenericObjectPoolConfig poolConfig, org.apache.commons.pool2.PooledObjectFactory<T> factory)
boolean
isClosed()
protected void
returnBrokenResource(T resource)
protected void
returnBrokenResourceObject(T resource)
protected void
returnResource(T resource)
protected void
returnResourceObject(T resource)
-
-
-
Field Detail
-
internalPool
protected org.apache.commons.pool2.impl.GenericObjectPool<T> internalPool
-
-
Constructor Detail
-
Pool
public Pool()
Using this constructor means you have to set and initialize the internalPool yourself.
-
Pool
public Pool(org.apache.commons.pool2.impl.GenericObjectPoolConfig poolConfig, org.apache.commons.pool2.PooledObjectFactory<T> factory)
-
-
Method Detail
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
isClosed
public boolean isClosed()
-
initPool
public void initPool(org.apache.commons.pool2.impl.GenericObjectPoolConfig poolConfig, org.apache.commons.pool2.PooledObjectFactory<T> factory)
-
getResource
public T getResource()
-
returnResourceObject
protected void returnResourceObject(T resource)
-
returnBrokenResource
protected void returnBrokenResource(T resource)
-
returnResource
protected void returnResource(T resource)
-
destroy
public void destroy()
-
returnBrokenResourceObject
protected void returnBrokenResourceObject(T resource)
-
closeInternalPool
protected void closeInternalPool()
-
getNumActive
public int getNumActive()
Returns the number of instances currently borrowed from this pool.- Returns:
- The number of instances currently borrowed from this pool, -1 if the pool is inactive.
-
getNumIdle
public int getNumIdle()
Returns the number of instances currently idle in this pool.- Returns:
- The number of instances currently idle in this pool, -1 if the pool is inactive.
-
getNumWaiters
public int getNumWaiters()
Returns an estimate of the number of threads currently blocked waiting for a resource from this pool.- Returns:
- The number of threads waiting, -1 if the pool is inactive.
-
getMeanBorrowWaitTimeMillis
public long getMeanBorrowWaitTimeMillis()
Returns the mean waiting time spent by threads to obtain a resource from this pool.- Returns:
- The mean waiting time, in milliseconds, -1 if the pool is inactive.
-
getMaxBorrowWaitTimeMillis
public long getMaxBorrowWaitTimeMillis()
Returns the maximum waiting time spent by threads to obtain a resource from this pool.- Returns:
- The maximum waiting time, in milliseconds, -1 if the pool is inactive.
-
addObjects
public void addObjects(int count)
-
-