com.datastax.driver.core
Class ProtocolOptions

java.lang.Object
  extended by com.datastax.driver.core.ProtocolOptions

public class ProtocolOptions
extends Object

Options of the Cassandra native binary protocol.


Nested Class Summary
static class ProtocolOptions.Compression
          Compression supported by the Cassandra binary protocol.
 
Field Summary
static int DEFAULT_PORT
          The default port for Cassandra native binary protocol: 9042.
 
Constructor Summary
ProtocolOptions()
          Creates a new ProtocolOptions instance using the DEFAULT_PORT (and without SSL).
ProtocolOptions(int port)
          Creates a new ProtocolOptions instance using the provided port (without SSL nor authentication).
ProtocolOptions(int port, int protocolVersion, SSLOptions sslOptions, AuthProvider authProvider)
          Creates a new ProtocolOptions instance using the provided port and SSL context.
 
Method Summary
 AuthProvider getAuthProvider()
          The AuthProvider used by this cluster.
 ProtocolOptions.Compression getCompression()
          Returns the compression used by the protocol.
 int getPort()
          Returns the port used to connect to the Cassandra hosts.
 int getProtocolVersion()
          The protocol version used by the Cluster instance.
 SSLOptions getSSLOptions()
          The SSLOptions used by this cluster.
 ProtocolOptions setCompression(ProtocolOptions.Compression compression)
          Sets the compression to use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PORT

public static final int DEFAULT_PORT
The default port for Cassandra native binary protocol: 9042.

See Also:
Constant Field Values
Constructor Detail

ProtocolOptions

public ProtocolOptions()
Creates a new ProtocolOptions instance using the DEFAULT_PORT (and without SSL).


ProtocolOptions

public ProtocolOptions(int port)
Creates a new ProtocolOptions instance using the provided port (without SSL nor authentication).

This is a shortcut for new ProtocolOptions(port, null, AuthProvider.NONE).

Parameters:
port - the port to use for the binary protocol.

ProtocolOptions

public ProtocolOptions(int port,
                       int protocolVersion,
                       SSLOptions sslOptions,
                       AuthProvider authProvider)
Creates a new ProtocolOptions instance using the provided port and SSL context.

Parameters:
port - the port to use for the binary protocol.
protocolVersion - the protocol version to use. This can be a negative number, in which case the version uses will be the biggest version supported by the first node the driver connects to. Otherwise, it must be either 1 or 2 to force using a particular protocol version. See Cluster.Builder.withProtocolVersion(int) for more details.
sslOptions - the SSL options to use. Use null if SSL is not to be used.
authProvider - the AuthProvider to use for authentication against the Cassandra nodes.
Method Detail

getPort

public int getPort()
Returns the port used to connect to the Cassandra hosts.

Returns:
the port used to connect to the Cassandra hosts.

getProtocolVersion

public int getProtocolVersion()
The protocol version used by the Cluster instance.

Returns:
the protocol version in use. This might return a negative value if a particular version hasn't been forced by the user (using say {Cluster.Builder#withProtocolVersion}) and this Cluster instance has not yet connected to any node (but as soon as the Cluster instance is connected, this is guaranteed to return either 1 or 2). Note that nodes that do not support this protocol version will be ignored.

getCompression

public ProtocolOptions.Compression getCompression()
Returns the compression used by the protocol.

By default, compression is not used.

Returns:
the compression used.

setCompression

public ProtocolOptions setCompression(ProtocolOptions.Compression compression)
Sets the compression to use.

Note that while this setting can be changed at any time, it will only apply to newly created connections.

Parameters:
compression - the compression algorithm to use (or Compression.NONE to disable compression).
Returns:
this ProtocolOptions object.
Throws:
IllegalStateException - if the compression requested is not available. Most compression algorithms require that the relevant be present in the classpath. If not, the compression will be unavailable.

getSSLOptions

public SSLOptions getSSLOptions()
The SSLOptions used by this cluster.

Returns:
the SSLOptions used by this cluster (set at the cluster creation time) or null if SSL is not in use.

getAuthProvider

public AuthProvider getAuthProvider()
The AuthProvider used by this cluster.

Returns:
the AuthProvided used by this cluster (set at the cluster creation time). If no authentication mechanism is in use (the default), AuthProvided.NONE will be returned.


Copyright © 2014. All rights reserved.