Package com.datastax.driver.core
Class ProtocolOptions
- java.lang.Object
-
- com.datastax.driver.core.ProtocolOptions
-
public class ProtocolOptions extends Object
Options of the Cassandra native binary protocol.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classProtocolOptions.CompressionCompression supported by the Cassandra binary protocol.
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_LOCAL_PORT_HIGHstatic intDEFAULT_LOCAL_PORT_LOWstatic intDEFAULT_MAX_SCHEMA_AGREEMENT_WAIT_SECONDSThe default value forgetMaxSchemaAgreementWaitSeconds(): 10.static intDEFAULT_PORTThe default port for Cassandra native binary protocol: 9042.
-
Constructor Summary
Constructors Constructor Description ProtocolOptions()Creates a newProtocolOptionsinstance using theDEFAULT_PORT(and without SSL).ProtocolOptions(int port)Creates a newProtocolOptionsinstance using the provided port (without SSL nor authentication).ProtocolOptions(int port, ProtocolVersion protocolVersion, int maxSchemaAgreementWaitSeconds, SSLOptions sslOptions, AuthProvider authProvider)Creates a newProtocolOptionsinstance using the provided port and SSL context.ProtocolOptions(int port, ProtocolVersion protocolVersion, int maxSchemaAgreementWaitSeconds, SSLOptions sslOptions, AuthProvider authProvider, boolean noCompact)Creates a newProtocolOptionsinstance using the provided port and SSL context.ProtocolOptions(int port, ProtocolVersion protocolVersion, int maxSchemaAgreementWaitSeconds, SSLOptions sslOptions, AuthProvider authProvider, boolean noCompact, boolean useAdvancedShardAwarness, int portLow, int portHigh)Creates a newProtocolOptionsinstance using the provided port and SSL context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AuthProvidergetAuthProvider()TheAuthProviderused by this cluster.ProtocolOptions.CompressiongetCompression()Returns the compression used by the protocol.intgetHighLocalPort()intgetLowLocalPort()intgetMaxSchemaAgreementWaitSeconds()Returns the maximum time to wait for schema agreement before returning from a DDL query.intgetPort()Returns the port used to connect to the Cassandra hosts.ProtocolVersiongetProtocolVersion()The protocol version used by the Cluster instance.SSLOptionsgetSSLOptions()TheSSLOptionsused by this cluster.booleanisNoCompact()booleanisUseAdvancedShardAwareness()ProtocolOptionssetCompression(ProtocolOptions.Compression compression)Sets the compression to use.
-
-
-
Field Detail
-
DEFAULT_PORT
public static final int DEFAULT_PORT
The default port for Cassandra native binary protocol: 9042.- See Also:
- Constant Field Values
-
DEFAULT_MAX_SCHEMA_AGREEMENT_WAIT_SECONDS
public static final int DEFAULT_MAX_SCHEMA_AGREEMENT_WAIT_SECONDS
The default value forgetMaxSchemaAgreementWaitSeconds(): 10.- See Also:
- Constant Field Values
-
DEFAULT_LOCAL_PORT_LOW
public static final int DEFAULT_LOCAL_PORT_LOW
- See Also:
- Constant Field Values
-
DEFAULT_LOCAL_PORT_HIGH
public static final int DEFAULT_LOCAL_PORT_HIGH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ProtocolOptions
public ProtocolOptions()
Creates a newProtocolOptionsinstance using theDEFAULT_PORT(and without SSL).
-
ProtocolOptions
public ProtocolOptions(int port)
Creates a newProtocolOptionsinstance 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, ProtocolVersion protocolVersion, int maxSchemaAgreementWaitSeconds, SSLOptions sslOptions, AuthProvider authProvider)Creates a newProtocolOptionsinstance 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 benull, in which case the version used will be the biggest version supported by the first node the driver connects to. SeeCluster.Builder.withProtocolVersion(com.datastax.driver.core.ProtocolVersion)for more details.sslOptions- the SSL options to use. Usenullif SSL is not to be used.authProvider- theAuthProviderto use for authentication against the Cassandra nodes.
-
ProtocolOptions
public ProtocolOptions(int port, ProtocolVersion protocolVersion, int maxSchemaAgreementWaitSeconds, SSLOptions sslOptions, AuthProvider authProvider, boolean noCompact)Creates a newProtocolOptionsinstance 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 benull, in which case the version used will be the biggest version supported by the first node the driver connects to. SeeCluster.Builder.withProtocolVersion(com.datastax.driver.core.ProtocolVersion)for more details.sslOptions- the SSL options to use. Usenullif SSL is not to be used.authProvider- theAuthProviderto use for authentication against the Cassandra nodes.noCompact- whether or not to include the NO_COMPACT startup option.
-
ProtocolOptions
public ProtocolOptions(int port, ProtocolVersion protocolVersion, int maxSchemaAgreementWaitSeconds, SSLOptions sslOptions, AuthProvider authProvider, boolean noCompact, boolean useAdvancedShardAwarness, int portLow, int portHigh)Creates a newProtocolOptionsinstance 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 benull, in which case the version used will be the biggest version supported by the first node the driver connects to. SeeCluster.Builder.withProtocolVersion(com.datastax.driver.core.ProtocolVersion)for more details.sslOptions- the SSL options to use. Usenullif SSL is not to be used.authProvider- theAuthProviderto use for authentication against the Cassandra nodes.noCompact- whether or not to include the NO_COMPACT startup option.useAdvancedShardAwarness- should the advanced shard awarness (choosing shard to connect to by client-side port) be used.portLow- lower bound (inclusive) of ports to use for advanced shard awareness.portHigh- upper bound (inclusive) of ports to use for advanced shard awareness.
-
-
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 ProtocolVersion getProtocolVersion()
The protocol version used by the Cluster instance.- Returns:
- the protocol version in use. This might return
nullif 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 a non-null value). 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 (orCompression.NONEto disable compression).- Returns:
- this
ProtocolOptionsobject. - 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.
-
getMaxSchemaAgreementWaitSeconds
public int getMaxSchemaAgreementWaitSeconds()
Returns the maximum time to wait for schema agreement before returning from a DDL query.- Returns:
- the time.
-
getSSLOptions
public SSLOptions getSSLOptions()
TheSSLOptionsused by this cluster.- Returns:
- the
SSLOptionsused by this cluster (set at the cluster creation time) ornullif SSL is not in use.
-
getAuthProvider
public AuthProvider getAuthProvider()
TheAuthProviderused by this cluster.- Returns:
- the
AuthProvidedused by this cluster (set at the cluster creation time). If no authentication mechanism is in use (the default),AuthProvided.NONEwill be returned.
-
isNoCompact
public boolean isNoCompact()
- Returns:
- Whether or not to include the NO_COMPACT startup option.
-
isUseAdvancedShardAwareness
public boolean isUseAdvancedShardAwareness()
- Returns:
- Wheter advanced or non-advanced shard awareness is used.
-
getLowLocalPort
public int getLowLocalPort()
-
getHighLocalPort
public int getHighLocalPort()
-
-