@Test public void testGetJobFoldersTypicalHistoryFolder() { Path histFolder = new Path(Constants.TONY_CORE_SRC + "test/resources/typicalHistFolder"); String regex = "^job.*"; List<Path> expectedRes = new ArrayList<>(); for (int i = 1; i < 6; ++i) { String sb = "file:" + System.getProperty("user.dir") + "/tony-core/src/test/resources/typicalHistFolder/job" + i; expectedRes.add(new Path(sb)); } List<Path> actualRes = HdfsUtils.getJobDirs(fs, histFolder, regex); Collections.sort(actualRes); assertEquals(actualRes, expectedRes); assertEquals(actualRes.size(), expectedRes.size()); }
public static List<Path> getJobDirs(FileSystem fs, Path curr, String regex) { List<Path> result = new ArrayList<>(); List<FileStatus> dirs = getDirectories(fs, curr); dirs.forEach(dir -> { if (isJobFolder(dir.getPath(), regex)) { result.add(dir.getPath()); } result.addAll(getJobDirs(fs, dir.getPath(), regex)); }); return result; }
HdfsUtils { public static List<Path> getJobDirs(FileSystem fs, Path curr, String regex) { List<Path> result = new ArrayList<>(); List<FileStatus> dirs = getDirectories(fs, curr); dirs.forEach(dir -> { if (isJobFolder(dir.getPath(), regex)) { result.add(dir.getPath()); } result.addAll(getJobDirs(fs, dir.getPath(), regex)); }); return result; } }
HdfsUtils { public static List<Path> getJobDirs(FileSystem fs, Path curr, String regex) { List<Path> result = new ArrayList<>(); List<FileStatus> dirs = getDirectories(fs, curr); dirs.forEach(dir -> { if (isJobFolder(dir.getPath(), regex)) { result.add(dir.getPath()); } result.addAll(getJobDirs(fs, dir.getPath(), regex)); }); return result; } private  HdfsUtils(); }
HdfsUtils { public static List<Path> getJobDirs(FileSystem fs, Path curr, String regex) { List<Path> result = new ArrayList<>(); List<FileStatus> dirs = getDirectories(fs, curr); dirs.forEach(dir -> { if (isJobFolder(dir.getPath(), regex)) { result.add(dir.getPath()); } result.addAll(getJobDirs(fs, dir.getPath(), regex)); }); return result; } private  HdfsUtils(); static boolean pathExists(FileSystem fs, Path filePath); static String contentOfHdfsFile(FileSystem fs, Path filePath); static String getLastComponent(String path); @VisibleForTesting static boolean isJobFolder(Path p, String regex); static List<FileStatus> getDirectories(FileSystem fs, Path path); static Path getJobDirPath(FileSystem fs, Path curr, String applicationId); static List<Path> getJobDirs(FileSystem fs, Path curr, String regex); static void copySrcToDest(Path src, Path dst, Configuration conf); }
HdfsUtils { public static List<Path> getJobDirs(FileSystem fs, Path curr, String regex) { List<Path> result = new ArrayList<>(); List<FileStatus> dirs = getDirectories(fs, curr); dirs.forEach(dir -> { if (isJobFolder(dir.getPath(), regex)) { result.add(dir.getPath()); } result.addAll(getJobDirs(fs, dir.getPath(), regex)); }); return result; } private  HdfsUtils(); static boolean pathExists(FileSystem fs, Path filePath); static String contentOfHdfsFile(FileSystem fs, Path filePath); static String getLastComponent(String path); @VisibleForTesting static boolean isJobFolder(Path p, String regex); static List<FileStatus> getDirectories(FileSystem fs, Path path); static Path getJobDirPath(FileSystem fs, Path curr, String applicationId); static List<Path> getJobDirs(FileSystem fs, Path curr, String regex); static void copySrcToDest(Path src, Path dst, Configuration conf);  }