handle_rov.sh 3.1 KB

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