private FileStatus[] listStatus(Path path) throws IOException { try { if (fs != null) { return fs.listStatus(path); } else { return fc.util().listStatus(path); } } catch (FileNotFoundException e) { return new FileStatus[0]; } }
if (!this.util().exists(f)) { return false;
/** * Returns all jars that are in the directory. It is useful in expanding a * wildcard path to return all jars from the directory to use in a classpath. * * @param path the path to the directory. The path may include the wildcard. * @return the list of jars as URLs, or an empty list if there are no jars, or * the directory does not exist */ public static List<Path> getJarsInDirectory(String path, boolean useLocal) { List<Path> paths = new ArrayList<>(); try { // add the wildcard if it is not provided if (!path.endsWith("*")) { path += File.separator + "*"; } Path globPath = new Path(path).suffix("{.jar,.JAR}"); FileContext context = useLocal ? FileContext.getLocalFSFileContext() : FileContext.getFileContext(globPath.toUri()); FileStatus[] files = context.util().globStatus(globPath); if (files != null) { for (FileStatus file: files) { paths.add(file.getPath()); } } } catch (IOException ignore) {} // return the empty list return paths; }
private FileStatus[] listStatus(Path path) throws IOException { try { if (fs != null) { return fs.listStatus(path); } else { return fc.util().listStatus(path); } } catch (FileNotFoundException e) { return new FileStatus[0]; } }
private FileStatus[] listStatus(Path path) throws IOException { try { if (fs != null) { return fs.listStatus(path); } else { return fc.util().listStatus(path); } } catch (FileNotFoundException e) { return new FileStatus[0]; } }
private FileStatus[] listStatus(Path path) throws IOException { try { if (fs != null) { return fs.listStatus(path); } else { return fc.util().listStatus(path); } } catch (FileNotFoundException e) { return new FileStatus[0]; } }
protected void finalize(int partNum) throws IOException { String tmpToFinalize = fileSystemWAL.tempPartFiles.remove(partNum); Path tmpPath = new Path(tmpToFinalize); if (fileSystemWAL.fileContext.util().exists(tmpPath)) { LOG.debug("finalize {} of part {}", tmpPath, partNum); fileSystemWAL.fileContext.rename(tmpPath, new Path(fileSystemWAL.getPartFilePath(partNum)), Options.Rename.OVERWRITE); latestFinalizedPart = partNum; } }
@Override public Object run() throws Exception { if (fileContext.util().exists(fileToDelete)) { fileContext.delete(fileToDelete, false); } return null; } });
@Override public Void run() throws Exception { if (fileContext.util().exists(deletePath)) { fileContext.delete(deletePath, false); } return null; } }.runWithRetries();
private FileStatus[] listStatus(Path path, boolean isDirectory) throws IOException { try { if (fs != null) { return fs.listStatus(path, filter, true, isDirectory); } else { return fc.util().listStatus(path); } } catch (FileNotFoundException e) { return new FileStatus[0]; } }
private FileStatus[] listStatus(Path path, boolean isDirectory) throws IOException { try { if (fs != null) { return fs.listStatus(path, filter, true, isDirectory); } else { return fc.util().listStatus(path); } } catch (FileNotFoundException e) { return new FileStatus[0]; } }
private void cleanupLogDir(FileContext fs, DeletionService del, String logDir) throws IOException { if (!fs.util().exists(new Path(logDir))){ return; } renameAppLogDir(logDir); deleteAppLogDir(fs, del, logDir); }
private void cleanupLogDir(FileContext fs, DeletionService del, String logDir) throws IOException { if (!fs.util().exists(new Path(logDir))){ return; } renameAppLogDir(logDir); deleteAppLogDir(fs, del, logDir); }
@Override public FileStatus[] globStatus(Path pathPattern, PathFilter filter) throws IOException { return fc.util().globStatus(pathPattern, filter); } }
@Override public FileStatus[] listStatus(Path f) throws AccessControlException, FileNotFoundException, UnsupportedFileSystemException, IOException { return fc.util().listStatus(f); }
@Override public FileStatus[] listStatus(Path f) throws AccessControlException, FileNotFoundException, UnsupportedFileSystemException, IOException { return fc.util().listStatus(f); }
@Override public FileStatus[] globStatus(Path pathPattern, PathFilter filter) throws IOException { return fc.util().globStatus(pathPattern, filter); } }
@Test public void testGlobStatusThrowsExceptionForNonExistentFile() throws Exception { try { // This should throw a FileNotFoundException fc.util().globStatus( getTestRootPath(fc, "test/hadoopfsdf/?")); Assert.fail("Should throw FileNotFoundException"); } catch (FileNotFoundException fnfe) { // expected } }
@Test public void testGlobStatusNonExistentFile() throws Exception { FileStatus[] paths = fc.util().globStatus( getTestRootPath(fc, "test/hadoopfsdf")); Assert.assertNull(paths); paths = fc.util().globStatus( getTestRootPath(fc, "test/hadoopfsdf/?")); Assert.assertEquals(0, paths.length); paths = fc.util().globStatus( getTestRootPath(fc, "test/hadoopfsdf/xyz*/?")); Assert.assertEquals(0, paths.length); }
@Test public void testGlobStatusNonExistentFile() throws Exception { FileStatus[] paths = fc.util().globStatus( getTestRootPath(fc, "test/hadoopfsdf")); Assert.assertNull(paths); paths = fc.util().globStatus( getTestRootPath(fc, "test/hadoopfsdf/?")); Assert.assertEquals(0, paths.length); paths = fc.util().globStatus( getTestRootPath(fc, "test/hadoopfsdf/xyz*/?")); Assert.assertEquals(0, paths.length); }