Created
March 10, 2014 13:49
-
-
Save prateek/9465243 to your computer and use it in GitHub Desktop.
Code Snippet for Hooking Java Drivers in Oozie
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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