@Override public boolean isFile() { return myFs.isFile(); }
/** * Process the input stat. * If it is a file, return the file stat. * If it is a directory, traverse the directory if recursive is true; * ignore it if recursive is false. * @param stat input status * @throws IOException if any IO error occurs */ private void handleFileStat(LocatedFileStatus stat) throws IOException { if (stat.isFile()) { // file curFile = stat; } else if (recursive) { // directory itors.push(curItor); curItor = listLocatedStatus(stat.getPath()); } }
private List<FileStatus> getListOfWALFiles(Configuration c) throws IOException { Path logRoot = new Path(CommonFSUtils.getWALRootDir(c), HConstants.HREGION_LOGDIR_NAME); FileSystem fs = logRoot.getFileSystem(c); RemoteIterator<LocatedFileStatus> it = fs.listFiles(logRoot, true); List<FileStatus> logFiles = new ArrayList<FileStatus>(); while (it.hasNext()) { LocatedFileStatus lfs = it.next(); if (lfs.isFile() && !AbstractFSWALProvider.isMetaFile(lfs.getPath())) { logFiles.add(lfs); LOG.info(Objects.toString(lfs)); } } return logFiles; }
/** * Process the input stat. * If it is a file, return the file stat. * If it is a directory, traverse the directory if recursive is true; * ignore it if recursive is false. * If it is a symlink, resolve the symlink first and then process it * depending on if it is a file or directory. * @param stat input status * @throws AccessControlException if access is denied * @throws FileNotFoundException if file is not found * @throws UnsupportedFileSystemException if fs is not supported * @throws IOException for all other IO errors */ private void handleFileStat(LocatedFileStatus stat) throws IOException { if (stat.isFile()) { // file curFile = stat; } else if (stat.isSymlink()) { // symbolic link // resolve symbolic link FileStatus symstat = FileContext.this.getFileStatus( stat.getSymlink()); if (symstat.isFile() || (recursive && symstat.isDirectory())) { itors.push(curItor); curItor = listLocatedStatus(stat.getPath()); } } else if (recursive) { // directory itors.push(curItor); curItor = listLocatedStatus(stat.getPath()); } }
while (it.hasNext()) { final LocatedFileStatus locatedFileStatus = it.next(); if (locatedFileStatus.isFile()) { final Path myPath = locatedFileStatus.getPath(); if (ConvertingOutputFormat.DATA_SUCCESS_KEY.equals(myPath.getName())) {
private boolean hasHFileLink(Path tableDir) throws IOException { if (fs.exists(tableDir)) { RemoteIterator<LocatedFileStatus> iterator = fs.listFiles(tableDir, true); while (iterator.hasNext()) { LocatedFileStatus fileStatus = iterator.next(); if (fileStatus.isFile() && HFileLink.isHFileLink(fileStatus.getPath())) { return true; } } } return false; }
while (iterator.hasNext()) { LocatedFileStatus fileStatus = iterator.next(); if (!fileStatus.isFile()) { continue;
@Override public boolean isFile() { return myFs.isFile(); }
@Override public boolean isFile() { return myFs.isFile(); }
@Override public boolean isFile() { return myFs.isFile(); }
@Override public boolean isFile() { return myFs.isFile(); }
private void enqueue(String path) throws IOException { Path filePath = new Path(path); if (!fs.exists(filePath) || fs.getFileStatus(filePath) == null) { log.info("Cannot enqueue file {} because it does not exist but got an event from the FS", filePath.toString()); return; } RemoteIterator<LocatedFileStatus> it = fs.listFiles(filePath, false); while (it.hasNext()) { LocatedFileStatus status = it.next(); if (!status.isFile() || !fileRegexp.matcher(status.getPath().getName()).find()) continue; fileQueue.offer(toMetadata(status)); } } }
/** * Process the input stat. * If it is a file, return the file stat. * If it is a directory, traverse the directory if recursive is true; * ignore it if recursive is false. * @param stat input status * @throws IOException if any IO error occurs */ private void handleFileStat(LocatedFileStatus stat) throws IOException { if (stat.isFile()) { // file curFile = stat; } else if (recursive) { // directory itors.push(curItor); curItor = listLocatedStatus(stat.getPath()); } }
/** * Process the input stat. * If it is a file, return the file stat. * If it is a directory, traverse the directory if recursive is true; * ignore it if recursive is false. * @param stat input status * @throws IOException if any IO error occurs */ private void handleFileStat(LocatedFileStatus stat) throws IOException { if (stat.isFile()) { // file curFile = stat; } else if (recursive) { // directory itors.push(curItor); curItor = listLocatedStatus(stat.getPath()); } }
/** * Process the input stat. * If it is a file, return the file stat. * If it is a directory, traverse the directory if recursive is true; * ignore it if recursive is false. * @param stat input status * @throws IOException if any IO error occurs */ private void handleFileStat(LocatedFileStatus stat) throws IOException { if (stat.isFile()) { // file curFile = stat; } else if (recursive) { // directory itors.push(curItor); curItor = listLocatedStatus(stat.getPath()); } }
/** * Process the input stat. * If it is a file, return the file stat. * If it is a directory, traverse the directory if recursive is true; * ignore it if recursive is false. * @param stat input status * @throws IOException if any IO error occurs */ private void handleFileStat(LocatedFileStatus stat) throws IOException { if (stat.isFile()) { // file curFile = stat; } else if (recursive) { // directory itors.push(curItor); curItor = listLocatedStatus(stat.getPath()); } }
@Override public boolean hasNext() { try { if (current == null) { if (!it.hasNext()) return false; current = it.next(); return hasNext(); } if (current.isFile() && fileRegexp.matcher(current.getPath().getName()).find()) { return true; } current = null; return hasNext(); } catch (IOException ioe) { throw new ConnectException(ioe); } }
private List<String> getCommitFiles(final String basePath, final FileSystem fs) throws IOException { final List<String> commitFiles = new ArrayList<>(); final RemoteIterator<LocatedFileStatus> filesI = fs.listFiles(new Path(basePath), true); while (filesI.hasNext()) { final LocatedFileStatus fileStatus = filesI.next(); if (fileStatus.isFile() && fileStatus.getPath().getName().endsWith("commit")) { commitFiles.add(fileStatus.getPath().getName()); } } return commitFiles; } }
private boolean hasHFileLink(Path tableDir) throws IOException { if (fs.exists(tableDir)) { RemoteIterator<LocatedFileStatus> iterator = fs.listFiles(tableDir, true); while (iterator.hasNext()) { LocatedFileStatus fileStatus = iterator.next(); if (fileStatus.isFile() && HFileLink.isHFileLink(fileStatus.getPath())) { return true; } } } return false; }
/** Test when input path is a file */ @Test public void testFile() throws IOException { fc.mkdir(TEST_DIR, FsPermission.getDefault(), true); writeFile(fc, FILE1, FILE_LEN); RemoteIterator<LocatedFileStatus> itor = fc.util().listFiles( FILE1, true); LocatedFileStatus stat = itor.next(); assertFalse(itor.hasNext()); assertTrue(stat.isFile()); assertEquals(FILE_LEN, stat.getLen()); assertEquals(fc.makeQualified(FILE1), stat.getPath()); assertEquals(1, stat.getBlockLocations().length); itor = fc.util().listFiles(FILE1, false); stat = itor.next(); assertFalse(itor.hasNext()); assertTrue(stat.isFile()); assertEquals(FILE_LEN, stat.getLen()); assertEquals(fc.makeQualified(FILE1), stat.getPath()); assertEquals(1, stat.getBlockLocations().length); }