@Override public Path getLinkTarget(Path p) throws IOException { return new Path(dfs.getLinkTarget(getUriPath(p))); }
@Override public Path getLinkTarget(Path p) throws IOException { return new Path(dfs.getLinkTarget(getUriPath(p))); }
@Override public Path getLinkTarget(Path p) throws IOException { return new Path(dfs.getLinkTarget(getUriPath(p))); }
@Override protected Path resolveLink(Path f) throws IOException { statistics.incrementReadOps(1); String target = dfs.getLinkTarget(getPathName(fixRelativePart(f))); if (target == null) { throw new FileNotFoundException("File does not exist: " + f.toString()); } return new Path(target); }
@Override protected Path resolveLink(Path f) throws IOException { statistics.incrementReadOps(1); String target = dfs.getLinkTarget(getPathName(fixRelativePart(f))); if (target == null) { throw new FileNotFoundException("File does not exist: " + f.toString()); } return new Path(target); }
@Override protected Path resolveLink(Path f) throws IOException { statistics.incrementReadOps(1); storageStatistics.incrementOpCounter(OpType.RESOLVE_LINK); String target = dfs.getLinkTarget(getPathName(fixRelativePart(f))); if (target == null) { throw new FileNotFoundException("File does not exist: " + f.toString()); } return new Path(target); }
String target = dfsClient.getLinkTarget(fileIdPath);
/** * Tests that attempting to resolve a non-existent-file */ @Test public void testLinkTargetNonExistent() throws IOException { Path doesNotExist = new Path("/filethatdoesnotexist"); DFSClient client = new DFSClient(cluster.getFileSystem().getUri(), cluster.getConfiguration(0)); try { client.getLinkTarget(doesNotExist.toString()); fail("Expected exception for resolving non-existent file"); } catch (FileNotFoundException e) { GenericTestUtils.assertExceptionContains("File does not exist: " + doesNotExist.toString(), e); } } }
/** * Verifies that attempting to resolve a non-symlink results in client * exception */ @Test public void testLinkTargetNonSymlink() throws UnsupportedFileSystemException, IOException { FileContext fc = null; Path notSymlink = new Path("/notasymlink"); try { fc = FileContext.getFileContext(cluster.getFileSystem().getUri()); fc.create(notSymlink, EnumSet.of(CreateFlag.CREATE)); DFSClient client = new DFSClient(cluster.getFileSystem().getUri(), cluster.getConfiguration(0)); try { client.getLinkTarget(notSymlink.toString()); fail("Expected exception for resolving non-symlink"); } catch (IOException e) { GenericTestUtils.assertExceptionContains("is not a symbolic link", e); } } finally { if (fc != null) { fc.delete(notSymlink, false); } } }