title: Shutdown Hook for spark batch application
body: <p>I have a spark scala batch application. It commits the run status to mariadb when it completes or fails.
  I want to implement an edge case when the application is killed by say &quot;yarn application -kill [appid]&quot;, I want to update the status as failed in mariadb table.</p>
  <p>I planned to use &quot;ShutdownHookManager&quot; for the same but I see it is private in spark and the scala sys.ShutdownHookThread does not work as well.</p>
  <p>Can somebody guide me on the shutdown hook handling of killing spark batch application. Not much resources on the same.</p>