sqoop job shell script execute parallel in oozie

烈酒焚心 提交于 2019-12-01 13:56:01

As @Samson Scharfrichter mentioned you can start parallel jobs in the shell script. Make a function runJob() in shell and run it in parallel. Use this template:

#!/bin/bash

runJob() {
tableName="$1"
#add other parameters here

#call sqoop here or do something else
#write command logs
#etc, etc
#return 0 on success, return 1 on fail

return 0
}

#Run parallel processes and wait for their completion

#Add loop here or add more calls
runJob $table_name &
runJob $table_name2 &
runJob $table_name3 &
#Note the ampersand in above commands says to create parallel process

#Now wait for all processes to complete
FAILED=0

for job in `jobs -p`
do
   echo "job=$job"
   wait $job || let "FAILED+=1"
done

if [ "$FAILED" != "0" ]; then
    echo "Execution FAILED!  ($FAILED)"
    #Do something here, log or send messege, etc

    exit 1
fi

#All processes are completed successfully!
#Do something here
echo "Done successfully"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!