Package org.jppf.client
Interface ConnectionPool<E extends AutoCloseable>
- Type Parameters:
E- the type of the connections in the pool.
- All Superinterfaces:
AutoCloseable,Iterable<E>
- All Known Implementing Classes:
AbstractClientConnectionPool,AbstractConnectionPool,JPPFConnectionPool
Interface for pools of connections with a maximum size which can be dynamically updated.
- Since:
- 4.2
- Author:
- Laurent Cohen
-
Method Summary
Modifier and TypeMethodDescriptionbooleanAdd a connection to this pool.intGet the current size of this pool.Get the next connection that is connected and available.Get a list of connections held by this pool.intgetSize()Get the maximum size of this connection pool.booleanisEmpty()Determine whether this pool is empty.Get the next connection.booleanRemove a connection from this pool.intsetSize(int maxSize) Set the size of this connection pool, starting or stopping connections as needed.Methods inherited from interface java.lang.AutoCloseable
closeMethods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
add
Add a connection to this pool.- Parameters:
connection- the connection too add.- Returns:
- true if the underlying list of connections changed as a result of calling this method.
-
remove
Remove a connection from this pool.- Parameters:
connection- the connection too remove.- Returns:
- true if the underlying list of connections changed as a result of calling this method.
-
nextConnection
E nextConnection()Get the next connection.- Returns:
- a connection.
-
getConnection
E getConnection()Get the next connection that is connected and available.- Returns:
- a connection object if one is found in the desired state, or
nullotherwise.
-
isEmpty
boolean isEmpty()Determine whether this pool is empty.- Returns:
trueif this pool is empty,falseotherwise.
-
connectionCount
int connectionCount()Get the current size of this pool.- Returns:
- the size as an int.
-
getSize
int getSize()Get the maximum size of this connection pool.- Returns:
- the max size as an int.
-
setSize
int setSize(int maxSize) Set the size of this connection pool, starting or stopping connections as needed.If any connection to be stopped is currently executing a job, then it will not be stopped.
- Parameters:
maxSize- the max size as an int.- Returns:
- the new maximum pool size.
-
getConnections
Get a list of connections held by this pool. The returned list is independent from this pool, thus changing, adding or removing elements has not effect on the pool.- Returns:
- a list of
JPPFClientConnectioninstances.
-