Java Driver 1.0 for Apache Cassandra

Connection options

There are three classes the driver uses to configure node connections.

Protocol options

Protocol options configure the port on which to connect to a Cassandra node and which type of compression to use.

Description

Protocol options
Option Description Default
port The port to connect to a Cassandra node on. 9042
compression What kind of compression to use when sending data to a node: either no compression or snappy. Snappy compression isoptimized for high speeds and reasonable compression. ProtocolOptions.Compression.NONE

Pooling options

The Java driver uses connections asynchronously, so multiple requests can be submitted on the same connection at the same time.

Description

The driver only needs to maintain a relatively small number of connections to each Cassandra host. These options allow you to control how many connections are kept exactly. The defaults should be fine for most applications.

Connection pooling options
Option Description Default value
coreConnectionsPerHost The core number of connections per host. 2 for HostDistance.LOCAL, 1 for HostDistance.REMOTE
maxConnectionPerHost The maximum number of connections per host. 8 for HostDistance.LOCAL, 2 for HostDistance.REMOTE
maxSimultaneousRequestsPerConnectionThreshold The number of simultaneous requests on all connections to an host after which more connections are created. 128
minSimultaneousRequestsPerConnectionThreshold The number of simultaneous requests on a connection below which connections in excess are reclaimed. 25

Socket options

Socket options configure the low-level sockets used to connect to nodes.

Description

All but one of these socket options comes from the Java runtime library's SocketOptions class. The connectTimeoutMillis option though is from Netty's ChannelConfig class.

Pooling options
Option Corresponds to Description
connectTimeoutMillis org.jboss.netty.channel.ChannelConfig "connectTineoutMillis" The connect timeout in milliseconds for the underlying Netty channel.
keepAlive java.net.SocketOptions.SO_KEEPALIVE  
receiveBufferSize java.net.SocketOptions.SO_RCVBUF A hint on the size of the buffer used to receive data.
reuseAddress java.net.SocketOptions.SO_REUSEADDR Whether to allow the same port to be bound to multiple times.
sendBufferSize java.net.SocketOptions.SO_SNDBUF A hint on the size of the buffer used to send data.
soLinger java.net.SocketOptions.SO_LINGER When specified, disables the immediate return from a call to close() on a TCP socket.
tcpNoDelay java.net.SocketOptions.TCPNODELAY Disables Nagle's algorithm on the underlying socket.
Show/hide