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

echo "dayTime is "${daytime}

echo "tag is "${tag}

sh dir.sh ${daytime}

numPartitions=50

total=1

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

MAIN_CLASS=com.uml.tech.spark.SparkApp

executor_cores=1

num_executors=3

executor_memory=4G

for jar in ../lib/*.jar
do
  if [ ${jar} != ${JAR_PATH} ] ; then
    LIBJARS=${jar},${LIBJARS}
  fi
done

appName="azkaban-statistics-farm-"${tag}"."${daytime}

echo "app name : "${appName}

spark-submit \
  --master yarn \
  --deploy-mode cluster \
  --class ${MAIN_CLASS} \
  --conf spark.app.name=${appName} \
  --jars ${LIBJARS} \
  --conf spark.serializer=org.apache.spark.serializer.KryoSerializer \
  --conf spark.shuffle.memoryFraction=0.4 \
  --conf spark.storage.memoryFraction=0.3 \
  --conf spark.driver.memory=2G \
  --executor-cores ${executor_cores} \
  --num-executors ${num_executors} \
  --executor-memory ${executor_memory} \
  ${JAR_PATH} \
  ${tag} ${daytime} ${numPartitions} ${total}
