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 Exception
InterruptedException
public 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 Exception
InterruptedException
public void release(T element)
element
- the element to be returnedCopyright © 2017 The Apache Software Foundation. All rights reserved.