datastax/spark-cassandra-connector — pull request #267 by rstrickland (2014-09-24 13:52:41+00:00)
Title: Added support for ignoring non-local DCs

In some multi-DC configurations it's advantageous to block port 9042 externally. This breaks the Java driver, since nodes in other DCs are set to ``HostDistance.REMOTE``, which still causes the driver to try to connect to them when it receives an onAdd event. The result is a fatal exception.

This allows the user to set the name of the local DC in an optional config key, ``spark.cassandra.connection.local_dc``. If set, this value is used to filter out non-local DCs. Otherwise I get a unique list of DCs from the contact points, and if there's only one I use that; if not I throw an exception. The distance function always returns ``HostDistance.IGNORED`` if the host DC doesn't match the local DC. So this makes it work correctly out of the box, but gives you the option of being explicit.