public class JPPFConnectionPool extends AbstractConnectionPool<JPPFClientConnection> implements Comparable<JPPFConnectionPool>
This connection pool also holds a pool of JMX connections to the same remote driver
Modifier and Type | Method and Description |
---|---|
JPPFClientConnection |
awaitActiveConnection()
Wait for the a connection to be in the
ACTIVE status. |
List<JPPFClientConnection> |
awaitActiveConnections(Operator operator,
int nbConnections)
Wait for the specified number of connections to be in the
ACTIVE status. |
JPPFClientConnection |
awaitConnection(JPPFClientConnectionStatus... statuses)
Wait for a connection to be in one of the specified states.
|
List<JPPFClientConnection> |
awaitConnections(Operator operator,
int nbConnections,
JPPFClientConnectionStatus... statuses)
Wait for the specified number of connections to be in one of the specified states.
|
List<JPPFClientConnection> |
awaitConnections(Operator 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.
|
JMXDriverConnectionWrapper |
awaitJMXConnection(boolean connectedOnly)
Wait a JMX connection to be in the specified state.
|
List<JMXDriverConnectionWrapper> |
awaitJMXConnections(Operator operator,
int nbConnections,
boolean connectedOnly)
Wait for the specified number of JMX connections to be in the specified state.
|
List<JMXDriverConnectionWrapper> |
awaitJMXConnections(Operator 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.
|
JPPFClientConnection |
awaitWorkingConnection()
|
List<JPPFClientConnection> |
awaitWorkingConnections(Operator operator,
int nbConnections)
|
JMXDriverConnectionWrapper |
awaitWorkingJMXConnection()
Wait an established JMX connection to be available.
|
void |
close() |
int |
compareTo(JPPFConnectionPool other)
Compares this connection pool with another, based on their respective priorities.
|
int |
connectionCount(JPPFClientConnectionStatus... statuses)
Get the number of connections in this pool that have one of the psecified statuses.
|
boolean |
equals(Object obj) |
JPPFClient |
getClient()
Get the JPPF client which holds this pool.
|
JPPFClientConnection |
getConnection()
Get the next connection that is connected and available.
|
List<JPPFClientConnection> |
getConnections(JPPFClientConnectionStatus... statuses)
Get a list of connections held by this pool whose status is one of the specified statuses.
|
String |
getDriverHost()
Get the host name of the remote driver.
|
String |
getDriverIPAddress()
Get the ip address of the remote driver.
|
int |
getDriverPort()
Get the port to use on the remote driver.
|
String |
getDriverUuid()
Get the uuid of the driver to which connections in this pool are connected.
|
int |
getId()
Get the id of this pool.
|
JMXDriverConnectionWrapper |
getJmxConnection()
Get a connected JMX connection among those in the JMX pool.
|
JMXDriverConnectionWrapper |
getJmxConnection(boolean connectedOnly)
Get a JMX connection among those in the JMX pool.
|
List<JMXDriverConnectionWrapper> |
getJMXConnections()
Get the list of connections currently in the JMX pool.
|
int |
getJMXPoolMaxSize()
Get the current maximum size of the associated JMX connection pool.
|
int |
getJmxPort()
Get the jmx port to use on the remote driver.
|
String |
getName()
Get the name of this pool.
|
int |
getPriority()
Get the priority associated with this pool.
|
JPPFSystemInformation |
getSystemInfo()
Get the driver's system information.
|
int |
hashCode() |
boolean |
isSslEnabled()
Check whether this pool is for SSL connections.
|
int |
setJMXPoolMaxSize(int maxSize)
Set a new maximum size for the associated pool of JMX connections, adding new or closing existing connections as needed.
|
int |
setSize(int newSize)
Set the size of this connection pool, starting or stopping connections as needed.
|
String |
toString() |
connectionCount, getConnections, getMaxSize, getSize, isEmpty, iterator, setMaxSize
public JPPFClientConnection getConnection()
ConnectionPool
getConnection
in interface ConnectionPool<JPPFClientConnection>
null
otherwise.public int connectionCount(JPPFClientConnectionStatus... statuses)
Warning: the execution time for this method is in O(n).
statuses
- the set of connection statuses to look for.public int getId()
public int getPriority()
public boolean isSslEnabled()
true
if SSL is enabled, false otherwise.public String getDriverUuid()
public int compareTo(JPPFConnectionPool other)
This comparison defines an ordering of connection pools by their descending priority.
compareTo
in interface Comparable<JPPFConnectionPool>
other
- the other connection pool to compare with.public int setSize(int newSize)
ConnectionPool
If any connection to be stopped is currently executing a job, then it will not be stopped.
setSize
in interface ConnectionPool<JPPFClientConnection>
newSize
- the max size as an int.public List<JPPFClientConnection> getConnections(JPPFClientConnectionStatus... statuses)
statuses
- an array of JPPFClientConnectionStatus
values to check against.JPPFClientConnection
instances, possibly empty but never null
.public List<JPPFClientConnection> awaitConnections(Operator operator, int nbConnections, long timeout, JPPFClientConnectionStatus... statuses)
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.JPPFClientConnection
instances, possibly less than the requested number if the timeout expired first.public String toString()
toString
in class AbstractConnectionPool<JPPFClientConnection>
public String getDriverHost()
public String getDriverIPAddress()
public int getDriverPort()
public JPPFClient getClient()
JPPFClient
instance.public JPPFSystemInformation getSystemInfo()
JPPFSystemInformation
.public int getJmxPort()
public JMXDriverConnectionWrapper getJmxConnection()
JMXDriverConnectionWrapper
instance, or null
if the JMX pool has no connected connection.public JMXDriverConnectionWrapper getJmxConnection(boolean connectedOnly)
connectedOnly
- specifies whether to get a connection in connected state only or in any state.JMXDriverConnectionWrapper
instance, or null
if the JMX pool has no connection in the specified state.public int getJMXPoolMaxSize()
public int setJMXPoolMaxSize(int maxSize)
maxSize
- the new maxsize to set.public List<JMXDriverConnectionWrapper> getJMXConnections()
JMXDriverConnectionWrapper
instances.public void close()
close
in interface AutoCloseable
close
in class AbstractConnectionPool<JPPFClientConnection>
public List<JPPFClientConnection> awaitActiveConnections(Operator operator, int nbConnections)
ACTIVE
status.
This is a shorthand for awaitConnections(nbConnections, Long.MAX_VALUE, JPPFClientConnectionStatus.ACTIVE)
.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.nbConnections
JPPFClientConnection
instances with the desired status.public JPPFClientConnection awaitActiveConnection()
ACTIVE
status.
This is a shorthand for awaitActiveConnections(Operator.AT_LEAST, 1).get(0)
.JPPFClientConnection
instances with the desired status.public List<JPPFClientConnection> awaitWorkingConnections(Operator operator, int nbConnections)
ACTIVE
or EXECUTING
status.
This is a shorthand for awaitConnections(nbConnections, Long.MAX_VALUE, JPPFClientConnectionStatus.ACTIVE, JPPFClientConnectionStatus.EXECUTING)
.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.nbConnections
JPPFClientConnection
instances with the desired status.public JPPFClientConnection awaitWorkingConnection()
ACTIVE
or EXECUTING
status.
This is a shorthand for awaitWorkingConnections(Operator.AT_LEAST, 1).get(0)
.nbConnections
JPPFClientConnection
instances with the desired status.public List<JPPFClientConnection> awaitConnections(Operator operator, int nbConnections, JPPFClientConnectionStatus... statuses)
awaitConnections(nbConnections, Long.MAX_VALUE, JPPFstatuses)
.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.nbConnections
JPPFClientConnection
instances.public JPPFClientConnection awaitConnection(JPPFClientConnectionStatus... statuses)
awaitConnections(Operator.AT_LEAST, 1, Long.MAX_VALUE, statuses).get(0)
.statuses
- the possible statuses of the connections to wait for.JPPFClientConnection
instance in one of the specified statuses.public List<JMXDriverConnectionWrapper> awaitJMXConnections(Operator operator, int nbConnections, boolean connectedOnly)
awaitJMXConnections(nbConnections, Long.MAX_VALUE, connectedOnly)
.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.nbConnections
JMXDriverConnectionWrapper
instances.public List<JMXDriverConnectionWrapper> awaitJMXConnections(Operator operator, int nbConnections, long timeout, boolean connectedOnly)
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.JMXDriverConnectionWrapper
instances, possibly less than the requested number if the timeout expired first.public JMXDriverConnectionWrapper awaitJMXConnection(boolean connectedOnly)
awaitJMXConnections(Operator.AT_LEAST, 1, connectedOnly).get(0)
.connectedOnly
- specifies whether to get a connection in connected state only or in any state.JMXDriverConnectionWrapper
instance in the specified connected state.public JMXDriverConnectionWrapper awaitWorkingJMXConnection()
awaitJMXConnections(Operator.AT_LEAST, 1, true).get(0)
.JMXDriverConnectionWrapper
instance.Copyright © 2005-2016 JPPF Team.