diff --git shims/0.23/src/main/java/org/apache/hadoop/mapred/WebHCatJTShim23.java shims/0.23/src/main/java/org/apache/hadoop/mapred/WebHCatJTShim23.java index d0a4bf7..2bc3ca4 100644 --- shims/0.23/src/main/java/org/apache/hadoop/mapred/WebHCatJTShim23.java +++ shims/0.23/src/main/java/org/apache/hadoop/mapred/WebHCatJTShim23.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.net.URI; +import java.security.PrivilegedExceptionAction; public class WebHCatJTShim23 implements WebHCatJTShim { private JobClient jc; @@ -31,10 +32,23 @@ /** * Create a connection to the Job Tracker. */ - public WebHCatJTShim23(Configuration conf, final UserGroupInformation ugi) + public WebHCatJTShim23(final Configuration conf, final UserGroupInformation ugi) throws IOException { - - jc = new JobClient(conf); + try { + jc = ugi.doAs(new PrivilegedExceptionAction() { + public JobClient run() throws IOException, InterruptedException { + return ugi.doAs(new PrivilegedExceptionAction() { + public JobClient run() throws IOException { + //create this in doAs() so that it gets a security context based passed in 'ugi' + return new JobClient(conf); + } + }); + } + }); + } + catch(InterruptedException ex) { + throw new RuntimeException("Failed to create JobClient", ex); + } } /**