Skip to content

Commit e3694ea

Browse files
authored
Merge pull request #13 from riptano/DSP-14970
DSP-14970 update to 0.8.0
2 parents 3518627 + e84a3cb commit e3694ea

File tree

128 files changed

+3299
-1986
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+3299
-1986
lines changed

.DS_Store

6 KB
Binary file not shown.

.github/issue_template.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
**Used Spark version**
2+
3+
**Used Spark Job Server version**
4+
(Released version, git branch or docker image version)
5+
6+
**Deployed mode**
7+
(client/cluster on Spark Standalone/YARN/Mesos/EMR or default)
8+
9+
**Actual (wrong) behavior**
10+
11+
**Steps to reproduce**
12+
13+
**Logs**
14+
15+
```
16+
some log
17+
```
18+
19+
or as attached file (see below)
20+
21+
22+
Unused parts of this template should be removed (including this line).

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ test-reports/
99
.idea*
1010
.vagrant
1111
*.pyc
12+
.DS_Store
1213

1314
# ignore deployment configs
1415
config/*.conf

Dockerfile.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ RUN sbt update
2424
# add the rest of the code
2525
COPY . .
2626

27-
ENV SPARK_HOME /tmp/spark-2.1.0-bin-hadoop2.7
27+
ENV SPARK_HOME /tmp/spark-2.2.0-bin-hadoop2.7
2828
ENV JAVA_OPTIONS "-Xmx1500m -XX:MaxPermSize=512m -Dakka.test.timefactor=3"
2929

3030
CMD ["/usr/src/app/run_tests.sh"]

README.md

Lines changed: 203 additions & 60 deletions
Large diffs are not rendered by default.

bin/manager_start.sh

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# Script to start the job manager
3-
# args: <work dir for context> <cluster address> [proxy_user]
3+
# args: <master> <deployMode> <akkaAdress> <actorName> <workDir> [<proxyUser>]
44
set -e
55

66
get_abs_script_path() {
@@ -13,12 +13,8 @@ get_abs_script_path
1313

1414
. $appdir/setenv.sh
1515

16-
# Override logging options to provide per-context logging
17-
LOGGING_OPTS="-Dlog4j.configuration=file:$appdir/log4j-server.properties
18-
-DLOG_DIR=$2"
19-
2016
GC_OPTS="-XX:+UseConcMarkSweepGC
21-
-verbose:gc -XX:+PrintGCTimeStamps -Xloggc:$appdir/gc.out
17+
-verbose:gc -XX:+PrintGCTimeStamps
2218
-XX:MaxPermSize=512m
2319
-XX:+CMSClassUnloadingEnabled "
2420

@@ -27,26 +23,46 @@ JAVA_OPTS="-XX:MaxDirectMemorySize=$MAX_DIRECT_MEMORY
2723

2824
MAIN="spark.jobserver.JobManager"
2925

30-
MESOS_OPTS=""
31-
if [ $1 == "mesos-cluster" ]; then
32-
MESOS_OPTS="--master $MESOS_SPARK_DISPATCHER --deploy-mode cluster"
33-
appdir=$REMOTE_JOBSERVER_DIR
34-
fi
26+
# copy files via spark-submit and read them from current (container) dir
27+
if [ $2 = "cluster" -a -z "$REMOTE_JOBSERVER_DIR" ]; then
28+
SPARK_SUBMIT_OPTIONS="$SPARK_SUBMIT_OPTIONS
29+
--master $1 --deploy-mode cluster
30+
--conf spark.yarn.submit.waitAppCompletion=false
31+
--files $appdir/log4j-cluster.properties,$conffile"
32+
JAR_FILE="$appdir/spark-job-server.jar"
33+
CONF_FILE=$(basename $conffile)
34+
LOGGING_OPTS="-Dlog4j.configuration=log4j-cluster.properties"
35+
36+
# use files in REMOTE_JOBSERVER_DIR
37+
elif [ $2 == "cluster" ]; then
38+
SPARK_SUBMIT_OPTIONS="$SPARK_SUBMIT_OPTIONS
39+
--master $1 --deploy-mode cluster
40+
--conf spark.yarn.submit.waitAppCompletion=false"
41+
JAR_FILE="$REMOTE_JOBSERVER_DIR/spark-job-server.jar"
42+
CONF_FILE="$REMOTE_JOBSERVER_DIR/$(basename $conffile)"
43+
LOGGING_OPTS="-Dlog4j.configuration=$REMOTE_JOBSERVER_DIR/log4j-cluster.properties"
3544

36-
if [ ! -z $5 ]; then
37-
cmd='$SPARK_HOME/bin/spark-submit --class $MAIN --driver-memory $JOBSERVER_MEMORY
38-
--conf "spark.executor.extraJavaOptions=$LOGGING_OPTS"
39-
--proxy-user $5
40-
$MESOS_OPTS
41-
--driver-java-options "$GC_OPTS $JAVA_OPTS $LOGGING_OPTS $CONFIG_OVERRIDES"
42-
$appdir/spark-job-server.jar $2 $3 $4 $conffile'
45+
# client mode, use files from app dir
4346
else
44-
cmd='$SPARK_HOME/bin/spark-submit --class $MAIN --driver-memory $JOBSERVER_MEMORY
45-
--conf "spark.executor.extraJavaOptions=$LOGGING_OPTS"
46-
--driver-java-options "$GC_OPTS $JAVA_OPTS $LOGGING_OPTS $CONFIG_OVERRIDES"
47-
$MESOS_OPTS
48-
$appdir/spark-job-server.jar $2 $3 $4 $conffile'
47+
JAR_FILE="$appdir/spark-job-server.jar"
48+
CONF_FILE="$conffile"
49+
LOGGING_OPTS="-Dlog4j.configuration=file:$appdir/log4j-server.properties -DLOG_DIR=$5"
50+
GC_OPTS="$GC_OPTS -Xloggc:$5/gc.out"
51+
fi
52+
53+
if [ -n "$6" ]; then
54+
SPARK_SUBMIT_OPTIONS="$SPARK_SUBMIT_OPTIONS --proxy-user $6"
4955
fi
5056

51-
eval $cmd > /dev/null 2>&1 &
52-
# exec java -cp $CLASSPATH $GC_OPTS $JAVA_OPTS $LOGGING_OPTS $CONFIG_OVERRIDES $MAIN $1 $2 $conffile 2>&1 &
57+
if [ -n "$JOBSERVER_KEYTAB" ]; then
58+
SPARK_SUBMIT_OPTIONS="$SPARK_SUBMIT_OPTIONS --keytab $JOBSERVER_KEYTAB"
59+
fi
60+
61+
cmd='$SPARK_HOME/bin/spark-submit --class $MAIN --driver-memory $JOBSERVER_MEMORY
62+
--conf "spark.executor.extraJavaOptions=$LOGGING_OPTS"
63+
$SPARK_SUBMIT_OPTIONS
64+
--driver-java-options "$GC_OPTS $JAVA_OPTS $LOGGING_OPTS $CONFIG_OVERRIDES $SPARK_SUBMIT_JAVA_OPTIONS"
65+
$JAR_FILE $3 $4 $CONF_FILE'
66+
67+
eval $cmd 2>&1 > $5/spark-job-server.out
68+

build.sbt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ lazy val akkaApp = Project(id = "akka-app", base = file("akka-app"))
1919
lazy val jobServer = Project(id = "job-server", base = file("job-server"))
2020
.settings(commonSettings)
2121
.settings(revolverSettings)
22-
.settings(Assembly.settings)
22+
.settings(assembly := null.asInstanceOf[File])
2323
.settings(
2424
description := "Spark as a Service: a RESTful job server for Apache Spark",
2525
libraryDependencies ++= sparkDeps ++ slickDeps ++ cassandraDeps ++ securityDeps ++ coreTestDeps,
@@ -35,7 +35,6 @@ lazy val jobServer = Project(id = "job-server", base = file("job-server"))
3535
fullClasspath in Compile <<= (fullClasspath in Compile).map { classpath =>
3636
extraJarPaths ++ classpath
3737
},
38-
test in assembly := {},
3938
fork in Test := true
4039
)
4140
.settings(noPublishSettings)
@@ -48,9 +47,11 @@ lazy val jobServerTestJar = Project(id = "job-server-tests", base = file("job-se
4847
.settings(noPublishSettings)
4948
.dependsOn(jobServerApi)
5049
.disablePlugins(SbtScalariform)
50+
.disablePlugins(ScoverageSbtPlugin) // do not include in coverage report
5151

5252
lazy val jobServerApi = Project(id = "job-server-api", base = file("job-server-api"))
5353
.settings(commonSettings)
54+
.settings(jobServerApiSettings)
5455
.settings(publishSettings)
5556
.disablePlugins(SbtScalariform)
5657

@@ -93,15 +94,17 @@ lazy val root = Project(id = "root", base = file("."))
9394
lazy val jobServerExtrasSettings = revolverSettings ++ Assembly.settings ++ publishSettings ++ Seq(
9495
libraryDependencies ++= sparkExtraDeps ++ sparkExtraDepsTest,
9596
// Extras packages up its own jar for testing itself
96-
test in Test <<= (test in Test).dependsOn(packageBin in Compile)
97-
.dependsOn(clean in Compile),
97+
test in Test <<= (test in Test).dependsOn(packageBin in Compile),
9898
fork in Test := true,
99+
parallelExecution in Test := false,
99100
// Temporarily disable test for assembly builds so folks can package and get started. Some tests
100101
// are flaky in extras esp involving paths.
101102
test in assembly := {},
102103
exportJars := true
103104
)
104105

106+
lazy val jobServerApiSettings = Seq(libraryDependencies ++= sparkDeps ++ sparkExtraDeps)
107+
105108
lazy val testPython = taskKey[Unit]("Launch a sub process to run the Python tests")
106109
lazy val buildPython = taskKey[Unit]("Build the python side of python support into an egg")
107110
lazy val buildPyExamples = taskKey[Unit]("Build the examples of python jobs into an egg")
@@ -138,7 +141,10 @@ lazy val dockerSettings = Seq(
138141
val sparkBuild = s"spark-${Versions.spark}"
139142
val sparkBuildCmd = scalaBinaryVersion.value match {
140143
case "2.11" =>
141-
"./make-distribution.sh -Dscala-2.11 -Phadoop-2.7 -Phive"
144+
Versions.spark match {
145+
case s if s.startsWith("1") => {"./make-distribution.sh -Dscala-2.11 -Phadoop-2.7 -Phive"}
146+
case _ => {"./dev/make-distribution.sh -Dscala-2.11 -Phadoop-2.7 -Phive"}
147+
}
142148
case other => throw new RuntimeException(s"Scala version $other is not supported!")
143149
}
144150

@@ -282,7 +288,7 @@ lazy val commonSettings = Defaults.coreDefaultSettings ++ dirSettings ++ implici
282288

283289
lazy val scoverageSettings = {
284290
// Semicolon-separated list of regexs matching classes to exclude
285-
coverageExcludedPackages := ".+Benchmark.*"
291+
coverageExcludedPackages := ".+Benchmark.*;.+Example.*;.+TestJob"
286292
}
287293

288294
/** Used for publishing `extras`, `api` and `python` jars. Main Spark Job Server assembly is published

ci/install-spark.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env bash
22
set -e
3-
curl -L -o /tmp/spark.tgz http://d3kbcqa49mib13.cloudfront.net/spark-2.1.0-bin-hadoop2.7.tgz
3+
curl -L -o /tmp/spark.tgz http://d3kbcqa49mib13.cloudfront.net/spark-2.2.0-bin-hadoop2.7.tgz
44
tar -xvzf /tmp/spark.tgz -C /tmp

doc/EMR.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## Step by step instruction on how to run Spark Job Server on EMR 4.2.0 (Spark 1.6.0)
22

3+
See also running in [cluster mode](cluster.md), running [YARN in client mode](yarn.md) and running on [Mesos](Mesos.md).
4+
35
### Create EMR 4.2.0 cluster
46

57
Create EMR cluster using AWS EMR console or aws cli.

doc/cluster.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
## Configuring Job Server for YARN cluster mode
2+
3+
See also running [YARN in client mode](yarn.md), running [YARN on EMR](EMR.md) and running on [Mesos](mesos.md).
4+
5+
### Job Server configuration
6+
7+
Add the following properties in your job server config file:
8+
- set `spark.master` property to `yarn`, `spark://...` or `mesos://...`
9+
- set `spark.submit.deployMode` property to `cluster`
10+
- set `spark.jobserver.context-per-jvm` to `true`
11+
- set `akka.remote.netty.tcp.hostname` to the cluster interface of the host running the frontend
12+
- set `akka.remote.netty.tcp.maximum-frame-size` to support big remote jars fetch
13+
14+
Optional / required in spark standalone mode:
15+
- set `REMOTE_JOBSERVER_DIR` to `hdfs://...`, `file://...` or `http://...` in your settings `xxx.sh`
16+
- copy `spark-job-server.jar`, your job server config and `log4j-cluster.properties` file into this location
17+
18+
Example job server config (replace `CLUSTER-IP` with the internal IP of the host running the job server frontend):
19+
20+
spark {
21+
# deploy in yarn cluster mode
22+
master = yarn
23+
submit.deployMode = cluster
24+
25+
jobserver {
26+
context-per-jvm = true
27+
28+
# start a H2 DB server, reachable in your cluster
29+
sqldao {
30+
jdbc {
31+
url = "jdbc:h2:tcp://CLUSTER-IP:9092/h2-db;AUTO_RECONNECT=TRUE"
32+
}
33+
}
34+
startH2Server = false
35+
}
36+
}
37+
38+
# start akka on this interface, reachable from your cluster
39+
akka {
40+
remote.netty.tcp {
41+
hostname = "CLUSTER-IP"
42+
43+
# This controls the maximum message size, including job results, that can be sent
44+
maximum-frame-size = 100 MiB
45+
}
46+
}
47+
48+
Note:
49+
- YARN transfers the files provided via `--files` submit option into the cluster / container. Spark standalone does not support this in cluster mode and you have to transfer them manual.
50+
- Instead of running a H2 DB instance you can also run a real DB reachable inside your cluster. You can't use the default (host only) H2 configuration in a cluster setup.
51+
- Akka binds by [default](../job-server/src/main/resources/application.conf) to the local host interface and is not reachable from the cluster. You need to configure the akka hostname to the cluster internal address.
52+
53+
### Reading files uploaded via frontend
54+
55+
Files uploaded via the data API (`/data`) are stored on your job server frontend host.
56+
Call the [DataFileCache](../job-server-api/src/main/scala/spark/jobserver/api/SparkJobBase.scala) API implemented by the job environment in your spark jobs to access them:
57+
58+
```scala
59+
object RemoteDriverExample extends NewSparkJob {
60+
def runJob(sc: SparkContext, runtime: JobEnvironment, data: JobData): JobOutput =
61+
runtime.getDataFile(...)
62+
```
63+
64+
The job server transfers the files via akka to the host running your driver and caches them there.
65+
66+
Note: Files uploaded via the JAR or binary API are stored and transfered via the Job DB.

0 commit comments

Comments
 (0)