handle_rov.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/bin/sh
  2. set -ex
  3. # 原始数据table name
  4. #table='alg_recsys_sample_all'
  5. table='alg_recsys_sample_all_test'
  6. # 处理分区配置
  7. beginStr="$(date -d '1 days ago' +%Y%m%d)"
  8. endStr="$(date -d '1 days ago' +%Y%m%d)"
  9. beginHhStr=08
  10. endHhStr=08
  11. # 0 判断上游表是否生产完成,最长等待到12点
  12. # shellcheck disable=SC2039
  13. source /root/anaconda3/bin/activate py37
  14. echo "----------step1------------开始校验是否生产完数据,分区信息:beginStr:${beginStr}${beginHhStr},endStr:${endStr}${endHhStr}"
  15. while true; do
  16. python_return_code=$(python /root/joe/recommend-emr-dataprocess/qiaojialiang/checkHiveDataUtil.py --table ${table} --beginStr ${beginStr}${beginHhStr} --endStr ${endStr}${endHhStr})
  17. echo "python 返回值:${python_return_code}"
  18. if [ $python_return_code -eq 0 ]; then
  19. echo "Python程序返回0,校验存在数据,退出循环。"
  20. break
  21. fi
  22. echo "Python程序返回非0值,不存在数据,等待五分钟后再次调用。"
  23. sleep 300
  24. current_hour=$(date +%H)
  25. current_minute=$(date +%M)
  26. # shellcheck disable=SC2039
  27. if (( current_hour > max_hour || (current_hour == max_hour && current_minute >= max_minute) )); then
  28. echo "最长等待时间已到,失败:${current_hour}-${current_minute}"
  29. exit 1
  30. fi
  31. done
  32. # 1 生产原始数据
  33. echo "----------step2------------开始根据${table}生产原始数据"
  34. /opt/apps/SPARK2/spark-2.4.8-hadoop3.2-1.0.8/bin/spark-class2 org.apache.spark.deploy.SparkSubmit \
  35. --class com.aliyun.odps.spark.examples.makedata_qiao.makedata_13_originData_20240705 \
  36. --master yarn --driver-memory 1G --executor-memory 2G --executor-cores 1 --num-executors 16 \
  37. ../target/spark-examples-1.0.0-SNAPSHOT-shaded.jar \
  38. tablePart:64 repartition:32 \
  39. beginStr:${beginStr}${beginHhStr} endStr:${endStr}${endHhStr} \
  40. savePath:/dw/recommend/model/13_sample_data/ \
  41. table:${table}
  42. if [ $? -ne 0 ]; then
  43. echo "Spark原始样本生产任务执行失败"
  44. exit 1
  45. else
  46. echo "spark原始样本生产执行成功"
  47. fi
  48. # 2 特征值拼接
  49. /opt/apps/SPARK2/spark-2.4.8-hadoop3.2-1.0.8/bin/spark-class2 org.apache.spark.deploy.SparkSubmit \
  50. --class com.aliyun.odps.spark.examples.makedata_qiao.makedata_14_valueData_20240705 \
  51. --master yarn --driver-memory 1G --executor-memory 3G --executor-cores 1 --num-executors 32 \
  52. ../target/spark-examples-1.0.0-SNAPSHOT-shaded.jar \
  53. readPath:/dw/recommend/model/13_sample_data/ \
  54. savePath:/dw/recommend/model/14_feature_data/ \
  55. beginStr:${beginStr} endStr:${endStr} repartition:1000
  56. if [ $? -ne 0 ]; then
  57. echo "Spark特征值拼接处理任务执行失败"
  58. exit 1
  59. else
  60. echo "spark特征值拼接处理执行成功"
  61. fi
  62. # 3 特征分桶
  63. echo "----------step3------------根据特征分桶生产重打分特征数据"
  64. /opt/apps/SPARK2/spark-2.4.8-hadoop3.2-1.0.8/bin/spark-class2 org.apache.spark.deploy.SparkSubmit \
  65. --class com.aliyun.odps.spark.examples.makedata_qiao.makedata_16_bucketData_20240705 \
  66. --master yarn --driver-memory 2G --executor-memory 4G --executor-cores 1 --num-executors 16 \
  67. ../target/spark-examples-1.0.0-SNAPSHOT-shaded.jar \
  68. beginStr:${beginStr} endStr:${endStr} repartition:1000
  69. if [ $? -ne 0 ]; then
  70. echo "Spark特征分桶处理任务执行失败"
  71. exit 1
  72. else
  73. echo "spark特征分桶处理执行成功"
  74. fi