Example usage for org.apache.hadoop.hdfs.protocol HdfsFileStatus getSymlink

List of usage examples for org.apache.hadoop.hdfs.protocol HdfsFileStatus getSymlink

Introduction

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

Prototype

Path getSymlink() throws IOException;

Source Link

Document

See FileStatus#getSymlink() .

Usage

From source file:com.bigstep.datalake.DLFileSystem.java

License:Apache License

private FileStatus makeQualified(HdfsFileStatus f, Path parent) {

    return new FileStatus(f.getLen(), f.isDir(), f.getReplication(), f.getBlockSize(), f.getModificationTime(),
            f.getAccessTime(), f.getPermission(), f.getOwner(), f.getGroup(),
            f.isSymlink() ? new Path(f.getSymlink()) : null,
            makeQualified(f.getFullPath(parent).makeQualified(getUri(), getWorkingDirectory())));
}

From source file:com.bigstep.datalake.JsonUtil.java

License:Apache License

/**
 * Convert a HdfsFileStatus object to a Json string.
 * @param status input status// www . jav a2s.c  o  m
 * @param includeType type to use
 * @return the json
 */
public static String toJsonString(final HdfsFileStatus status, boolean includeType) {
    if (status == null) {
        return null;
    }
    final Map<String, Object> m = new TreeMap<String, Object>();
    m.put("pathSuffix", status.getLocalName());
    m.put("type", PathType.valueOf(status));
    if (status.isSymlink()) {
        m.put("symlink", status.getSymlink());
    }

    m.put("length", status.getLen());
    m.put("owner", status.getOwner());
    m.put("group", status.getGroup());
    FsPermission perm = status.getPermission();
    m.put("permission", toString(perm));
    if (perm.getAclBit()) {
        m.put("aclBit", true);
    }
    if (perm.getEncryptedBit()) {
        m.put("encBit", true);
    }
    m.put("accessTime", status.getAccessTime());
    m.put("modificationTime", status.getModificationTime());
    m.put("blockSize", status.getBlockSize());
    m.put("replication", status.getReplication());
    m.put("fileId", status.getFileId());
    m.put("childrenNum", status.getChildrenNum());
    m.put("storagePolicy", status.getStoragePolicy());

    Gson gson = new Gson();

    return includeType ? toJsonString(FileStatus.class, m) : gson.toJson(m);

}

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.
     */// w  w w .  j  a va 2  s  . c o 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;
}