@Override public void setPath(Path p) { realStatus.setPath(p); }
@Override public boolean isDirectory(URI uri) { FileStatus fileStatus = new FileStatus(); fileStatus.setPath(new Path(uri)); return fileStatus.isDirectory(); }
private static FileStatus fixFileStatus(FileStatus orig, Path qualified) throws IOException { // FileStatus#getPath is a fully qualified path relative to the root of // target file system. // We need to change it to viewfs URI - relative to root of mount table. // The implementors of RawLocalFileSystem were trying to be very smart. // They implement FileStatus#getOwner lazily -- the object // returned is really a RawLocalFileSystem that expect the // FileStatus#getPath to be unchanged so that it can get owner when needed. // Hence we need to interpose a new ViewFileSystemFileStatus that // works around. if ("file".equals(orig.getPath().toUri().getScheme())) { orig = wrapLocalFileStatus(orig, qualified); } orig.setPath(qualified); return orig; }
@Override public FileStatus getFileStatus(Path arg0) throws IOException { LlapCacheAwareFs.CacheAwareInputStream ctx = getCtx(arg0); FileStatus fileStatus = ctx.getFs().getFileStatus(ctx.path); // We replace the path in the file status by the input path as Parquet // may use the path in the file status to open the file fileStatus.setPath(arg0); return fileStatus; }
Path userTrash = new Path(candidate.getPath(), TRASH_PREFIX); if (exists(userTrash)) { candidate.setPath(userTrash); ret.add(candidate);
setGroup(other.getGroup()); setSymlink((other.isSymlink() ? other.getSymlink() : null)); setPath(other.getPath()); attr = attributes(other.hasAcl(), other.isEncrypted(), other.isErasureCoded(), other.isSnapshotEnabled());
@Test public void testAddWALFiles() throws IOException { List<String> files = Arrays.asList("hdfs://server/WALs/srv1,101,15555/srv1,101,15555.default.1", "hdfs://server/WALs/srv2,102,16666/srv2,102,16666.default.2", "hdfs://server/WALs/srv3,103,17777/srv3,103,17777.default.3"); String newFile = "hdfs://server/WALs/srv1,101,15555/srv1,101,15555.default.5"; table.addWALFiles(files, "backup", "root"); assertTrue(table.isWALFileDeletable(files.get(0))); assertTrue(table.isWALFileDeletable(files.get(1))); assertTrue(table.isWALFileDeletable(files.get(2))); assertFalse(table.isWALFileDeletable(newFile)); // test for isWALFilesDeletable List<FileStatus> fileStatues = new ArrayList<>(); for (String file : files) { FileStatus fileStatus = new FileStatus(); fileStatus.setPath(new Path(file)); fileStatues.add(fileStatus); } FileStatus newFileStatus = new FileStatus(); newFileStatus.setPath(new Path(newFile)); fileStatues.add(newFileStatus); Map<FileStatus, Boolean> walFilesDeletableMap = table.areWALFilesDeletable(fileStatues); assertTrue(walFilesDeletableMap.get(fileStatues.get(0))); assertTrue(walFilesDeletableMap.get(fileStatues.get(1))); assertTrue(walFilesDeletableMap.get(fileStatues.get(2))); assertFalse(walFilesDeletableMap.get(newFileStatus)); cleanBackupTable(); }
private FileStatus[] toFileStatuses(final List<DirectoryEntry> entries, final Path parent) { FileStatus[] fileStatuses = new FileStatus[entries.size()]; int index = 0; for (DirectoryEntry entry : entries) { FileStatus status = toFileStatus(entry, parent); if (!(entry.name == null || entry.name == "")) { status.setPath( new Path(parent.makeQualified(uri, workingDirectory), entry.name)); } fileStatuses[index++] = status; } return fileStatuses; }
private static FileStatus fixFileStatus(FileStatus orig, Path qualified) throws IOException { // FileStatus#getPath is a fully qualified path relative to the root of // target file system. // We need to change it to viewfs URI - relative to root of mount table. // The implementors of RawLocalFileSystem were trying to be very smart. // They implement FileStatus#getOwner lazily -- the object // returned is really a RawLocalFileSystem that expect the // FileStatus#getPath to be unchanged so that it can get owner when needed. // Hence we need to interpose a new ViewFileSystemFileStatus that // works around. if ("file".equals(orig.getPath().toUri().getScheme())) { orig = wrapLocalFileStatus(orig, qualified); } orig.setPath(qualified); return orig; }
private static FileStatus fixFileStatus(FileStatus orig, Path qualified) throws IOException { // FileStatus#getPath is a fully qualified path relative to the root of // target file system. // We need to change it to viewfs URI - relative to root of mount table. // The implementors of RawLocalFileSystem were trying to be very smart. // They implement FileStatus#getOwner lazily -- the object // returned is really a RawLocalFileSystem that expect the // FileStatus#getPath to be unchanged so that it can get owner when needed. // Hence we need to interpose a new ViewFileSystemFileStatus that // works around. if ("file".equals(orig.getPath().toUri().getScheme())) { orig = wrapLocalFileStatus(orig, qualified); } orig.setPath(qualified); return orig; }
private static FileStatus fixFileStatus(FileStatus orig, Path qualified) throws IOException { // FileStatus#getPath is a fully qualified path relative to the root of // target file system. // We need to change it to viewfs URI - relative to root of mount table. // The implementors of RawLocalFileSystem were trying to be very smart. // They implement FileStatus#getOwner lazily -- the object // returned is really a RawLocalFileSystem that expect the // FileStatus#getPath to be unchanged so that it can get owner when needed. // Hence we need to interpose a new ViewFileSystemFileStatus that // works around. if ("file".equals(orig.getPath().toUri().getScheme())) { orig = wrapLocalFileStatus(orig, qualified); } orig.setPath(qualified); return orig; }
private static FileStatus fixFileStatus(FileStatus orig, Path qualified) throws IOException { // FileStatus#getPath is a fully qualified path relative to the root of // target file system. // We need to change it to viewfs URI - relative to root of mount table. // The implementors of RawLocalFileSystem were trying to be very smart. // They implement FileStatus#getOwner lazily -- the object // returned is really a RawLocalFileSystem that expect the // FileStatus#getPath to be unchanged so that it can get owner when needed. // Hence we need to interpose a new ViewFileSystemFileStatus that // works around. if ("file".equals(orig.getPath().toUri().getScheme())) { orig = wrapLocalFileStatus(orig, qualified); } orig.setPath(qualified); return orig; }
try { FileStatus status = fs.getFileStatus(new Path(url.toURI())); status.setPath(arg0); return status; } catch (URISyntaxException e) {
/** * Filter file status. * * @param fileStatus the file status * @return the file status */ protected FileStatus filter(final FileStatus fileStatus) { FileStatus newObj = new FileStatus(); newObj.setPath(toGitPath(fileStatus.getPath())); try { newObj.setSymlink(toGitPath(fileStatus.getSymlink())); } catch (IOException e) { } return newObj; }
/** * Test FileStatus of snapshot file before/after rename */ @Test (timeout=60000) public void testSnapshotRename() throws Exception { DFSTestUtil.createFile(hdfs, file1, BLOCKSIZE, REPLICATION, seed); // Create snapshot for sub1 Path snapshotRoot = SnapshotTestHelper.createSnapshot(hdfs, sub1, "s1"); Path ssPath = new Path(snapshotRoot, file1.getName()); assertTrue(hdfs.exists(ssPath)); FileStatus statusBeforeRename = hdfs.getFileStatus(ssPath); // Rename the snapshot hdfs.renameSnapshot(sub1, "s1", "s2"); // <sub1>/.snapshot/s1/file1 should no longer exist assertFalse(hdfs.exists(ssPath)); snapshotRoot = SnapshotTestHelper.getSnapshotRoot(sub1, "s2"); ssPath = new Path(snapshotRoot, file1.getName()); // Instead, <sub1>/.snapshot/s2/file1 should exist assertTrue(hdfs.exists(ssPath)); FileStatus statusAfterRename = hdfs.getFileStatus(ssPath); // FileStatus of the snapshot should not change except the path assertFalse(statusBeforeRename.equals(statusAfterRename)); statusBeforeRename.setPath(statusAfterRename.getPath()); assertEquals(statusBeforeRename.toString(), statusAfterRename.toString()); }