T - the type of the elementsE - the type of exception thrown by create()public abstract class ElasticPool<T,E extends Exception> extends Object
| Constructor and Description |
|---|
ElasticPool(int sizeLimit) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract T |
create()
A method to create a new element.
|
T |
obtain()
Get a element from the pool.
|
T |
obtain(long timeout,
TimeUnit unit)
Get a element from the pool.
|
protected boolean |
recycle(T element)
A method to recycle an existing element when it is returned to the pool.
|
void |
release(T element)
Returns an element to the pool of available elements.
|
protected abstract T create() throws E extends Exception
protected boolean recycle(T element)
element - the element to recyclepublic T obtain() throws E extends Exception, InterruptedException
E extends ExceptionInterruptedExceptionpublic T obtain(long timeout, TimeUnit unit) throws E extends Exception, TimeoutException, InterruptedException
timeout - the timeout for trying to obtain an elementunit - the timeout unit for trying to obtain an elementTimeoutException - if a client is not able to be obtained within the given timeoutE extends ExceptionInterruptedExceptionpublic void release(T element)
element - the element to be returnedCopyright © 2016 The Apache Software Foundation. All rights reserved.