Java Code Examples for org.apache.hadoop.fs.FileStatus#setPath()
The following examples show how to use
org.apache.hadoop.fs.FileStatus#setPath() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestFsRegionsMetaRecoverer.java From hbase-operator-tools with Apache License 2.0 | 6 votes |
@Test public void testReportTablesMissingRegionsOneMissing() throws Exception { ResultScanner mockedRS = Mockito.mock(ResultScanner.class); when(this.mockedTable.getScanner(any(Scan.class))).thenReturn(mockedRS); List<Cell> cells = new ArrayList<>(); cells.add(createCellForTableState(TableName.valueOf("test-tbl"))); Result result = Result.create(cells); when(mockedRS.next()).thenReturn(result,(Result)null); FileStatus status = new FileStatus(); Path p = new Path(this.testTblDir+ "/182182182121"); status.setPath(p); when(mockedFileSystem.listStatus(new Path(this.testTblDir))) .thenReturn(new FileStatus[]{status}); Map<TableName, List<Path>> report = fixer.reportTablesMissingRegions(null); assertEquals("Should had returned 1 missing region", 1,report.size()); }
Example 2
Source File: CachingFileSystem.java From rubix with Apache License 2.0 | 5 votes |
@Override public FileStatus getFileStatus(Path path) throws IOException { FileStatus originalStatus = fs.getFileStatus(path); originalStatus.setPath(getRubixPath(originalStatus.getPath(), isRubixSchemeUsed)); return originalStatus; }
Example 3
Source File: TestBackupSystemTable.java From hbase with Apache License 2.0 | 5 votes |
@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(); }
Example 4
Source File: TestPseudoDistributedFileSystem.java From dremio-oss with Apache License 2.0 | 4 votes |
@Test public void testListStatusWithValidPath() throws IOException { Path path = new Path("/foo/bar"); FileStatus[] statuses = fs.listStatus(path); assertEquals(5, statuses.length); // Note -- listStatus does not guarantee ordering. Sorting/then searching for paths // rather than relying on fixed indices. Arrays.sort(statuses); final FileStatus searchKeyStatus = new FileStatus(); searchKeyStatus.setPath(new Path("pdfs:/foo/bar/10.0.0.1@file1")); int testIndex = Arrays.binarySearch(statuses, searchKeyStatus); assertTrue("Status for path " + searchKeyStatus.getPath().toString() + " not found", testIndex >= 0); assertEquals(new Path("pdfs:/foo/bar/10.0.0.1@file1"), statuses[testIndex].getPath()); assertFalse(statuses[testIndex].isDirectory()); assertEquals(1024, statuses[testIndex].getLen()); assertEquals(1, statuses[testIndex].getReplication()); assertEquals(4096, statuses[testIndex].getBlockSize()); assertEquals(42, statuses[testIndex].getAccessTime()); assertEquals(37, statuses[testIndex].getModificationTime()); assertEquals("root", statuses[testIndex].getOwner()); assertEquals("wheel", statuses[testIndex].getGroup()); assertEquals(0644, statuses[testIndex].getPermission().toExtendedShort()); searchKeyStatus.setPath(new Path("pdfs:/foo/bar/10.0.0.1@file2")); testIndex = Arrays.binarySearch(statuses, searchKeyStatus); assertTrue("Status for path " + searchKeyStatus.getPath().toString() + " not found", testIndex >= 0); assertEquals(new Path("pdfs:/foo/bar/10.0.0.1@file2"), statuses[testIndex].getPath()); assertFalse(statuses[1].isDirectory()); assertEquals(2048, statuses[testIndex].getLen()); assertEquals(1, statuses[testIndex].getReplication()); assertEquals(4096, statuses[testIndex].getBlockSize()); assertEquals(42, statuses[testIndex].getAccessTime()); assertEquals(37, statuses[testIndex].getModificationTime()); assertEquals("root", statuses[testIndex].getOwner()); assertEquals("wheel", statuses[testIndex].getGroup()); assertEquals(0644, statuses[testIndex].getPermission().toExtendedShort()); searchKeyStatus.setPath(new Path("pdfs:/foo/bar/10.0.0.2@file1")); testIndex = Arrays.binarySearch(statuses, searchKeyStatus); assertTrue("Status for path " + searchKeyStatus.getPath().toString() + " not found", testIndex >= 0); assertEquals(new Path("pdfs:/foo/bar/10.0.0.2@file1"), statuses[testIndex].getPath()); assertFalse(statuses[testIndex].isDirectory()); assertEquals(1027, statuses[testIndex].getLen()); assertEquals(1, statuses[testIndex].getReplication()); assertEquals(4096, statuses[testIndex].getBlockSize()); assertEquals(42, statuses[testIndex].getAccessTime()); assertEquals(37, statuses[testIndex].getModificationTime()); assertEquals("root", statuses[testIndex].getOwner()); assertEquals("wheel", statuses[testIndex].getGroup()); assertEquals(0644, statuses[testIndex].getPermission().toExtendedShort()); searchKeyStatus.setPath(new Path("pdfs:/foo/bar/10.0.0.2@file3")); testIndex = Arrays.binarySearch(statuses, searchKeyStatus); assertTrue("Status for path " + searchKeyStatus.getPath().toString() + " not found", testIndex >= 0); assertEquals(new Path("pdfs:/foo/bar/10.0.0.2@file3"), statuses[testIndex].getPath()); assertFalse(statuses[testIndex].isDirectory()); assertEquals(2049, statuses[testIndex].getLen()); assertEquals(1, statuses[testIndex].getReplication()); assertEquals(4096, statuses[testIndex].getBlockSize()); assertEquals(42, statuses[testIndex].getAccessTime()); assertEquals(37, statuses[testIndex].getModificationTime()); assertEquals("root", statuses[testIndex].getOwner()); assertEquals("wheel", statuses[testIndex].getGroup()); assertEquals(0644, statuses[testIndex].getPermission().toExtendedShort()); searchKeyStatus.setPath(new Path("pdfs:/foo/bar/dir")); testIndex = Arrays.binarySearch(statuses, searchKeyStatus); assertTrue("Status for path " + searchKeyStatus.getPath().toString() + " not found", testIndex >= 0); assertEquals(new Path("pdfs:/foo/bar/dir"), statuses[testIndex].getPath()); assertTrue(statuses[testIndex].isDirectory()); assertEquals(47, statuses[testIndex].getLen()); assertEquals(0, statuses[testIndex].getReplication()); assertEquals(0, statuses[testIndex].getBlockSize()); assertEquals(3645, statuses[testIndex].getAccessTime()); assertEquals(1234, statuses[testIndex].getModificationTime()); assertEquals("admin", statuses[testIndex].getOwner()); assertEquals("admin", statuses[testIndex].getGroup()); assertEquals(0755, statuses[testIndex].getPermission().toExtendedShort()); }
Example 5
Source File: HadoopPinotFS.java From incubator-pinot with Apache License 2.0 | 4 votes |
@Override public boolean isDirectory(URI uri) { FileStatus fileStatus = new FileStatus(); fileStatus.setPath(new Path(uri)); return fileStatus.isDirectory(); }
Example 6
Source File: PvfsHadoopBridge.java From pentaho-hadoop-shims with Apache License 2.0 | 4 votes |
@Override public FileStatus getFileStatus( Path path ) throws IOException { FileStatus fileStatus = getFs( path ).getFileStatus( updatePath( path ) ); fileStatus.setPath( path ); return fileStatus; }