#!/bin/sh

# # # # # # # # # # # # # # # # # # # # # #
# @author : jiangfan
# @date : 2021-07-01 12:06:00
# # # # # # # # # # # # # # # # # # # # # #
#!/usr/bin/env bash

source ../../dmp_env.sh

dt_today=$(date -d "$ScheduleTime 1 days ago" +"%Y%m%d")
dt_slash_today=$(date -d "$ScheduleTime 1 days ago" +"%Y/%m/%d")
update_date=$(date -d "$ScheduleTime 1 days ago" +"%Y-%m-%d")

INPUT_PATH="${DM_INSTALL_LIST}_v2/${dt_slash_today}/reyun"

check_await  "${INPUT_PATH}/_SUCCESS"

OUTPUT_PATH="${RTDMP_TMP_PACKAGE_NAME_PATH}/reyun_pseudo_package_to_s3/${dt_slash_today}"

hadoop fs -rm -r "${OUTPUT_PATH}"

spark-submit --class mobvista.dmp.datasource.reyun.ReyunPseudoPackageToS3 \
 --conf spark.network.timeout=720s \
 --conf spark.driver.maxResultSize=4g \
 --conf spark.default.parallelism=2000 \
 --conf spark.sql.shuffle.partitions=2000 \
 --conf spark.sql.broadcastTimeout=1200 \
 --conf spark.sql.autoBroadcastJoinThreshold=31457280 \
 --deploy-mode cluster  --executor-memory 6g --driver-memory 4g  --executor-cores 3  --num-executors 20 \
 ../../${JAR}  \
 -output ${OUTPUT_PATH} -coalesce 100  -dt_today ${dt_today}  -update_date ${update_date}

if [[ $? -ne 0 ]];then
  exit 255
fi
