handle_rov.sh 3.5 KB

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