#!/bin/bash
if [ $# == 1 ] ; then
    daytime=`date -d "1 day ago" "+%Y%m%d"`
    tag=$1
elif [ $# == 2 ] ; then
  tag=$1
  daytime=$2
else
  echo "输入参数错误 ！"
  exit
fi
echo "dayTime is "${daytime}

echo "tag is "${tag}

numPartitions=50

total=1

JAR_PATH=../lib/azkaban-statistics-farm-tdengine-1.0.0.jar

MAIN_CLASS=uml.tech.bigdata.spark.SparkApp

executor_cores=1

num_executors=4

executor_memory=2G
FILE=../conf/config.json
for jar in ../lib/*.jar
do
  if [ ${jar} != ${JAR_PATH} ] ; then
    LIBJARS=${jar},${LIBJARS}
  fi
done
GUAVA_JAR_PATH=guava-30.1.1-jre.jar
appName="azkaban-statistics-farm-tdengine-"${tag}"."${daytime}

echo "app name : "${appName}

spark-submit \
  --master yarn \
  --deploy-mode cluster \
  --class ${MAIN_CLASS} \
  --conf spark.app.name=${appName} \
  --jars ${LIBJARS} \
  --files ${FILE} \
  --conf spark.serializer=org.apache.spark.serializer.KryoSerializer \
  --conf spark.driver.memory=2G \
  --conf spark.yarn.executor.memoryOverhead=1024 \
  --executor-cores ${executor_cores} \
  --num-executors ${num_executors} \
  --executor-memory ${executor_memory} \
  --conf spark.driver.extraClassPath=${GUAVA_JAR_PATH} \
  --conf spark.executor.extraClassPath=${GUAVA_JAR_PATH} \
  ${JAR_PATH} \
  ${tag} ${daytime} ${numPartitions} ${total}
