1
votes

I have created table in Cassandra with below commands:

CREATE KEYSPACE test WITH REPLICATION = { 'class' : 
'NetworkTopologyStrategy', 'dc1' : 3 } AND DURABLE_WRITES = false;  

use test;

create table demo(id int primary key, name text);

Once the table got created successfully, I was running the below code to write the data into Cassandra from Spark.
But facing below error

Code Snippet of Spark

import com.datastax.spark.connector._
import org.apache.spark.SparkContext._
import org.apache.spark.SparkConf
import com.datastax.spark.connector.cql._

val connectorToClusterOne = CassandraConnector(sc.getConf.set("spark.cassandra.connection.host","xx.xx.xx.xx").set("spark.cassandra.auth.username", "xxxxxxx").set("spark.cassandra.auth.password", "xxxxxxx"))

---K/V---
val data = sc.textFile("/home/ubuntu/test.txt").map(_.split(",")).map(p => demo(p(0).toInt,p(1)))

implicit val c = connectorToClusterOne
data.saveToCassandra("test","demo")

BELOW IS THE ERROR DESCRIPTION: .

Error while computing token map for keyspace test with datacenter dc1: could not achieve replication factor 3 (found 0 replicas only), check your keyspace replication settings.

Could any one suggest what could be the possible reason for this.

1

1 Answers

0
votes

This error is usually because either the request is not being directed at the correct cluster or the datacenter does not exist or has an incorrect name.

To make sure you are connecting to the correct cluster double check the connection host used for your spark application.

To check the datacenter, use nodetool status to make sure that the datacenter which you requested exists and includes no extraneous whitespace.

Lastly, it could be possible that all the nodes in the datacenter are down, so double check this as well.