简体   繁体   中英

Error running spark and cassandra using datastax spark-cassandra java connector

I am getting the following error while using spark-cassandra connector:

ERROR executor.Executor: Exception in task 0.0 in stage 10.0 (TID 207)
java.lang.NoSuchMethodError: org.apache.spark.executor.TaskMetrics.inputMetrics_$eq(Lscala/Option;)V
at com.datastax.spark.connector.metrics.InputMetricsUpdater$.apply(InputMetricsUpdater.scala:61)
at com.datastax.spark.connector.rdd.CassandraTableScanRDD.compute(CassandraTableScanRDD.scala:196)
at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:277)
at org.apache.spark.rdd.RDD.iterator(RDD.scala:244)
at org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:35)
at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:277)
at org.apache.spark.rdd.RDD.iterator(RDD.scala:244)
at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:68)
at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:41)
at org.apache.spark.scheduler.Task.run(Task.scala:64)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:203)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

My code:

    SparkConf conf = new SparkConf(true).setMaster("local").setAppName("org.sparkexample.SparkCassandra")
            .set("spark.executor.memory", "1g").set("spark.cassandra.connection.host", "localhost")
            .set("spark.cassandra.connection.native.port", "9042")
            .set("spark.cassandra.connection.rpc.port", "9160");
    SparkContext ctx = new SparkContext(conf);
    SparkContextJavaFunctions functions = CassandraJavaUtil.javaFunctions(ctx);

    JavaRDD<String> cassandraRowsRDD = functions.cassandraTable("sparktest", "SPARK_PERSON").map(
            new Function<CassandraRow, String>()
            {
                public String call(CassandraRow cassandraRow) throws Exception
                {
                    return cassandraRow.toString();
                }
            });
    System.out.println("Data as CassandraRows: \n" + StringUtils.join(cassandraRowsRDD.toArray(), "\n"));

I tried to google this issue and found that it could be solved by using compatible scala version. But I am using java connector.

How to resolve this?

Thanks.

I degraded the spark version to 1.2.1 from 1.3.1 to resolve this issue temporarily. I was using spark-cassandra-connector-java_2.10 version 1.2.1 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM