class CassandraConnector extends Serializable with Logging
Provides and manages connections to Cassandra.
A CassandraConnector
instance is serializable and
can be safely sent over network,
because it automatically reestablishes the connection
to the same cluster after deserialization. Internally it saves
a list of all nodes in the cluster, so a connection can be established
even if the host given in the initial config is down.
Multiple CassandraConnector
s in the same JVM connected to the same
Cassandra cluster will share a single underlying Cluster
object.
CassandraConnector
will close the underlying Cluster
object automatically
whenever it is not used i.e. no Session
or Cluster
is open for longer
than spark.cassandra.connection.keepAliveMS
property value.
A CassandraConnector
object is configured from CassandraConnectorConf object which
can be either given explicitly or automatically configured from SparkConf.
The connection options are:
spark.cassandra.connection.host
: contact points to connect to the Cassandra cluster, defaults to spark master hostspark.cassandra.connection.port
: Cassandra native port, defaults to 9042spark.cassandra.connection.factory
: name of a Scala module or class implementing CassandraConnectionFactory that allows to plugin custom code for connecting to Cassandraspark.cassandra.connection.keepAliveMS
: how long to keep unused connection before closing it (default 250 ms)spark.cassandra.connection.timeoutMS
: how long to wait for connection to the Cassandra cluster (default 5 s)spark.cassandra.connection.reconnectionDelayMS.min
: initial delay determining how often to try to reconnect to a dead node (default 1 s)spark.cassandra.connection.reconnectionDelayMS.max
: final delay determining how often to try to reconnect to a dead node (default 60 s)spark.cassandra.auth.username
: login for password authenticationspark.cassandra.auth.password
: password for password authenticationspark.cassandra.auth.conf.factory
: name of a Scala module or class implementing AuthConfFactory that allows to plugin custom authentication configurationspark.cassandra.query.retry.count
: how many times to reattempt a failed query (default 10)spark.cassandra.read.timeoutMS
: maximum period of time to wait for a read to returnspark.cassandra.connection.ssl.enabled
: enable secure connection to Cassandra clusterspark.cassandra.connection.ssl.trustStore.path
: path for the trust store being usedspark.cassandra.connection.ssl.trustStore.password
: trust store passwordspark.cassandra.connection.ssl.trustStore.type
: trust store type (default JKS)spark.cassandra.connection.ssl.protocol
: SSL protocol (default TLS)spark.cassandra.connection.ssl.enabledAlgorithms
: SSL cipher suites (default TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA)
- Alphabetic
- By Inheritance
- CassandraConnector
- Logging
- Serializable
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new CassandraConnector(conf: CassandraConnectorConf)
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
closeResourceAfterUse[T, C <: AnyRef { def close(): Unit }](closeable: C)(code: (C) ⇒ T): T
Automatically closes resource after use.
Automatically closes resource after use. Handy for closing streams, files, sessions etc. Similar to try-with-resources in Java 7.
- val conf: CassandraConnectorConf
-
def
connectionFactory: CassandraConnectionFactory
Connection configurator
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hosts: Set[InetSocketAddress]
Known cluster hosts in the connected datacenter.
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isTraceEnabled(): Boolean
- Attributes
- protected
- Definition Classes
- Logging
-
def
jWithSessionDo[T](code: Function[CqlSession, T]): T
Allows use of a Cassandra
Session
in a safe way without risk of forgetting to close it from java.Allows use of a Cassandra
Session
in a safe way without risk of forgetting to close it from java. SeewithSessionDo
We should not need this in scala 2.12
-
def
log: Logger
- Attributes
- protected
- Definition Classes
- Logging
-
def
logDebug(msg: ⇒ String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logDebug(msg: ⇒ String): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logError(msg: ⇒ String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logError(msg: ⇒ String): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logInfo(msg: ⇒ String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logInfo(msg: ⇒ String): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logName: String
- Attributes
- protected
- Definition Classes
- Logging
-
def
logTrace(msg: ⇒ String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logTrace(msg: ⇒ String): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logWarning(msg: ⇒ String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
def
logWarning(msg: ⇒ String): Unit
- Attributes
- protected
- Definition Classes
- Logging
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
openSession(): CqlSession
Returns a shared session to Cassandra and increases the internal open reference counter.
Returns a shared session to Cassandra and increases the internal open reference counter. It does not release the session automatically, so please remember to close it after use. Closing a shared session decreases the session reference counter. If the reference count drops to zero, the session may be physically closed.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
withSessionDo[T](code: (CqlSession) ⇒ T): T
Allows to use Cassandra
Session
in a safe way without risk of forgetting to close it.Allows to use Cassandra
Session
in a safe way without risk of forgetting to close it. TheSession
object obtained through this method is a proxy to a shared, singleSession
associated with the cluster. Internally, the shared underlyingSession
will be closed shortly after all the proxies are closed.