#!/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")

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

spark-submit --class mobvista.dmp.datasource.rtdmp.DeviceRegionWrite \
     --name "DeviceRegionWrite.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" \
     --jars ${SPARK_HOME}/auxlib/Common-SerDe-1.0-SNAPSHOT.jar \
     --master yarn --deploy-mode cluster --executor-memory 4g --driver-memory 4g  --executor-cores 3  --num-executors 4 \
     ../${JAR} -input ${INPUT}

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