@Override public boolean evaluate() throws Exception { return dfs.isFileClosed(localFile) && dfs.isFileClosed(remoteFile); }
@Override public String explainFailure() throws Exception { StringBuilder sb = new StringBuilder(); if (!dfs.isFileClosed(localFile)) { sb.append(localFile + " has not been closed yet."); } if (!dfs.isFileClosed(remoteFile)) { sb.append(remoteFile + " has not been closed yet."); } return sb.toString(); } });
sw.start(); boolean isClosed = dfs.isFileClosed(path); while (!isClosed && deadline.hasTimeLeft()) { try { throw new IOException("Recovering the lease failed: ", e1); isClosed = dfs.isFileClosed(path);
LOG.debug("Trying to recover file lease {}", partPath); dfs.recoverLease(partPath); boolean isclosed = dfs.isFileClosed(partPath); StopWatch sw = new StopWatch(); sw.start(); isclosed = dfs.isFileClosed(partPath);
LOG.debug("Trying to recover file lease {}", partPath); dfs.recoverLease(partPath); boolean isclosed = dfs.isFileClosed(partPath); StopWatch sw = new StopWatch(); sw.start(); isclosed = dfs.isFileClosed(partPath);
@Override public Boolean next(final FileSystem fs, final Path p) throws IOException { if (fs instanceof DistributedFileSystem) { DistributedFileSystem myDfs = (DistributedFileSystem)fs; return myDfs.isFileClosed(p); } else { throw new UnsupportedOperationException("Cannot call isFileClosed" + " on a symlink to a non-DistributedFileSystem: " + src + " -> " + p); } } }.resolve(this, absF);
@Override public Boolean next(final FileSystem fs, final Path p) throws IOException { if (fs instanceof DistributedFileSystem) { DistributedFileSystem myDfs = (DistributedFileSystem)fs; return myDfs.isFileClosed(p); } else { throw new UnsupportedOperationException("Cannot call isFileClosed" + " on a symlink to a non-DistributedFileSystem: " + src + " -> " + p); } } }.resolve(this, absF);
@Override public Boolean next(final FileSystem fs, final Path p) throws IOException { if (fs instanceof DistributedFileSystem) { DistributedFileSystem myDfs = (DistributedFileSystem)fs; return myDfs.isFileClosed(p); } else { throw new UnsupportedOperationException("Cannot call isFileClosed" + " on a symlink to a non-DistributedFileSystem: " + src + " -> " + p); } } }.resolve(this, absF);
/** * @return the size of the file path as reported by the {@link FileSystem} or {@link -1} if the file is still * opened. */ private long sizeFromFileSystem() throws IOException { if (fs instanceof DistributedFileSystem) { if (((DistributedFileSystem) fs).isFileClosed(path)) { return fs.getFileStatus(path).getLen(); } else { return -1L; } } // If the the underlying file system is not DistributedFileSystem, just assume the file length tells the size return fs.getFileStatus(path).getLen(); } };
/** * @return the size of the file path as reported by the {@link FileSystem} or {@link -1} if the file is still * opened. */ private long sizeFromFileSystem() throws IOException { if (fs instanceof DistributedFileSystem) { if (((DistributedFileSystem) fs).isFileClosed(path)) { return fs.getFileStatus(path).getLen(); } else { return -1L; } } // If the the underlying file system is not DistributedFileSystem, just assume the file length tells the size return fs.getFileStatus(path).getLen(); } };
@Override public Boolean get() { try { return fs.isFileClosed(file); } catch (IOException e) { return false; } } }, 500, 30000);
@Override public Boolean get() { try { return cluster.getFileSystem(0).isFileClosed(hdfFilepath); } catch (IOException e) { return false; } } }, 100, 60 * 1000);
sw.start(); boolean isClosed = dfs.isFileClosed(path); while (!isClosed && deadline.hasTimeLeft()) { try { throw new IOException("Recovering the lease failed: ", e1); isClosed = dfs.isFileClosed(path);
if (fs instanceof DistributedFileSystem) { DistributedFileSystem dfs = (DistributedFileSystem) fs; openDataFile = !dfs.isFileClosed(path); openSideFile = sideFileExists && !dfs.isFileClosed(sideFile);
@Test(timeout=10000) public void testIsFileClosed() throws IOException { Path dir = new Path(testBaseDir1()); Path file = new Path(testBaseDir1(), "file"); Path link = new Path(testBaseDir1(), "link"); wrapper.setWorkingDirectory(dir); createAndWriteFile(file); wrapper.createSymlink(file, link, false); // Attempt recoverLease through a symlink boolean closed = dfs.isFileClosed(link); assertTrue("Expected isFileClosed to return true", closed); }
@Test(timeout=60000) public void testFileCloseStatus() throws IOException { Configuration conf = new HdfsConfiguration(); MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build(); DistributedFileSystem fs = cluster.getFileSystem(); try { // create a new file. Path file = new Path("/simpleFlush.dat"); FSDataOutputStream output = fs.create(file); // write to file output.writeBytes("Some test data"); output.flush(); assertFalse("File status should be open", fs.isFileClosed(file)); output.close(); assertTrue("File status should be closed", fs.isFileClosed(file)); } finally { if (cluster != null) { cluster.shutdown(); } } }
fs.isFileClosed(testFileInodePath); fs.getAclStatus(testFileInodePath); fs.getXAttrs(testFileInodePath);