Skip to content

Instantly share code, notes, and snippets.

@oivoodoo
Created November 1, 2018 09:46
Show Gist options
  • Save oivoodoo/4c1ef67544b2c5023c249f21813392af to your computer and use it in GitHub Desktop.
Save oivoodoo/4c1ef67544b2c5023c249f21813392af to your computer and use it in GitHub Desktop.
puts('[spark] remove marker file by ensuring to trigger graceful stop spark-etl jobs')
`hadoop fs -rm -r /tmp/datalake.marker.*`
while true
app_id = `yarn application -list | grep datalake.Main | awk -F " " '{print $1}'`.strip
status = `yarn application -list | grep datalake.Main | awk -F " " '{print $6}'`.strip
puts("[spark] application status: #{status}")
if status == "ACCEPTED"
puts("[spark] killing #{app_id}")
`yarn application -kill #{app_id}`
break
end
if status != 'RUNNING'
puts("[spark] application '#{app_id}' was stopped")
break
end
puts("[spark] application '#{app_id}' waiting graceful shutdown...")
sleep(20)
end
puts('[spark] remove checkpoint directory because of rolling out the new application version')
`hadoop fs -rm -r /tmp/spark-etl/`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment