Index: hcatalog/webhcat/svr/src/test/java/org/apache/hcatalog/templeton/tool/TestTempletonUtils.java =================================================================== --- hcatalog/webhcat/svr/src/test/java/org/apache/hcatalog/templeton/tool/TestTempletonUtils.java (revision 1475939) +++ hcatalog/webhcat/svr/src/test/java/org/apache/hcatalog/templeton/tool/TestTempletonUtils.java (working copy) @@ -118,6 +118,16 @@ // This is our problem -- it means the configuration was wrong. e.printStackTrace(); } + try { + TempletonUtils.hadoopFsPath("a", new Configuration(), "teddybear"); + Assert.fail("Should not have found /user/teddybear/a"); + } catch (FileNotFoundException e) { + Assert.assertTrue(e.getMessage().contains("/user/teddybear/a")); + } catch (Exception e) { + // This is our problem -- it means the configuration was wrong. + e.printStackTrace(); + Assert.fail("Get wrong exception: " + e.getMessage()); + } } @Test Index: hcatalog/webhcat/svr/src/main/java/org/apache/hcatalog/templeton/tool/TempletonControllerJob.java =================================================================== --- hcatalog/webhcat/svr/src/main/java/org/apache/hcatalog/templeton/tool/TempletonControllerJob.java (revision 1475939) +++ hcatalog/webhcat/svr/src/main/java/org/apache/hcatalog/templeton/tool/TempletonControllerJob.java (working copy) @@ -157,6 +157,9 @@ conf.get(OVERRIDE_CLASSPATH)); String statusdir = conf.get(STATUSDIR_NAME); + if (statusdir != null) { + statusdir = TempletonUtils.addUserHomeDirectoryIfApplicable(statusdir, conf.get("user.name")); + } Counter cnt = context.getCounter(ControllerCounters.SIMPLE_COUNTER); ExecutorService pool = Executors.newCachedThreadPool(); Index: hcatalog/webhcat/svr/src/main/java/org/apache/hcatalog/templeton/tool/TempletonUtils.java =================================================================== --- hcatalog/webhcat/svr/src/main/java/org/apache/hcatalog/templeton/tool/TempletonUtils.java (revision 1475939) +++ hcatalog/webhcat/svr/src/main/java/org/apache/hcatalog/templeton/tool/TempletonUtils.java (working copy) @@ -209,6 +209,15 @@ return false; } } + + public static String addUserHomeDirectoryIfApplicable(String origPathStr, String user) { + Path path = new Path(origPathStr); + String result = origPathStr; + if (!path.isAbsolute()) { + result = "/user/" + user + "/" + origPathStr; + } + return result; + } public static Path hadoopFsPath(String fname, Configuration conf, String user) throws URISyntaxException, FileNotFoundException, IOException, @@ -230,6 +239,7 @@ } }); + fname = addUserHomeDirectoryIfApplicable(fname, user); URI u = new URI(fname); Path p = new Path(u).makeQualified(defaultFs);