2010-03-30 03:17:55 +04:00
|
|
|
#!/bin/bash
|
|
|
|
|
2012-09-25 01:12:48 +04:00
|
|
|
SCALA_VERSION=2.9.2
|
2011-05-27 13:20:34 +04:00
|
|
|
|
2010-03-30 03:17:55 +04:00
|
|
|
# Figure out where the Scala framework is installed
|
2010-10-16 23:18:02 +04:00
|
|
|
FWDIR="$(cd `dirname $0`; pwd)"
|
2010-03-30 03:17:55 +04:00
|
|
|
|
2010-10-16 06:42:26 +04:00
|
|
|
# Export this as SPARK_HOME
|
|
|
|
export SPARK_HOME="$FWDIR"
|
|
|
|
|
2010-07-20 05:00:30 +04:00
|
|
|
# Load environment variables from conf/spark-env.sh, if it exists
|
|
|
|
if [ -e $FWDIR/conf/spark-env.sh ] ; then
|
|
|
|
. $FWDIR/conf/spark-env.sh
|
|
|
|
fi
|
|
|
|
|
2012-07-09 01:00:04 +04:00
|
|
|
# Check that SCALA_HOME has been specified
|
|
|
|
if [ -z "$SCALA_HOME" ]; then
|
|
|
|
echo "SCALA_HOME is not set" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-03-18 00:39:14 +04:00
|
|
|
# If the user specifies a Mesos JAR, put it before our included one on the classpath
|
2010-10-16 06:42:26 +04:00
|
|
|
MESOS_CLASSPATH=""
|
2012-07-09 01:00:04 +04:00
|
|
|
if [ -z "$MESOS_JAR" ] ; then
|
2012-03-18 00:39:14 +04:00
|
|
|
MESOS_CLASSPATH="$MESOS_JAR"
|
2010-08-13 11:39:36 +04:00
|
|
|
fi
|
|
|
|
|
2012-03-18 00:39:14 +04:00
|
|
|
# Figure out how much memory to use per executor and set it as an environment
|
|
|
|
# variable so that our process sees it and can report it to Mesos
|
2012-07-09 01:00:04 +04:00
|
|
|
if [ -z "$SPARK_MEM" ] ; then
|
2011-08-02 00:54:48 +04:00
|
|
|
SPARK_MEM="512m"
|
2010-07-20 05:00:30 +04:00
|
|
|
fi
|
2012-03-18 00:39:14 +04:00
|
|
|
export SPARK_MEM
|
2010-07-20 05:00:30 +04:00
|
|
|
|
|
|
|
# Set JAVA_OPTS to be able to load native libraries and to set heap size
|
|
|
|
JAVA_OPTS="$SPARK_JAVA_OPTS"
|
2012-03-18 00:39:14 +04:00
|
|
|
JAVA_OPTS+=" -Djava.library.path=$SPARK_LIBRARY_PATH"
|
2010-07-20 05:00:30 +04:00
|
|
|
JAVA_OPTS+=" -Xms$SPARK_MEM -Xmx$SPARK_MEM"
|
|
|
|
# Load extra JAVA_OPTS from conf/java-opts, if it exists
|
2010-03-30 03:17:55 +04:00
|
|
|
if [ -e $FWDIR/conf/java-opts ] ; then
|
|
|
|
JAVA_OPTS+=" `cat $FWDIR/conf/java-opts`"
|
|
|
|
fi
|
|
|
|
export JAVA_OPTS
|
|
|
|
|
2012-03-18 00:39:14 +04:00
|
|
|
CORE_DIR="$FWDIR/core"
|
|
|
|
REPL_DIR="$FWDIR/repl"
|
|
|
|
EXAMPLES_DIR="$FWDIR/examples"
|
|
|
|
BAGEL_DIR="$FWDIR/bagel"
|
2011-02-02 02:11:08 +03:00
|
|
|
|
|
|
|
# Build up classpath
|
2012-03-18 00:39:14 +04:00
|
|
|
CLASSPATH="$SPARK_CLASSPATH"
|
|
|
|
CLASSPATH+=":$MESOS_CLASSPATH"
|
|
|
|
CLASSPATH+=":$FWDIR/conf"
|
|
|
|
CLASSPATH+=":$CORE_DIR/target/scala-$SCALA_VERSION/classes"
|
2012-09-08 04:08:36 +04:00
|
|
|
CLASSPATH+=":$CORE_DIR/target/scala-$SCALA_VERSION/test-classes"
|
2012-07-01 03:43:27 +04:00
|
|
|
CLASSPATH+=":$CORE_DIR/src/main/resources"
|
2012-03-18 00:39:14 +04:00
|
|
|
CLASSPATH+=":$REPL_DIR/target/scala-$SCALA_VERSION/classes"
|
|
|
|
CLASSPATH+=":$EXAMPLES_DIR/target/scala-$SCALA_VERSION/classes"
|
2011-05-27 13:20:34 +04:00
|
|
|
for jar in `find $CORE_DIR/lib -name '*jar'`; do
|
2012-03-18 00:39:14 +04:00
|
|
|
CLASSPATH+=":$jar"
|
2011-05-27 13:20:34 +04:00
|
|
|
done
|
2011-07-15 06:38:25 +04:00
|
|
|
for jar in `find $FWDIR/lib_managed/jars -name '*jar'`; do
|
2012-03-18 00:39:14 +04:00
|
|
|
CLASSPATH+=":$jar"
|
2011-05-27 13:20:34 +04:00
|
|
|
done
|
2011-07-15 06:38:25 +04:00
|
|
|
for jar in `find $FWDIR/lib_managed/bundles -name '*jar'`; do
|
2012-03-18 00:39:14 +04:00
|
|
|
CLASSPATH+=":$jar"
|
2011-05-27 13:20:34 +04:00
|
|
|
done
|
2011-07-15 06:38:25 +04:00
|
|
|
for jar in `find $REPL_DIR/lib -name '*jar'`; do
|
2012-03-18 00:39:14 +04:00
|
|
|
CLASSPATH+=":$jar"
|
2010-03-30 03:17:55 +04:00
|
|
|
done
|
2012-07-09 01:00:04 +04:00
|
|
|
CLASSPATH+=":$BAGEL_DIR/target/scala-$SCALA_VERSION/classes"
|
2010-09-29 10:22:07 +04:00
|
|
|
export CLASSPATH # Needed for spark-shell
|
2010-03-30 03:17:55 +04:00
|
|
|
|
2012-07-09 01:00:04 +04:00
|
|
|
# Figure out whether to run our class with java or with the scala launcher.
|
|
|
|
# In most cases, we'd prefer to execute our process with java because scala
|
|
|
|
# creates a shell script as the parent of its Java process, which makes it
|
|
|
|
# hard to kill the child with stuff like Process.destroy(). However, for
|
|
|
|
# the Spark shell, the wrapper is necessary to properly reset the terminal
|
|
|
|
# when we exit, so we allow it to set a variable to launch with scala.
|
|
|
|
if [ "$SPARK_LAUNCH_WITH_SCALA" == "1" ]; then
|
|
|
|
RUNNER="${SCALA_HOME}/bin/scala"
|
2012-07-29 06:53:31 +04:00
|
|
|
EXTRA_ARGS="" # Java options will be passed to scala as JAVA_OPTS
|
2010-03-30 03:17:55 +04:00
|
|
|
else
|
2012-07-09 01:00:04 +04:00
|
|
|
CLASSPATH+=":$SCALA_HOME/lib/scala-library.jar"
|
|
|
|
CLASSPATH+=":$SCALA_HOME/lib/scala-compiler.jar"
|
|
|
|
CLASSPATH+=":$SCALA_HOME/lib/jline.jar"
|
|
|
|
if [ -n "$JAVA_HOME" ]; then
|
|
|
|
RUNNER="${JAVA_HOME}/bin/java"
|
|
|
|
else
|
|
|
|
RUNNER=java
|
|
|
|
fi
|
2012-07-29 06:53:31 +04:00
|
|
|
# The JVM doesn't read JAVA_OPTS by default so we need to pass it in
|
|
|
|
EXTRA_ARGS="$JAVA_OPTS"
|
2010-03-30 03:17:55 +04:00
|
|
|
fi
|
|
|
|
|
2012-07-29 06:53:31 +04:00
|
|
|
exec "$RUNNER" -cp "$CLASSPATH" $EXTRA_ARGS "$@"
|