Search in sources :

Example 1 with UnresolvedPathException

use of org.apache.hadoop.hdfs.protocol.UnresolvedPathException in project hadoop by apache.

the class NameNodeRpcServer method getLinkTarget.

// ClientProtocol
@Override
public String getLinkTarget(String path) throws IOException {
    checkNNStartup();
    metrics.incrGetLinkTargetOps();
    HdfsFileStatus stat = null;
    try {
        stat = namesystem.getFileInfo(path, false);
    } catch (UnresolvedPathException e) {
        return e.getResolvedPath().toString();
    } catch (UnresolvedLinkException e) {
        // The NameNode should only throw an UnresolvedPathException
        throw new AssertionError("UnresolvedLinkException thrown");
    }
    if (stat == null) {
        throw new FileNotFoundException("File does not exist: " + path);
    } else if (!stat.isSymlink()) {
        throw new IOException("Path " + path + " is not a symbolic link");
    }
    return stat.getSymlink();
}
Also used : UnresolvedLinkException(org.apache.hadoop.fs.UnresolvedLinkException) HdfsFileStatus(org.apache.hadoop.hdfs.protocol.HdfsFileStatus) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) UnresolvedPathException(org.apache.hadoop.hdfs.protocol.UnresolvedPathException)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 UnresolvedLinkException (org.apache.hadoop.fs.UnresolvedLinkException)1 HdfsFileStatus (org.apache.hadoop.hdfs.protocol.HdfsFileStatus)1 UnresolvedPathException (org.apache.hadoop.hdfs.protocol.UnresolvedPathException)1