@Test public void testGetJobFoldersHandlesIOException() throws IOException { Path histFolder = new Path(Constants.TONY_CORE_SRC + "test/resources/typicalHistFolder"); FileSystem mockFs = mock(FileSystem.class); String regex = "job*"; when(mockFs.listStatus(histFolder)).thenThrow(new IOException("IO Excpt")); assertNull(HdfsUtils.getJobDirPath(mockFs, histFolder, regex)); }
public static Path getJobDirPath(FileSystem fs, Path curr, String applicationId) { List<FileStatus> dirs = getDirectories(fs, curr); for (FileStatus dir : dirs) { if (dir.getPath().getName().equals(applicationId)) { return dir.getPath(); } } for (FileStatus dir : dirs) { Path result = getJobDirPath(fs, dir.getPath(), applicationId); if (result != null) { return result; } } return null; }
HdfsUtils { public static Path getJobDirPath(FileSystem fs, Path curr, String applicationId) { List<FileStatus> dirs = getDirectories(fs, curr); for (FileStatus dir : dirs) { if (dir.getPath().getName().equals(applicationId)) { return dir.getPath(); } } for (FileStatus dir : dirs) { Path result = getJobDirPath(fs, dir.getPath(), applicationId); if (result != null) { return result; } } return null; } }
HdfsUtils { public static Path getJobDirPath(FileSystem fs, Path curr, String applicationId) { List<FileStatus> dirs = getDirectories(fs, curr); for (FileStatus dir : dirs) { if (dir.getPath().getName().equals(applicationId)) { return dir.getPath(); } } for (FileStatus dir : dirs) { Path result = getJobDirPath(fs, dir.getPath(), applicationId); if (result != null) { return result; } } return null; } private  HdfsUtils(); }
HdfsUtils { public static Path getJobDirPath(FileSystem fs, Path curr, String applicationId) { List<FileStatus> dirs = getDirectories(fs, curr); for (FileStatus dir : dirs) { if (dir.getPath().getName().equals(applicationId)) { return dir.getPath(); } } for (FileStatus dir : dirs) { Path result = getJobDirPath(fs, dir.getPath(), applicationId); if (result != null) { return result; } } return null; } 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 Path getJobDirPath(FileSystem fs, Path curr, String applicationId) { List<FileStatus> dirs = getDirectories(fs, curr); for (FileStatus dir : dirs) { if (dir.getPath().getName().equals(applicationId)) { return dir.getPath(); } } for (FileStatus dir : dirs) { Path result = getJobDirPath(fs, dir.getPath(), applicationId); if (result != null) { return result; } } return null; } 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);  }