Spark Job Server中的Java程序抛出scala.MatchError

时间:2016-10-21 17:00:14

标签: apache-spark datastax spark-jobserver

我正在使用DSE Spark Job Server 。我试图完成的任务如下:

我在Java中创建的spark作业有望从cassandra db获取一些数据,这将部署在DSE Analytics集群中。

代码如下:

package com.symantec.nsp.analytics;

import static com.datastax.spark.connector.japi.CassandraJavaUtil.javaFunctions;
import static com.datastax.spark.connector.japi.CassandraJavaUtil.mapRowTo;

import java.io.Serializable;
import java.util.List;
import java.util.UUID;

import org.apache.commons.lang.StringUtils;
import org.apache.spark.SparkContext;
import org.apache.spark.api.java.JavaSparkContext;

import spark.jobserver.JavaSparkJob;
import spark.jobserver.SparkJobInvalid;
import spark.jobserver.SparkJobValid$;
import spark.jobserver.SparkJobValidation;

import com.symantec.nsp.analytics.model.Bucket;
import com.typesafe.config.Config;

public class JavaSparkJobBasicQuery extends JavaSparkJob {

    public String runJob(JavaSparkContext jsc, Config config) {
        try {
            List<UUID> bucketRecords = javaFunctions(jsc).cassandraTable("nsp_storage", "bucket", mapRowTo(Bucket.class))
                    .select("id", "deleted").filter(s -> s.getDeleted()).map(s -> s.getId()).collect();

            System.out.println(">>>>>>>>  Total Buckets getting scanned by Spark :" + bucketRecords.size());
            return bucketRecords.toString();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public SparkJobValidation validate(SparkContext sc, Config config) {
        return null;
    }

    public String invalidate(JavaSparkContext jsc, Config config) {
        return null;
    }
}

问题:

在执行此代码时,我遇到了以下问题:

  "status": "ERROR",
  "result":
    "message": "null",
    "errorClass": "scala.MatchError",
    "stack": ["spark.jobserver.JobManagerActor$$anonfun$spark$jobserver$JobManagerActor$$getJobFuture$4.apply(JobManagerActor.scala:244)", "scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)", "scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)", "java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)", "java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)", "java.lang.Thread.run(Thread.java:745)"]

有人可以解决这个问题。 注意:我多次尝试清理/tmp文件夹。无法解决这个问题。我使用的DSE版本是4.8.10。

1 个答案:

答案 0 :(得分:0)

我不确定你是否要在Exception上返回null。我会留下它来传播。