|
| 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 | +# Gather all all spark-submit options into SUBMISSION_OPTS |
| 21 | +function gatherSparkSubmitOpts() { |
| 22 | + |
| 23 | + if [ -z "$SUBMIT_USAGE_FUNCTION" ]; then |
| 24 | + echo "Function for printing usage of $0 is not set." 1>&2 |
| 25 | + echo "Please set usage function to shell variable 'SUBMIT_USAGE_FUNCTION' in $0" 1>&2 |
| 26 | + exit 1 |
| 27 | + fi |
| 28 | + |
| 29 | + # NOTE: If you add or remove spark-sumbmit options, |
| 30 | + # modify NOT ONLY this script but also SparkSubmitArgument.scala |
| 31 | + SUBMISSION_OPTS=() |
| 32 | + APPLICATION_OPTS=() |
| 33 | + while (($#)); do |
| 34 | + case "$1" in |
| 35 | + --master | --deploy-mode | --class | --name | --jars | --py-files | --files | \ |
| 36 | + --conf | --properties-file | --driver-memory | --driver-java-options | \ |
| 37 | + --driver-library-path | --driver-class-path | --executor-memory | --driver-cores | \ |
| 38 | + --total-executor-cores | --executor-cores | --queue | --num-executors | --archives) |
| 39 | + if [[ $# -lt 2 ]]; then |
| 40 | + "$SUBMIT_USAGE_FUNCTION" |
| 41 | + exit 1; |
| 42 | + fi |
| 43 | + SUBMISSION_OPTS+=("$1"); shift |
| 44 | + SUBMISSION_OPTS+=("$1"); shift |
| 45 | + ;; |
| 46 | + |
| 47 | + --verbose | -v | --supervise) |
| 48 | + SUBMISSION_OPTS+=("$1"); shift |
| 49 | + ;; |
| 50 | + |
| 51 | + *) |
| 52 | + APPLICATION_OPTS+=("$1"); shift |
| 53 | + ;; |
| 54 | + esac |
| 55 | + done |
| 56 | + |
| 57 | + export SUBMISSION_OPTS |
| 58 | + export APPLICATION_OPTS |
| 59 | +} |
0 commit comments