File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
job-server-api/src/spark.jobserver
job-server-tests/src/main/java/spark.jobserver Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ package spark .jobserver
2
+
3
+ import com .typesafe .config .Config
4
+ import org .apache .spark .api .java .JavaSparkContext
5
+ import org .apache .spark .SparkContext
6
+
7
+ /**
8
+ * A class to make Java jobs easier to write. In Java:
9
+ * public class MySparkJob extends JavaSparkJob {
10
+ * @override
11
+ * public Object runJob(JavaSparkContext jsc, Config jobConfig) { ... }
12
+ * }
13
+ */
14
+ class JavaSparkJob extends SparkJob {
15
+
16
+ def runJob (sc : SparkContext , jobConfig : Config ): Any = {
17
+ runJob(new JavaSparkContext (sc), jobConfig);
18
+ }
19
+
20
+ def validate (sc : SparkContext , config : Config ): SparkJobValidation = {
21
+ Option (invalidate(new JavaSparkContext (sc), config))
22
+ .map(err => SparkJobInvalid (err))
23
+ .getOrElse(SparkJobValid )
24
+ }
25
+
26
+ /**
27
+ * The main class that carries out the Spark job. The results will be converted to JSON
28
+ * and emitted (but NOT persisted).
29
+ */
30
+ def runJob (jsc : JavaSparkContext , jobConfig : Config ): Any = {}
31
+
32
+ /**
33
+ * Checks the config and returns an error message, or null if the config is fine.
34
+ * The error message will be returned to the user as a 404 HTTP error code.
35
+ */
36
+ def invalidate (jsc : JavaSparkContext , config : Config ): String = { null }
37
+ }
Original file line number Diff line number Diff line change
1
+ package spark .jobserver ;
2
+
3
+ import com .typesafe .config .Config ;
4
+ import org .apache .spark .api .java .JavaSparkContext ;
5
+ import spark .jobserver .JavaSparkJob ;
6
+
7
+ public class JavaHelloWorldJob extends JavaSparkJob {
8
+ @ Override
9
+ public Object runJob (JavaSparkContext jsc , Config jobConfig ) {
10
+ return ("Hello World!" );
11
+ }
12
+ }
You can’t perform that action at this time.
0 commit comments