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

SOURCES="cn overseas"
PLTS="ios android"

ID_MAPPING_PATH=${ADS_DEVICE_ID_MAPPING}/${date_path}

for sour in ${SOURCES}; do
  for plt in ${PLTS}; do
    check_await "${ID_MAPPING_PATH}/$sour/$plt/result/_SUCCESS"
  done
done

spark-submit --class mobvista.dmp.datasource.id_mapping.IDMappingWrite \
  --name "IDMappingWrite.${LOG_TIME}" \
  --conf spark.yarn.executor.memoryOverhead=2048 \
  --conf spark.network.timeout=720s \
  --conf spark.sql.shuffle.partitions=2000 \
  --conf spark.default.parallelism=2000 \
  --deploy-mode cluster --executor-memory 8g --driver-memory 6g --executor-cores 4 --num-executors 8 \
  ../${JAR} -date ${LOG_TIME}

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