Skip to content

Instantly share code, notes, and snippets.

@zapstar
Created April 7, 2015 07:15
Show Gist options
  • Select an option

  • Save zapstar/519bd6b4401a074e1033 to your computer and use it in GitHub Desktop.

Select an option

Save zapstar/519bd6b4401a074e1033 to your computer and use it in GitHub Desktop.
Run Spark Job by looking at the build File
#!/bin/sh
# NOTE: Make sure we have $SPARK_HOME set...
# Identify the build file
BUILD_FILE=`ls *.sbt`
# Find out the required variable from the build file
PROJECT_NAME=`grep name $BUILD_FILE | cut -d" " -f 3- | sed -e 's/ /-/g' | awk '{ gsub(/"/, "", $0); print tolower($0) }'`
SCALA_VERSION=`grep scalaVersion $BUILD_FILE | awk '{ gsub(/"/, "", $3); print $3 }' | rev | cut -d '.' -f 2- | rev`
APP_VERSION=`grep version $BUILD_FILE | awk '{ gsub(/"/, "", $3); print $3 }'`
# Start the Spark job
$SPARK_HOME/bin/spark-submit --master local[4] --class "WordCount" target/scala-${SCALA_VERSION}/${PROJECT_NAME}_${SCALA_VERSION}-${APP_VERSION}.jar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment