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 1519864) +++ 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 1519864) +++ hcatalog/webhcat/svr/src/main/java/org/apache/hcatalog/templeton/tool/TempletonControllerJob.java (working copy) @@ -154,6 +154,10 @@ String statusdir = conf.get(STATUSDIR_NAME); + if (statusdir != null) { + statusdir = TempletonUtils.addUserHomeDirectoryIfApplicable(statusdir, conf.get("user.name"), conf); + } + ExecutorService pool = Executors.newCachedThreadPool(); executeWatcher(pool, conf, context.getJobID(), proc.getInputStream(), statusdir, STDOUT_FNAME); 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 1519864) +++ hcatalog/webhcat/svr/src/main/java/org/apache/hcatalog/templeton/tool/TempletonUtils.java (working copy) @@ -36,6 +36,7 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.hdfs.DistributedFileSystem; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.util.StringUtils; import org.apache.hcatalog.templeton.UgiFactory; @@ -210,7 +211,24 @@ return false; } } + + public static String addUserHomeDirectoryIfApplicable(String origPathStr, String user, Configuration conf) throws IOException { + Path path = new Path(origPathStr); + String result = origPathStr; + // shortcut for s3/asv + // If path contains scheme, user should mean an absolute path, + // However, path.isAbsolute tell us otherwise. + // So we skip conversion for non-hdfs. + if (!(path.getFileSystem(conf) instanceof DistributedFileSystem)) { + return result; + } + if (!path.isAbsolute()) { + result = "/user/" + user + "/" + origPathStr; + } + return result; + } + public static Path hadoopFsPath(final String fname, final Configuration conf, String user) throws URISyntaxException, IOException, InterruptedException { @@ -227,6 +245,7 @@ } }); + fname = addUserHomeDirectoryIfApplicable(fname, user, conf); URI u = new URI(fname); Path p = new Path(u).makeQualified(defaultFs);