Ciaran0 Ciaran0 - 1 year ago 114
Scala Question

Phantom Scala Cassandra connector: how to specify port, username, password of nodes

I'm trying to use websudos phantom

Does anyone know how to specify connection arguments to Cassandra such as username and password?


Answer Source

Phantom doesn't yet support Kerberos authentication in the phantom-connectors framework but it is on the roadmap for the coming weeks.

However, when using connectors it is possible to override the createCluster method and connect to the cluster in any way you want.

object CustomCassandraManger extends DefaultCasandraManager {

  override protected[this] def createCluster: Cluster = {
    val inets =

     .addContactPoints(inets: _*)

I may not have used the correct methods, but that's how you control the way a cluster is created. Then all you need is to inject this manager in a connector:

trait MyConnector extends SimpleCassandraConnector {
  override val manager = CustomCassandraMananger

And then you mix in this connector into all your tables, just as you would normally when using phantom.

Recent versions of phantom

In more recent versions of phantom, the API is based on ContactPoints, where you can specify whatever ClusterBuilder options you want, using the following DSL.

import com.datastax.driver.core.PlainTextAuthProvider

lazy val local = ContactPoint.local.withClusterBuilder(
  _.withAuthProvider(new PlainTextAuthProvider("user", "pass"))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download