Class 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 Details

    • setSize

      public int setSize(int newSize)
      Description copied from interface: ConnectionPool
      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.

      Specified by:
      setSize in interface ConnectionPool<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:
      heartbeatConnectionFailed in interface org.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 the ACTIVE status. This is a shorthand for awaitConnections(nbConnections, Long.MAX_VALUE, JPPFClientConnectionStatus.ACTIVE).
      Parameters:
      operator - the condition on the number of connections to wait for. If null, it is assumed to be Operator.EQUAL.
      nbConnections - the expected number of connections to wait for.
      Returns:
      a list of nbConnections JPPFClientConnection instances with the desired status.
      Since:
      5.0
    • awaitActiveConnection

      public JPPFClientConnection awaitActiveConnection()
      Wait for the a connection to be in the ACTIVE status. This is a shorthand for awaitActiveConnections(Operator.AT_LEAST, 1).get(0).
      Returns:
      a JPPFClientConnection instances 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 the ACTIVE or EXECUTING status. This is a shorthand for awaitConnections(nbConnections, Long.MAX_VALUE, JPPFClientConnectionStatus.ACTIVE, JPPFClientConnectionStatus.EXECUTING).
      Parameters:
      operator - the condition on the number of connections to wait for. If null, it is assumed to be Operator.EQUAL.
      nbConnections - the number of connections to wait for.
      Returns:
      a list of nbConnections JPPFClientConnection instances with the desired status.
      Since:
      5.0
    • awaitWorkingConnection

      public JPPFClientConnection awaitWorkingConnection()
      Wait for a connection to be in the ACTIVE or EXECUTING status. This is a shorthand for awaitWorkingConnections(Operator.AT_LEAST, 1).get(0).
      Returns:
      a list of nbConnections JPPFClientConnection instances 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 for awaitConnections(nbConnections, Long.MAX_VALUE, JPPFstatuses).
      Parameters:
      operator - the condition on the number of connections to wait for. If null, it is assumed to be Operator.EQUAL.
      nbConnections - the number of connections to wait for.
      statuses - the possible statuses of the connections to wait for.
      Returns:
      a list of nbConnections JPPFClientConnection instances.
      Since:
      5.0
    • awaitConnection

      public JPPFClientConnection awaitConnection(JPPFClientConnectionStatus... statuses)
      Wait for a connection to be in one of the specified states. This is a shorthand for awaitConnections(Operator.AT_LEAST, 1, Long.MAX_VALUE, statuses).get(0).
      Parameters:
      statuses - the possible statuses of the connections to wait for.
      Returns:
      a JPPFClientConnection instance 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. If null, it is assumed to be Operator.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 JPPFClientConnection instances, 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 for awaitJMXConnections(nbConnections, Long.MAX_VALUE, connectedOnly).
      Parameters:
      operator - the condition on the number of connections to wait for. If null, it is assumed to be Operator.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 nbConnections JMXDriverConnectionWrapper instances.
      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. If null, it is assumed to be Operator.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 JMXDriverConnectionWrapper instances, 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 for awaitJMXConnections(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 JMXDriverConnectionWrapper instance 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 for awaitJMXConnections(Operator.AT_LEAST, 1, true).get(0).
      Returns:
      a connected JMXDriverConnectionWrapper instance.
      Since:
      5.1
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Overrides:
      close in class AbstractClientConnectionPool
    • toString

      public String toString()
      Overrides:
      toString in class AbstractConnectionPool<JPPFClientConnection>