1

I am using DSE Spark Job Server. The task I am attempting to accomplish is as follows:

The spark job which i have created in Java is expected to fetch some datas from cassandra db and this will be deployed in DSE Analytics cluster.

The code as follows:

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;
    }
}

Issue:

While exercising this code I am getting the below issue:

  "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)"]

Could someone resolving the issue. Note: I tried cleaning /tmp folder multiple times. Not able to solve this problem. The DSE version I am using is 4.8.10.

VladoDemcak
  • 4,893
  • 4
  • 35
  • 42

1 Answers1

0

I am not really sure whether you wan't to return null on Exception. I would leave it to propagate.

noorul
  • 1,283
  • 1
  • 8
  • 18