handle_rov.sh 3.3 KB

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