@Test public void parseTest() { Pair<String, String> result = UnderFileSystem.parse("/path"); Assert.assertEquals(result.getFirst(), "/"); Assert.assertEquals(result.getSecond(), "/path"); result = UnderFileSystem.parse("file: Assert.assertEquals(result.getFirst(), "/"); Assert.assertEquals(result.getSecond(), "/path"); result = UnderFileSystem.parse("tachyon: Assert.assertEquals(result.getFirst(), "tachyon: Assert.assertEquals(result.getSecond(), "/"); result = UnderFileSystem.parse("tachyon: Assert.assertEquals(result.getFirst(), "tachyon: Assert.assertEquals(result.getSecond(), "/"); result = UnderFileSystem.parse("tachyon: Assert.assertEquals(result.getFirst(), "tachyon: Assert.assertEquals(result.getSecond(), "/path"); result = UnderFileSystem.parse("tachyon-ft: Assert.assertEquals(result.getFirst(), "tachyon-ft: Assert.assertEquals(result.getSecond(), "/path"); result = UnderFileSystem.parse("hdfs: Assert.assertEquals(result.getFirst(), "hdfs: Assert.assertEquals(result.getSecond(), "/path"); result = UnderFileSystem.parse("s3: Assert.assertEquals(result.getFirst(), "s3: Assert.assertEquals(result.getSecond(), "/path"); result = UnderFileSystem.parse("s3n: Assert.assertEquals(result.getFirst(), "s3n: Assert.assertEquals(result.getSecond(), "/path"); Assert.assertEquals(UnderFileSystem.parse(null), null); Assert.assertEquals(UnderFileSystem.parse(""), null); Assert.assertEquals(UnderFileSystem.parse("anythingElse"), null); }
public static Pair<String, String> parse(String path) { if (path == null) { return null; } else if (path.startsWith(Constants.HEADER) || path.startsWith(Constants.HEADER_FT) || path.startsWith("hdfs: || path.startsWith("glusterfs: String prefix = path.substring(0, path.indexOf(": String body = path.substring(prefix.length()); if (body.contains(Constants.PATH_SEPARATOR)) { int ind = body.indexOf(Constants.PATH_SEPARATOR); return new Pair<String, String>(prefix + body.substring(0, ind), body.substring(ind)); } else { return new Pair<String, String>(path, Constants.PATH_SEPARATOR); } } else if (path.startsWith("file: String prefix = "file: String suffix = path.startsWith(prefix) ? path.substring(prefix.length()) : path; return new Pair<String, String>(Constants.PATH_SEPARATOR, suffix); } return null; }
UnderFileSystem { public static Pair<String, String> parse(String path) { if (path == null) { return null; } else if (path.startsWith(Constants.HEADER) || path.startsWith(Constants.HEADER_FT) || path.startsWith("hdfs: || path.startsWith("glusterfs: String prefix = path.substring(0, path.indexOf(": String body = path.substring(prefix.length()); if (body.contains(Constants.PATH_SEPARATOR)) { int ind = body.indexOf(Constants.PATH_SEPARATOR); return new Pair<String, String>(prefix + body.substring(0, ind), body.substring(ind)); } else { return new Pair<String, String>(path, Constants.PATH_SEPARATOR); } } else if (path.startsWith("file: String prefix = "file: String suffix = path.startsWith(prefix) ? path.substring(prefix.length()) : path; return new Pair<String, String>(Constants.PATH_SEPARATOR, suffix); } return null; } }
UnderFileSystem { public static Pair<String, String> parse(String path) { if (path == null) { return null; } else if (path.startsWith(Constants.HEADER) || path.startsWith(Constants.HEADER_FT) || path.startsWith("hdfs: || path.startsWith("glusterfs: String prefix = path.substring(0, path.indexOf(": String body = path.substring(prefix.length()); if (body.contains(Constants.PATH_SEPARATOR)) { int ind = body.indexOf(Constants.PATH_SEPARATOR); return new Pair<String, String>(prefix + body.substring(0, ind), body.substring(ind)); } else { return new Pair<String, String>(path, Constants.PATH_SEPARATOR); } } else if (path.startsWith("file: String prefix = "file: String suffix = path.startsWith(prefix) ? path.substring(prefix.length()) : path; return new Pair<String, String>(Constants.PATH_SEPARATOR, suffix); } return null; }  }
UnderFileSystem { public static Pair<String, String> parse(String path) { if (path == null) { return null; } else if (path.startsWith(Constants.HEADER) || path.startsWith(Constants.HEADER_FT) || path.startsWith("hdfs: || path.startsWith("glusterfs: String prefix = path.substring(0, path.indexOf(": String body = path.substring(prefix.length()); if (body.contains(Constants.PATH_SEPARATOR)) { int ind = body.indexOf(Constants.PATH_SEPARATOR); return new Pair<String, String>(prefix + body.substring(0, ind), body.substring(ind)); } else { return new Pair<String, String>(path, Constants.PATH_SEPARATOR); } } else if (path.startsWith("file: String prefix = "file: String suffix = path.startsWith(prefix) ? path.substring(prefix.length()) : path; return new Pair<String, String>(Constants.PATH_SEPARATOR, suffix); } return null; }  static UnderFileSystem get(String path); static UnderFileSystem get(String path, Object conf); static Pair<String, String> parse(String path); abstract void close(); abstract OutputStream create(String path); abstract OutputStream create(String path, int blockSizeByte); abstract OutputStream create(String path, short replication, int blockSizeByte); abstract boolean delete(String path, boolean recursive); abstract boolean exists(String path); abstract long getBlockSizeByte(String path); abstract Object getConf(); abstract List<String> getFileLocations(String path); abstract List<String> getFileLocations(String path, long offset); abstract long getFileSize(String path); abstract long getModificationTimeMs(String path); abstract long getSpace(String path, SpaceType type); abstract boolean isFile(String path); abstract String[] list(String path); abstract boolean mkdirs(String path, boolean createParent); abstract InputStream open(String path); abstract boolean rename(String src, String dst); abstract void setConf(Object conf); abstract void setPermission(String path, String posixPerm); }
UnderFileSystem { public static Pair<String, String> parse(String path) { if (path == null) { return null; } else if (path.startsWith(Constants.HEADER) || path.startsWith(Constants.HEADER_FT) || path.startsWith("hdfs: || path.startsWith("glusterfs: String prefix = path.substring(0, path.indexOf(": String body = path.substring(prefix.length()); if (body.contains(Constants.PATH_SEPARATOR)) { int ind = body.indexOf(Constants.PATH_SEPARATOR); return new Pair<String, String>(prefix + body.substring(0, ind), body.substring(ind)); } else { return new Pair<String, String>(path, Constants.PATH_SEPARATOR); } } else if (path.startsWith("file: String prefix = "file: String suffix = path.startsWith(prefix) ? path.substring(prefix.length()) : path; return new Pair<String, String>(Constants.PATH_SEPARATOR, suffix); } return null; }  static UnderFileSystem get(String path); static UnderFileSystem get(String path, Object conf); static Pair<String, String> parse(String path); abstract void close(); abstract OutputStream create(String path); abstract OutputStream create(String path, int blockSizeByte); abstract OutputStream create(String path, short replication, int blockSizeByte); abstract boolean delete(String path, boolean recursive); abstract boolean exists(String path); abstract long getBlockSizeByte(String path); abstract Object getConf(); abstract List<String> getFileLocations(String path); abstract List<String> getFileLocations(String path, long offset); abstract long getFileSize(String path); abstract long getModificationTimeMs(String path); abstract long getSpace(String path, SpaceType type); abstract boolean isFile(String path); abstract String[] list(String path); abstract boolean mkdirs(String path, boolean createParent); abstract InputStream open(String path); abstract boolean rename(String src, String dst); abstract void setConf(Object conf); abstract void setPermission(String path, String posixPerm);  }