|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.datastax.driver.core.PoolingOptions
public class PoolingOptions
Options related to connection pooling.
The driver uses connections in an asynchronous way. Meaning that multiple requests can be submitted on the same connection at the same time. This means that the driver only needs to maintain a relatively small number of connections to each Cassandra host. These options allow to control how many connections are kept exactly.
For each host, the driver keeps a core amount of connections open at all
time (getCoreConnectionsPerHost(com.datastax.driver.core.HostDistance)
). If the
utilisation of those connections reaches a configurable threshold
(getMaxSimultaneousRequestsPerConnectionTreshold(com.datastax.driver.core.HostDistance)
),
more connections are created up to a configurable maximum number of
connections (getMaxConnectionPerHost(com.datastax.driver.core.HostDistance)
). Once more
than core connections have been created, connections in excess are
reclaimed if the utilisation of opened connections drops below the
configured threshold (getMinSimultaneousRequestsPerConnectionTreshold(com.datastax.driver.core.HostDistance)
).
Each of these parameters can be separately set for LOCAL
and
REMOTE
hosts (HostDistance
). For IGNORED
hosts,
the default for all those settings is 0 and cannot be changed.
Constructor Summary | |
---|---|
PoolingOptions()
|
Method Summary | |
---|---|
int |
getCoreConnectionsPerHost(HostDistance distance)
The core number of connections per host. |
int |
getMaxConnectionPerHost(HostDistance distance)
The maximum number of connections per host. |
int |
getMaxSimultaneousRequestsPerConnectionTreshold(HostDistance distance)
Number of simultaneous requests on all connections to an host after which more connections are created. |
int |
getMinSimultaneousRequestsPerConnectionTreshold(HostDistance distance)
Number of simultaneous requests on a connection below which connections in excess are reclaimed. |
PoolingOptions |
setCoreConnectionsPerHost(HostDistance distance,
int coreConnections)
Sets the core number of connections per host. |
PoolingOptions |
setMaxConnectionsPerHost(HostDistance distance,
int maxConnections)
Sets the maximum number of connections per host. |
PoolingOptions |
setMaxSimultaneousRequestsPerConnectionTreshold(HostDistance distance,
int maxSimultaneousRequests)
Sets number of simultaneous requests on all connections to an host after which more connections are created. |
PoolingOptions |
setMinSimultaneousRequestsPerConnectionTreshold(HostDistance distance,
int minSimultaneousRequests)
Sets the number of simultaneous requests on a connection below which connections in excess are reclaimed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PoolingOptions()
Method Detail |
---|
public int getMinSimultaneousRequestsPerConnectionTreshold(HostDistance distance)
If an opened connection to an host at distance distance
handles less than this number of simultaneous requests and there is
more than getCoreConnectionsPerHost(com.datastax.driver.core.HostDistance)
connections open to this
host, the connection is closed.
The default value for this option is 25 for LOCAL
and
REMOTE
hosts.
distance
- the HostDistance
for which to return this threshold.
public PoolingOptions setMinSimultaneousRequestsPerConnectionTreshold(HostDistance distance, int minSimultaneousRequests)
distance
- the HostDistance
for which to configure this threshold.minSimultaneousRequests
- the value to set.
PoolingOptions
.
IllegalArgumentException
- if distance == HostDistance.IGNORED
.public int getMaxSimultaneousRequestsPerConnectionTreshold(HostDistance distance)
If all the connections opened to an host at distance distance
connection are handling more than this number of
simultaneous requests and there is less than
getMaxConnectionPerHost(com.datastax.driver.core.HostDistance)
connections open to this host, a
new connection is open.
Note that a given connection cannot handle more than 128 simultaneous requests (protocol limitation).
The default value for this option is 100 for LOCAL
and
REMOTE
hosts.
distance
- the HostDistance
for which to return this threshold.
public PoolingOptions setMaxSimultaneousRequestsPerConnectionTreshold(HostDistance distance, int maxSimultaneousRequests)
distance
- the HostDistance
for which to configure this threshold.maxSimultaneousRequests
- the value to set.
PoolingOptions
.
IllegalArgumentException
- if distance == HostDistance.IGNORED
.public int getCoreConnectionsPerHost(HostDistance distance)
For the provided distance
, this correspond to the number of
connections initially created and kept open to each host of that
distance.
distance
- the HostDistance
for which to return this threshold.
distance
.public PoolingOptions setCoreConnectionsPerHost(HostDistance distance, int coreConnections)
distance
- the HostDistance
for which to set this threshold.coreConnections
- the value to set
PoolingOptions
.
IllegalArgumentException
- if distance == HostDistance.IGNORED
.public int getMaxConnectionPerHost(HostDistance distance)
For the provided distance
, this correspond to the maximum
number of connections that can be created per host at that distance.
distance
- the HostDistance
for which to return this threshold.
distance
.public PoolingOptions setMaxConnectionsPerHost(HostDistance distance, int maxConnections)
distance
- the HostDistance
for which to set this threshold.maxConnections
- the value to set
PoolingOptions
.
IllegalArgumentException
- if distance == HostDistance.IGNORED
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |