Repository: kylin Updated Branches: refs/heads/KYLIN-2351 [created] aab7178c4
KYLIN-2351 enforce Path schema Project: http://git-wip-us.apache.org/repos/asf/kylin/repo Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/aab7178c Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/aab7178c Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/aab7178c Branch: refs/heads/KYLIN-2351 Commit: aab7178c44b37f47a4d5b3e2ac74581de5b11546 Parents: 979ceeb Author: Li Yang <liy...@apache.org> Authored: Thu Jan 5 11:26:02 2017 +0800 Committer: Li Yang <liy...@apache.org> Committed: Thu Jan 5 11:26:02 2017 +0800 ---------------------------------------------------------------------- .../org/apache/kylin/engine/mr/HadoopUtil.java | 23 +++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kylin/blob/aab7178c/engine-mr/src/main/java/org/apache/kylin/engine/mr/HadoopUtil.java ---------------------------------------------------------------------- diff --git a/engine-mr/src/main/java/org/apache/kylin/engine/mr/HadoopUtil.java b/engine-mr/src/main/java/org/apache/kylin/engine/mr/HadoopUtil.java index 3d29a02..3119c1e 100644 --- a/engine-mr/src/main/java/org/apache/kylin/engine/mr/HadoopUtil.java +++ b/engine-mr/src/main/java/org/apache/kylin/engine/mr/HadoopUtil.java @@ -72,17 +72,30 @@ public class HadoopUtil { } public static FileSystem getWorkingFileSystem(Configuration conf) throws IOException { - return getFileSystem(KylinConfig.getInstanceFromEnv().getHdfsWorkingDirectory(), conf); + Path workingPath = new Path(KylinConfig.getInstanceFromEnv().getHdfsWorkingDirectory()); + return getFileSystem(workingPath, conf); } public static FileSystem getFileSystem(String path) throws IOException { - return getFileSystem(path, getCurrentConfiguration()); + return getFileSystem(new Path(makeURI(path))); } - - static FileSystem getFileSystem(String path, Configuration conf) throws IOException { - return FileSystem.get(makeURI(path), conf); + + public static FileSystem getFileSystem(Path path) throws IOException { + Configuration conf = getCurrentConfiguration(); + return getFileSystem(path, conf); } + public static FileSystem getFileSystem(Path path, Configuration conf) { + if (StringUtils.isBlank(path.toUri().getScheme())) + throw new IllegalArgumentException("Path must be qualified: " + path); + + try { + return path.getFileSystem(conf); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + public static URI makeURI(String filePath) { try { return new URI(fixWindowsPath(filePath));