Example usage for org.apache.hadoop.hdfs.protocol UnresolvedPathException getResolvedPath

List of usage examples for org.apache.hadoop.hdfs.protocol UnresolvedPathException getResolvedPath

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs.protocol UnresolvedPathException getResolvedPath.

Prototype

public Path getResolvedPath() 

Source Link

Document

Return a path with the link resolved with the target.

Usage

From source file:common.NameNode.java

License:Apache License

/** @inheritDoc */
public String getLinkTarget(String path) throws IOException {
    myMetrics.numgetLinkTargetOps.inc();
    /* Resolves the first symlink in the given path, returning a
     * new path consisting of the target of the symlink and any 
     * remaining path components from the original path.
     *///ww w  . java  2s  .co m
    try {
        HdfsFileStatus stat = namesystem.getFileInfo(path, false);
        if (stat != null) {
            // NB: getSymlink throws IOException if !stat.isSymlink() 
            return stat.getSymlink();
        }
    } catch (UnresolvedPathException e) {
        return e.getResolvedPath().toString();
    } catch (UnresolvedLinkException e) {
        // The NameNode should only throw an UnresolvedPathException
        throw new AssertionError("UnresolvedLinkException thrown");
    }
    return null;
}