Package org.jppf.client
Class JPPFConnectionPool
java.lang.Object
org.jppf.client.AbstractConnectionPool<JPPFClientConnection>
org.jppf.client.AbstractClientConnectionPool
org.jppf.client.JPPFConnectionPool
- All Implemented Interfaces:
AutoCloseable,Comparable<AbstractClientConnectionPool>,Iterable<JPPFClientConnection>,EventListener,ConnectionPool<JPPFClientConnection>,org.jppf.comm.recovery.HeartbeatConnectionListener
public class JPPFConnectionPool
extends AbstractClientConnectionPool
implements org.jppf.comm.recovery.HeartbeatConnectionListener
Instances of this class manage a list of client connections with the same pool name, priority and remote driver.
This connection pool also holds a pool of JMX connections to the same remote driver
- Since:
- 4.1
-
Method Summary
Modifier and TypeMethodDescriptionWait for the a connection to be in theACTIVEstatus.awaitActiveConnections(org.jppf.utils.ComparisonOperator operator, int nbConnections) Wait for the specified number of connections to be in theACTIVEstatus.awaitConnection(JPPFClientConnectionStatus... statuses) Wait for a connection to be in one of the specified states.awaitConnections(org.jppf.utils.ComparisonOperator operator, int nbConnections, long timeout, JPPFClientConnectionStatus... statuses) Wait for the specified number of connections to be in one of the specified states, or the specified timeout to expire, whichever happens first.awaitConnections(org.jppf.utils.ComparisonOperator operator, int nbConnections, JPPFClientConnectionStatus... statuses) Wait for the specified number of connections to be in one of the specified states.org.jppf.management.JMXDriverConnectionWrapperawaitJMXConnection(boolean connectedOnly) Wait a JMX connection to be in the specified state.List<org.jppf.management.JMXDriverConnectionWrapper>awaitJMXConnections(org.jppf.utils.ComparisonOperator operator, int nbConnections, boolean connectedOnly) Wait for the specified number of JMX connections to be in the specified state.List<org.jppf.management.JMXDriverConnectionWrapper>awaitJMXConnections(org.jppf.utils.ComparisonOperator operator, int nbConnections, long timeout, boolean connectedOnly) Wait for the specified number of JMX connections to be in the specified state, or the specified timeout to expire, whichever happens first.awaitWorkingConnections(org.jppf.utils.ComparisonOperator operator, int nbConnections) org.jppf.management.JMXDriverConnectionWrapperWait an established JMX connection to be available.voidclose()voidheartbeatConnectionFailed(org.jppf.comm.recovery.HeartbeatConnectionEvent event) intsetSize(int newSize) Set the size of this connection pool, starting or stopping connections as needed.toString()Methods inherited from class org.jppf.client.AbstractClientConnectionPool
compareTo, connectionCount, equals, getClient, getConnection, getConnections, getDriverHost, getDriverIPAddress, getDriverPort, getDriverUuid, getId, getJmxConnection, getJmxConnection, getJMXConnections, getJMXPoolMaxSize, getJMXPoolSize, getJmxPort, getMaxJobs, getName, getPriority, getSystemInfo, hashCode, isSslEnabled, setJMXPoolMaxSize, setJMXPoolSize, setMaxJobsMethods inherited from class org.jppf.client.AbstractConnectionPool
add, connectionCount, getConnections, getSize, isEmpty, iterator, nextConnection, removeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
setSize
public int setSize(int newSize) Description copied from interface:ConnectionPoolSet 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.
- Specified by:
setSizein interfaceConnectionPool<JPPFClientConnection>- Parameters:
newSize- the max size as an int.- Returns:
- the new maximum pool size.
-
heartbeatConnectionFailed
public void heartbeatConnectionFailed(org.jppf.comm.recovery.HeartbeatConnectionEvent event) - Specified by:
heartbeatConnectionFailedin interfaceorg.jppf.comm.recovery.HeartbeatConnectionListener
-
awaitActiveConnections
public List<JPPFClientConnection> awaitActiveConnections(org.jppf.utils.ComparisonOperator operator, int nbConnections) Wait for the specified number of connections to be in theACTIVEstatus. This is a shorthand forawaitConnections(nbConnections, Long.MAX_VALUE, JPPFClientConnectionStatus.ACTIVE).- Parameters:
operator- the condition on the number of connections to wait for. Ifnull, it is assumed to beOperator.EQUAL.nbConnections- the expected number of connections to wait for.- Returns:
- a list of
nbConnectionsJPPFClientConnectioninstances with the desired status. - Since:
- 5.0
-
awaitActiveConnection
Wait for the a connection to be in theACTIVEstatus. This is a shorthand forawaitActiveConnections(Operator.AT_LEAST, 1).get(0).- Returns:
- a
JPPFClientConnectioninstances with the desired status. - Since:
- 5.1
-
awaitWorkingConnections
public List<JPPFClientConnection> awaitWorkingConnections(org.jppf.utils.ComparisonOperator operator, int nbConnections) Wait for the specified number of connections to be in theACTIVEorEXECUTINGstatus. This is a shorthand forawaitConnections(nbConnections, Long.MAX_VALUE, JPPFClientConnectionStatus.ACTIVE, JPPFClientConnectionStatus.EXECUTING).- Parameters:
operator- the condition on the number of connections to wait for. Ifnull, it is assumed to beOperator.EQUAL.nbConnections- the number of connections to wait for.- Returns:
- a list of
nbConnectionsJPPFClientConnectioninstances with the desired status. - Since:
- 5.0
-
awaitWorkingConnection
Wait for a connection to be in theACTIVEorEXECUTINGstatus. This is a shorthand forawaitWorkingConnections(Operator.AT_LEAST, 1).get(0).- Returns:
- a list of
nbConnectionsJPPFClientConnectioninstances with the desired status. - Since:
- 5.0
-
awaitConnections
public List<JPPFClientConnection> awaitConnections(org.jppf.utils.ComparisonOperator operator, int nbConnections, JPPFClientConnectionStatus... statuses) Wait for the specified number of connections to be in one of the specified states. This is a shorthand forawaitConnections(nbConnections, Long.MAX_VALUE, JPPFstatuses).- Parameters:
operator- the condition on the number of connections to wait for. Ifnull, it is assumed to beOperator.EQUAL.nbConnections- the number of connections to wait for.statuses- the possible statuses of the connections to wait for.- Returns:
- a list of
nbConnectionsJPPFClientConnectioninstances. - Since:
- 5.0
-
awaitConnection
Wait for a connection to be in one of the specified states. This is a shorthand forawaitConnections(Operator.AT_LEAST, 1, Long.MAX_VALUE, statuses).get(0).- Parameters:
statuses- the possible statuses of the connections to wait for.- Returns:
- a
JPPFClientConnectioninstance in one of the specified statuses. - Since:
- 5.1
-
awaitConnections
public List<JPPFClientConnection> awaitConnections(org.jppf.utils.ComparisonOperator operator, int nbConnections, long timeout, JPPFClientConnectionStatus... statuses) Wait for the specified number of connections to be in one of the specified states, or the specified timeout to expire, whichever happens first. This method will increase or decrease the number of connections in this pool as needed.- Parameters:
operator- the condition on the number of connections to wait for. Ifnull, it is assumed to beOperator.EQUAL.nbConnections- the number of connections to wait for.timeout- the maximum time to wait, in milliseconds.statuses- the possible statuses of the connections to wait for.- Returns:
- a list of
JPPFClientConnectioninstances, possibly less than the requested number if the timeout expired first. - Since:
- 5.0
-
awaitJMXConnections
public List<org.jppf.management.JMXDriverConnectionWrapper> awaitJMXConnections(org.jppf.utils.ComparisonOperator operator, int nbConnections, boolean connectedOnly) Wait for the specified number of JMX connections to be in the specified state. This is a shorthand forawaitJMXConnections(nbConnections, Long.MAX_VALUE, connectedOnly).- Parameters:
operator- the condition on the number of connections to wait for. Ifnull, it is assumed to beOperator.EQUAL.nbConnections- the number of connections to wait for.connectedOnly- specifies whether to get a connection in connected state only or in any state.- Returns:
- a list of at least
nbConnectionsJMXDriverConnectionWrapperinstances. - Since:
- 5.0
-
awaitJMXConnections
public List<org.jppf.management.JMXDriverConnectionWrapper> awaitJMXConnections(org.jppf.utils.ComparisonOperator operator, int nbConnections, long timeout, boolean connectedOnly) Wait for the specified number of JMX connections to be in the specified state, or the specified timeout to expire, whichever happens first.- Parameters:
operator- the condition on the number of connections to wait for. Ifnull, it is assumed to beOperator.EQUAL.nbConnections- the number of connections to wait for.timeout- the maximum time to wait, in milliseconds.connectedOnly- specifies whether to get a connection in connected state only or in any state.- Returns:
- a list of
JMXDriverConnectionWrapperinstances, possibly less than the requested number if the timeout expired first. - Since:
- 5.0
-
awaitJMXConnection
public org.jppf.management.JMXDriverConnectionWrapper awaitJMXConnection(boolean connectedOnly) Wait a JMX connection to be in the specified state. This is a shorthand forawaitJMXConnections(Operator.AT_LEAST, 1, connectedOnly).get(0).- Parameters:
connectedOnly- specifies whether to get a connection in connected state only or in any state.- Returns:
- a
JMXDriverConnectionWrapperinstance in the specified connected state. - Since:
- 5.1
-
awaitWorkingJMXConnection
public org.jppf.management.JMXDriverConnectionWrapper awaitWorkingJMXConnection()Wait an established JMX connection to be available. This is a shorthand forawaitJMXConnections(Operator.AT_LEAST, 1, true).get(0).- Returns:
- a connected
JMXDriverConnectionWrapperinstance. - Since:
- 5.1
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Overrides:
closein classAbstractClientConnectionPool
-
toString
- Overrides:
toStringin classAbstractConnectionPool<JPPFClientConnection>
-