Taken from
http://outworkers.com/blog/post/a-series-on-phantom-part-1-getting-started-with-phantom
I'm trying to connect to a Cassandra cluster that has multiple nodes like this:
object Defaults {
val hosts = Seq("Cassnode1.company.com", "Cassnode2.company.com", "Cassnode3.company.com")
val Connector = ContactPoints(hosts).keySpace("whatever")
}
If for some reason, one of the nodes does not exist, I get:
Caused by: java.lang.IllegalArgumentException: Cassnode3.company.com: unknown error
If I remove this node from the hosts Seq everything works fine.
I am using phantom dsl version "1.28.12" and I was wondering if this is the expected behavior as I assumed that whenever one of the listed hosts does not exist/is not available the application would use the remaining ones.
Is there a way to test connectivity to the nodes before passing the list to the ContactPoints?
Thanks!
There isn't, the whole point of
ContactPoints
which just leverage the underlyingClusterBuilder
is to deal "with that kind of thing" for you. You can also pass in an error handling function to deal with some of the issues, so that may make things easier.By gut feeling is that the rest of the nodes have some kind of IP mapping in your
/etc/hosts
, but you are missing the one forCassnode3.company.com
. Remember they all need to be resolved to an IP address otherwise they are no good to theClusterBuilder
.I would strongly recommend upgrading to a
2.1.3
version of phantom, but in this particular case the culprit is almost entirely your local dev setup, which just needs an IP mapping for that third URL.