Skip to content

Instantly share code, notes, and snippets.

@prateek
Created March 10, 2014 13:49
Show Gist options
  • Save prateek/9465243 to your computer and use it in GitHub Desktop.
Save prateek/9465243 to your computer and use it in GitHub Desktop.
Code Snippet for Hooking Java Drivers in Oozie
public class DriverHook implements Runnable{
static public DriverHookNewApi create(Job job){
return new DriverHookNewApi(job); }
Job job;
private DriverHookNewApi(Job job){
this.job = job; }
public void run(){
System.out.println("Hello from MyHook");
if(job == null)
throw new NullPointerException("err msg");
try{
JobID hdpJobID = job.getJobID(); if(!job.isComplete())
job.killJob();
}
catch (IOException e){
}
} }
Runnable myHook = DriverHook.create(job); Thread hookThr = new Thread(myHook); Runtime.getRuntime().addShutdownHook(hookThr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment