forked from Sunbird-Lern/data-products
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlern-run-job.j2
78 lines (67 loc) · 3.51 KB
/
lern-run-job.j2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env bash
export SPARK_HOME={{ analytics.home }}/spark-{{ spark_version }}-bin-hadoop2.7
export MODELS_HOME={{ analytics.home }}/models-{{ model_version }}
export DP_LOGS={{ analytics.home }}/logs/lern-data-products
## Job to run daily
cd {{ analytics.home }}/scripts
source lern-model-config.sh
today=$(date "+%Y-%m-%d")
libs_path="{{ analytics.home }}/models-{{ model_version }}/lern-data-products-1.0"
file_path="lern{{ env }}.conf"
get_report_job_model_name(){
case "$1" in
"course-enrollment-report") echo 'org.sunbird.lms.job.report.CourseEnrollmentJob'
;;
"course-consumption-report") echo 'org.sunbird.lms.job.report.CourseConsumptionJob'
;;
"admin-geo-reports") echo 'org.sunbird.userorg.job.report.StateAdminGeoReportJob'
;;
"admin-user-reports") echo 'org.sunbird.userorg.job.report.StateAdminReportJob'
;;
"userinfo-exhaust") echo 'org.sunbird.lms.exhaust.collection.UserInfoExhaustJob'
;;
"response-exhaust") echo 'org.sunbird.lms.exhaust.collection.ResponseExhaustJob'
;;
"response-exhaust-v2") echo 'org.sunbird.lms.exhaust.collection.ResponseExhaustJobV2'
;;
"progress-exhaust") echo 'org.sunbird.lms.exhaust.collection.ProgressExhaustJob'
;;
"progress-exhaust-v2") echo 'org.sunbird.lms.exhaust.collection.ProgressExhaustJobV2'
;;
"cassandra-migration") echo 'org.sunbird.lms.updater.CassandraMigratorJob'
;;
"collection-summary-report") echo 'org.sunbird.lms.audit.CollectionSummaryJob'
;;
"program-collection-summary-report") echo 'org.sunbird.lms.audit.CollectionSummaryJob'
;;
"collection-summary-report-v2") echo 'org.sunbird.lms.audit.CollectionSummaryJobV2'
;;
"assessment-score-metric-correction") echo 'org.sunbird.lms.audit.AssessmentScoreCorrectionJob'
;;
"course-batch-status-updater") echo 'org.sunbird.lms.audit.CourseBatchStatusUpdaterJob'
;;
"collection-reconciliation-job") echo 'org.sunbird.lms.audit.CollectionReconciliationJob'
;;
"assessment-correction") echo 'org.sunbird.lms.job.report.AssessmentCorrectionJob'
;;
"score-metric-migration-job") echo 'org.sunbird.lms.audit.ScoreMetricMigrationJob'
;;
"assessment-archival") echo 'org.sunbird.analytics.job.report.AssessmentArchivalJob'
;;
"assessment-archived-removal") echo 'org.sunbird.analytics.job.report.AssessmentArchivalJob'
;;
"user-cache-indexer-job") echo 'org.sunbird.userorg.job.report.UserCacheIndexerJob'
;;
"old-certificate-migration-job") echo 'org.sunbird.lms.audit.OldCertificateMigrationJob'
;;
*) echo $1
;;
esac
}
if [ ! -z "$1" ]; then job_id=$(get_report_job_model_name $1); fi
if [ ! -z "$1" ]; then job_config=$(config $1 $2); else job_config="$2"; fi
if [ ! -z "$2" ]; then batchIds=";$2"; else batchIds=""; fi
echo "Starting the job - $1" >> "$DP_LOGS/$today-job-execution.log"
echo "Job modelName - $job_id" >> "$DP_LOGS/$today-job-execution.log"
nohup $SPARK_HOME/bin/spark-submit --conf spark.driver.extraJavaOptions="-Dconfig.file=$MODELS_HOME/$file_path" --conf spark.executor.extraJavaOptions="-Dconfig.file=$MODELS_HOME/$file_path" --master local[*] --jars $(echo ${libs_path}/lib/*.jar | tr ' ' ','),$MODELS_HOME/analytics-framework-2.0.jar,$MODELS_HOME/scruid_2.12-2.5.0.jar,$MODELS_HOME/batch-models-2.0.jar --class org.ekstep.analytics.job.JobExecutor $MODELS_HOME/batch-models-2.0.jar --model "$job_id" --config "$job_config$batchIds" >> "$DP_LOGS/$today-job-execution.log" 2>&1
echo "Job execution completed - $1" >> "$DP_LOGS/$today-job-execution.log"