Created
August 23, 2015 05:33
-
-
Save RussellSpitzer/437f57dae4fd4bc4f32d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.datastax.spark.connector._ | |
import com.datastax.spark.connector.cql._ | |
import org.apache.spark.SparkContext | |
def twoClusterExample ( sc: SparkContext) = { | |
val connectorToClusterOne = CassandraConnector(sc.getConf.set("spark.cassandra.connection.host", "127.0.0.1")) | |
val connectorToClusterTwo = CassandraConnector(sc.getConf.set("spark.cassandra.connection.host", "127.0.0.2")) | |
val rddFromClusterOne = { | |
// Sets connectorToClusterOne as default connection for everything in this code block | |
implicit val c = connectorToClusterOne | |
sc.cassandraTable("ks","tab") | |
} | |
{ | |
//Sets connectorToClusterTwo as the default connection for everything in this code block | |
implicit val c = connectorToClusterTwo | |
rddFromClusterOne.saveToCassandra("ks","tab") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment