#! /bin/bash

source ../dmp_env.sh

LOG_TIME=$(date +%Y-%m-%d -d "-1 day $ScheduleTime")

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

ADN_REQUEST_INPUT_PATH=${ID_MAPPING}/${date_path}/adn_request

DSP_INPUT_PATH=${ID_MAPPING}/${date_path}/dsp_req

check_await "${ADN_REQUEST_INPUT_PATH}/_SUCCESS"

check_await "${DSP_INPUT_PATH}/_SUCCESS"

OUTPUT_PATH=${ADS_DEVICE_ID_MAPPING}/${date_path}

country="US"

platform="ios"

spark-submit --class mobvista.dmp.datasource.id_mapping.IDMappingGraphx \
  --name "IDMappingGraphx.${LOG_TIME}.${country}.${platform}" \
  --conf spark.yarn.executor.memoryOverhead=2048 \
  --conf spark.network.timeout=720s \
  --conf spark.sql.shuffle.partitions=5000 \
  --conf spark.default.parallelism=5000 \
  --conf spark.executor.extraJavaOptions="-XX:+UseG1GC" \
  --master yarn --deploy-mode cluster --executor-memory 12g --driver-memory 8g --executor-cores 5 --num-executors 100 \
  ../${JAR} -date ${LOG_TIME} -country ${country} -platform ${platform} -output ${OUTPUT_PATH} -coalesce 500

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