|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.datastax.driver.core.SocketOptions
public class SocketOptions
Options to configure low-level socket options for the connections kept to the Cassandra hosts.
Field Summary | |
---|---|
static int |
DEFAULT_CONNECT_TIMEOUT_MILLIS
The default connection timeout in milliseconds if none is set explicitly using setConnectTimeoutMillis(int) . |
static int |
DEFAULT_READ_TIMEOUT_MILLIS
The default read timeout in milliseconds if none is set explicitly using setReadTimeoutMillis(int) . |
Constructor Summary | |
---|---|
SocketOptions()
Creates a new SocketOptions instance with default values. |
Method Summary | |
---|---|
int |
getConnectTimeoutMillis()
The connection timeout in milliseconds. |
Boolean |
getKeepAlive()
|
int |
getReadTimeoutMillis()
The per-host read timeout in milliseconds. |
Integer |
getReceiveBufferSize()
|
Boolean |
getReuseAddress()
|
Integer |
getSendBufferSize()
|
Integer |
getSoLinger()
|
Boolean |
getTcpNoDelay()
|
SocketOptions |
setConnectTimeoutMillis(int connectTimeoutMillis)
Sets the connection timeout in milliseconds. |
SocketOptions |
setKeepAlive(boolean keepAlive)
|
SocketOptions |
setReadTimeoutMillis(int readTimeoutMillis)
Sets the per-host read timeout in milliseconds. |
SocketOptions |
setReceiveBufferSize(int receiveBufferSize)
|
SocketOptions |
setReuseAddress(boolean reuseAddress)
|
SocketOptions |
setSendBufferSize(int sendBufferSize)
|
SocketOptions |
setSoLinger(int soLinger)
|
SocketOptions |
setTcpNoDelay(boolean tcpNoDelay)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_CONNECT_TIMEOUT_MILLIS
setConnectTimeoutMillis(int)
.
That default is of 5 seconds.
public static final int DEFAULT_READ_TIMEOUT_MILLIS
setReadTimeoutMillis(int)
.
That default is of 12 seconds so as to be slightly bigger that the default Cassandra timeout.
for more details on this timeout.
,
Constant Field ValuesConstructor Detail |
---|
public SocketOptions()
SocketOptions
instance with default values.
Method Detail |
---|
public int getConnectTimeoutMillis()
As the name implies, the connection timeout defines how long the driver waits to etablish a new connection to a Cassandra node before giving up.
public SocketOptions setConnectTimeoutMillis(int connectTimeoutMillis)
connectTimeoutMillis
- the timeout to set.
SocketOptions
.public int getReadTimeoutMillis()
This defines how long the driver will wait for a given Cassandra node to answer a query.
Please note that this is not the maximum time a call to Session.execute(java.lang.String)
may block;
this is the maximum time that call will wait for one particular
Cassandra host, but other hosts will be tried if one of them timeout. In
other words, a Session.execute(java.lang.String)
call may theoretically wait up to
getReadTimeoutMillis() * <number_of_cassandra_hosts>
(though the
total number of hosts tried for a given query also depends on the
LoadBalancingPolicy
in use).
If you want to control how long to wait for a query, use Session.executeAsync(java.lang.String)
and the ResultSetFuture#get(long, TimeUnit)
method.
Also note that for efficiency reasons, this read timeout is approximate: it has an accuracy of up to 100 milliseconds (i.e. it may fire up to 100 milliseconds late). It is not meant to be used for precise timeout, but rather as a protection against misbehaving Cassandra nodes.
public SocketOptions setReadTimeoutMillis(int readTimeoutMillis)
When setting this value, keep in mind the following:
*_request_timeout_in_ms
in cassandra.yaml
) should be taken into account when picking a value for this
read timeout. In particular, if this read timeout option is lower than Cassandra's
timeout, the driver will try another host before it has had the time to receive the
Cassandra timeout. This might be counter-productive.getReadTimeoutMillis()
for more details). If a
high level of precision on the timeout to a request is required, you should use
the AbstractFuture.get(long, TimeUnit)
method.
Setting a value of 0 disables read timeouts.
readTimeoutMillis
- the timeout to set.
SocketOptions
.public Boolean getKeepAlive()
public SocketOptions setKeepAlive(boolean keepAlive)
public Boolean getReuseAddress()
public SocketOptions setReuseAddress(boolean reuseAddress)
public Integer getSoLinger()
public SocketOptions setSoLinger(int soLinger)
public Boolean getTcpNoDelay()
public SocketOptions setTcpNoDelay(boolean tcpNoDelay)
public Integer getReceiveBufferSize()
public SocketOptions setReceiveBufferSize(int receiveBufferSize)
public Integer getSendBufferSize()
public SocketOptions setSendBufferSize(int sendBufferSize)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |