handle_rov.sh 3.8 KB

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