Example usage for org.apache.hadoop.fs FileSystem getFileLinkStatus

List of usage examples for org.apache.hadoop.fs FileSystem getFileLinkStatus

Introduction

In this page you can find the example usage for org.apache.hadoop.fs FileSystem getFileLinkStatus.

Prototype

public FileStatus getFileLinkStatus(final Path f)
        throws AccessControlException, FileNotFoundException, UnsupportedFileSystemException, IOException 

Source Link

Document

See FileContext#getFileLinkStatus(Path) .

Usage

From source file:com.mellanox.r4h.DistributedFileSystem.java

License:Apache License

@Override
public FileStatus getFileLinkStatus(final Path f)
        throws AccessControlException, FileNotFoundException, UnsupportedFileSystemException, IOException {
    statistics.incrementReadOps(1);/*from   w  w  w .j  ava 2s  . c om*/
    final Path absF = fixRelativePart(f);
    FileStatus status = new FileSystemLinkResolver<FileStatus>() {
        @Override
        public FileStatus doCall(final Path p) throws IOException, UnresolvedLinkException {
            HdfsFileStatus fi = dfs.getFileLinkInfo(getPathName(p));
            if (fi != null) {
                return fi.makeQualified(getUri(), p);
            } else {
                throw new FileNotFoundException("File does not exist: " + p);
            }
        }

        @Override
        public FileStatus next(final FileSystem fs, final Path p) throws IOException, UnresolvedLinkException {
            return fs.getFileLinkStatus(p);
        }
    }.resolve(this, absF);
    // Fully-qualify the symlink
    if (status.isSymlink()) {
        Path targetQual = FSLinkResolver.qualifySymlinkTarget(this.getUri(), status.getPath(),
                status.getSymlink());
        status.setSymlink(targetQual);
    }
    return status;
}

From source file:org.apache.falcon.validation.ClusterEntityValidationIT.java

License:Apache License

@Test
public void testValidateClusterLocationsWithoutWorking() throws Exception {
    overlay = context.getUniqueOverlay();
    String filePath = TestContext.overlayParametersOverTemplate(TestContext.CLUSTER_TEMPLATE, overlay);
    InputStream stream = new FileInputStream(filePath);
    Cluster clusterEntity = (Cluster) EntityType.CLUSTER.getUnmarshaller().unmarshal(stream);
    clusterEntity.getLocations().getLocations().remove(2);
    FileSystem clusterFileSystem = FileSystem.get(ClusterHelper.getConfiguration(cluster));
    TestContext.createClusterLocations(clusterEntity, clusterFileSystem, false);
    parser.validate(clusterEntity);/*from w  w w . ja va  2 s.  c  om*/
    String expectedPath = ClusterHelper.getLocation(clusterEntity, ClusterLocationType.STAGING).getPath()
            + "/working";
    Assert.assertEquals(ClusterHelper.getLocation(clusterEntity, ClusterLocationType.WORKING).getPath(),
            expectedPath);
    Assert.assertTrue(clusterFileSystem.getFileLinkStatus(new Path(expectedPath)).isDirectory());
    Assert.assertEquals(clusterFileSystem.getFileLinkStatus(new Path(expectedPath)).getPermission(),
            HadoopClientFactory.READ_EXECUTE_PERMISSION);
}

From source file:org.apache.oozie.util.FSUtils.java

License:Apache License

public static Path getSymLinkTarget(FileSystem fs, Path p) throws IOException {
    try {//  ww w. jav  a 2 s.  co  m
        //getSymlink doesn't work with fragment name, need to remove fragment before calling getSymlink
        Path tempPath = new URI(p.toString()).getFragment() == null ? p
                : new Path(new URI(p.toString()).getPath());
        return fs.getFileLinkStatus(tempPath).getSymlink();
    } catch (java.net.URISyntaxException e) {
        throw new IOException(e);
    }
}

From source file:org.apache.oozie.util.FSUtils.java

License:Apache License

public static boolean isSymlink(FileSystem fs, Path p) throws IOException {
    try {/*from  w w  w . ja v a 2s  .c o m*/
        //isSymlink doesn't work with fragment name, need to remove fragment before checking for symlink
        Path tempPath = new URI(p.toString()).getFragment() == null ? p
                : new Path(new URI(p.toString()).getPath());
        return fs.getFileLinkStatus(tempPath).isSymlink();
    } catch (java.net.URISyntaxException e) {
        throw new IOException(e);
    }
}