|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectredis.clients.util.FixedResourcePool<T>
T
- The type of the resource to be managed.public abstract class FixedResourcePool<T>
Abstract resource pool of type T. Needs implementation for creation, validation and destruction of the resources. Keeps a fixed amount of resources
Nested Class Summary | |
---|---|
static class |
FixedResourcePool.Metrics
|
protected class |
FixedResourcePool.RepairThread
Generic Repair Thread |
Constructor Summary | |
---|---|
FixedResourcePool()
|
Method Summary | |
---|---|
protected void |
checkInit()
|
protected abstract T |
createResource()
Create a resource for the pool. |
void |
destroy()
Destroy the pool. |
protected abstract void |
destroyResource(T resource)
Destroy a resource. |
long |
getDefaultPoolWait()
|
long |
getDestructionWait()
|
String |
getName()
|
int |
getRepairThreadsNumber()
|
T |
getResource()
Get a resource from the pool waiting the default time. |
T |
getResource(long maxTime)
Get a resource from the pool. |
int |
getResourcesNumber()
|
long |
getTimeBetweenValidation()
|
void |
init()
Initialize the pool |
protected abstract boolean |
isResourceValid(T resource)
Check if the resource is still valid. |
void |
returnBrokenResource(T resource)
Return a broken resource to the pool. |
void |
returnResource(T resource)
Return a resource to the pool. |
void |
setDefaultPoolWait(long defaultPoolWait)
|
void |
setDestructionWait(long destructionWait)
|
void |
setName(String name)
|
void |
setRepairThreadsNumber(int repairThreadsNumber)
|
void |
setResourcesNumber(int resourcesNumber)
|
void |
setTimeBetweenValidation(long timeBetweenValidation)
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FixedResourcePool()
Method Detail |
---|
public int getResourcesNumber()
public void setResourcesNumber(int resourcesNumber)
public int getRepairThreadsNumber()
public void setRepairThreadsNumber(int repairThreadsNumber)
public long getTimeBetweenValidation()
public void setTimeBetweenValidation(long timeBetweenValidation)
public long getDestructionWait()
public void setDestructionWait(long destructionWait)
public void setName(String name)
public String getName()
public void setDefaultPoolWait(long defaultPoolWait)
public long getDefaultPoolWait()
public void init()
public void destroy()
protected void checkInit()
public void returnResource(T resource)
resource
- public void returnBrokenResource(T resource)
resource
- public T getResource() throws TimeoutException
setDefaultPoolWait(long)
TimeoutException
public T getResource(long maxTime) throws TimeoutException
maxTime
- Max time you would like to wait for the resource
TimeoutException
protected abstract T createResource()
protected abstract boolean isResourceValid(T resource)
resource
-
protected abstract void destroyResource(T resource)
resource
- public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |