#!/bin/bash

source ../dmp_env.sh

today=${ScheduleTime:-$1}

date=$(date +"%Y%m%d" -d "-1 day $today")
date_path=$(date +%Y/%m/%d -d "-1 day $today")

OUTPUT="s3://mob-emr-test/dataplatform/DataWareHouse/data/dev/device_region_result/${date_path}"

spark-submit --class mobvista.dmp.datasource.rtdmp.DeviceRegionResult \
     --name "DeviceRegionResult.wangjf.${date}" \
     --conf spark.sql.shuffle.partitions=1000 \
     --conf spark.default.parallelism=1000 \
     --conf spark.kryoserializer.buffer.max=256m \
     --conf spark.executor.extraJavaOptions="-XX:+UseG1GC" \
     --files ${HIVE_SITE_PATH} \
     --jars ${SPARK_HOME}/auxlib/Common-SerDe-1.0-SNAPSHOT.jar \
     --master yarn --deploy-mode cluster --executor-memory 4g --driver-memory 4g  --executor-cores 2  --num-executors 50 \
     ../${JAR} -date ${date} -output ${OUTPUT}

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