|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# |
| 4 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 5 | +# contributor license agreements. See the NOTICE file distributed with |
| 6 | +# this work for additional information regarding copyright ownership. |
| 7 | +# The ASF licenses this file to You under the Apache License, Version 2.0 |
| 8 | +# (the "License"); you may not use this file except in compliance with |
| 9 | +# the License. You may obtain a copy of the License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, software |
| 14 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | +# See the License for the specific language governing permissions and |
| 17 | +# limitations under the License. |
| 18 | +# |
| 19 | + |
| 20 | +SPARK_HOME="$(cd `dirname $0`/..; pwd)" |
| 21 | +ORIG_ARGS=("$@") |
| 22 | + |
| 23 | +while (($#)); do |
| 24 | + if [ "$1" = "--deploy-mode" ]; then |
| 25 | + DEPLOY_MODE=$2 |
| 26 | + elif [ "$1" = "--driver-memory" ]; then |
| 27 | + DRIVER_MEMORY=$2 |
| 28 | + elif [ "$1" = "--driver-library-path" ]; then |
| 29 | + SPARK_SUBMIT_LIBRARY_PATH=$2 |
| 30 | + elif [ "$1" = "--driver-class-path" ]; then |
| 31 | + SPARK_SUBMIT_CLASSPATH=$2 |
| 32 | + elif [ "$1" = "--driver-java-options" ]; then |
| 33 | + SPARK_SUBMIT_OPTS=$2 |
| 34 | + elif [ "$1" = "--properties-file" ]; then |
| 35 | + PROPERTIES_FILE=$2 |
| 36 | + fi |
| 37 | + shift |
| 38 | +done |
| 39 | + |
| 40 | +DEPLOY_MODE=${DEPLOY_MODE:-"client"} |
| 41 | + |
| 42 | +if [ -n "$DRIVER_MEMORY" ] && [ $DEPLOY_MODE == "client" ]; then |
| 43 | + SPARK_DRIVER_MEMORY=$DRIVER_MEMORY |
| 44 | +fi |
| 45 | + |
| 46 | +PROPERTIES_FILE=${PROPERTIES_FILE:-"$SPARK_HOME/conf/spark-defaults.conf"} |
| 47 | +if [ -f $PROPERTIES_FILE ]; then |
| 48 | + DRIVER_EXTRA_JAVA_OPTIONS="spark.driver.extraJavaOptions" |
| 49 | + DRIVER_EXTRA_CLASSPATH="spark.driver.extraClassPath" |
| 50 | + DRIVER_EXTRA_LIBRARY_PATH="spark.driver.extraLibraryPath" |
| 51 | + DRIVER_EXTRA_JAVA_OPTIONS=$(sed "/^#/ d" "$PROPERTIES_FILE" | grep "$DRIVER_EXTRA_JAVA_OPTIONS" | sed "s/$DRIVER_EXTRA_JAVA_OPTIONS//g" | sed "s/^=//g") |
| 52 | + DRIVER_EXTRA_CLASSPATH=$(sed "/^#/ d" "$PROPERTIES_FILE" | grep "$DRIVER_EXTRA_CLASSPATH" | sed "s/$DRIVER_EXTRA_CLASSPATH//g" | sed "s/^=//g") |
| 53 | + DRIVER_EXTRA_LIBRARY_PATH=$(sed "/^#/ d" "$PROPERTIES_FILE" | grep "$DRIVER_EXTRA_LIBRARY_PATH" | sed "s/$DRIVER_EXTRA_LIBRARY_PATH//g" | sed "s/^=//g") |
| 54 | +fi |
| 55 | + |
| 56 | +echo "DEPLOY_MODE = $DEPLOY_MODE" |
| 57 | +echo "DRIVER_MEMORY = $DRIVER_MEMORY" |
| 58 | +echo "SPARK_DRIVER_MEMORY = $SPARK_DRIVER_MEMORY" |
| 59 | +echo "SPARK_SUBMIT_LIBRARY_PATH = $SPARK_SUBMIT_LIBRARY_PATH" |
| 60 | +echo "SPARK_SUBMIT_CLASSPATH = $SPARK_SUBMIT_CLASSPATH" |
| 61 | +echo "SPARK_SUBMIT_OPTS = $SPARK_SUBMIT_OPTS" |
| 62 | +echo "DRIVER_EXTRA_JAVA_OPTIONS = $DRIVER_EXTRA_JAVA_OPTIONS" |
| 63 | +echo "DRIVER_EXTRA_CLASSPATH = $DRIVER_EXTRA_CLASSPATH" |
| 64 | +echo "DRIVER_EXTRA_LIBRARY_PATH = $DRIVER_EXTRA_LIBRARY_PATH" |
| 65 | + |
| 66 | +echo "exec $SPARK_HOME/bin/spark-class org.apache.spark.deploy.SparkSubmit "${ORIG_ARGS[@]}"" |
| 67 | + |
0 commit comments