我正在使用dse spark作业服务器。我要完成的任务如下:
我用java创建的spark作业将从cassandradb获取一些数据,这将部署在dse分析集群中。
代码如下:
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条答案
按热度按时间fxnxkyjh1#
我不太确定你是否要在异常时返回null。我会让它传播。