Search in sources :

Example 1 with INode

use of org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection.INode in project hadoop by apache.

the class PBImageTextWriter method outputINodes.

private void outputINodes(InputStream in) throws IOException {
    INodeSection s = INodeSection.parseDelimitedFrom(in);
    LOG.info("Found {} INodes in the INode section", s.getNumInodes());
    long ignored = 0;
    long ignoredSnapshots = 0;
    for (int i = 0; i < s.getNumInodes(); ++i) {
        INode p = INode.parseDelimitedFrom(in);
        try {
            String parentPath = metadataMap.getParentPath(p.getId());
            out.println(getEntry(parentPath, p));
        } catch (IOException ioe) {
            ignored++;
            if (!(ioe instanceof IgnoreSnapshotException)) {
                LOG.warn("Exception caught, ignoring node:{}", p.getId(), ioe);
            } else {
                ignoredSnapshots++;
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Exception caught, ignoring node:{}.", p.getId(), ioe);
                }
            }
        }
        if (LOG.isDebugEnabled() && i % 100000 == 0) {
            LOG.debug("Outputted {} INodes.", i);
        }
    }
    if (ignored > 0) {
        LOG.warn("Ignored {} nodes, including {} in snapshots. Please turn on" + " debug log for details", ignored, ignoredSnapshots);
    }
    LOG.info("Outputted {} INodes.", s.getNumInodes());
}
Also used : INodeSection(org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection) FSImageFormatPBINode(org.apache.hadoop.hdfs.server.namenode.FSImageFormatPBINode) INode(org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection.INode) IOException(java.io.IOException)

Example 2 with INode

use of org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection.INode in project hadoop by apache.

the class FSImageLoader method getContentSummaryMap.

private Map<String, Object> getContentSummaryMap(String path) throws IOException {
    long id = lookup(path);
    INode inode = fromINodeId(id);
    long spaceQuota = 0;
    long nsQuota = 0;
    long[] data = new long[4];
    FsImageProto.INodeSection.INodeFile f = inode.getFile();
    switch(inode.getType()) {
        case FILE:
            data[0] = 0;
            data[1] = 1;
            data[2] = getFileSize(f);
            nsQuota = -1;
            data[3] = data[2] * f.getReplication();
            spaceQuota = -1;
            return fillSummaryMap(spaceQuota, nsQuota, data);
        case DIRECTORY:
            fillDirSummary(id, data);
            nsQuota = inode.getDirectory().getNsQuota();
            spaceQuota = inode.getDirectory().getDsQuota();
            return fillSummaryMap(spaceQuota, nsQuota, data);
        case SYMLINK:
            data[0] = 0;
            data[1] = 1;
            data[2] = 0;
            nsQuota = -1;
            data[3] = 0;
            spaceQuota = -1;
            return fillSummaryMap(spaceQuota, nsQuota, data);
        default:
            return null;
    }
}
Also used : FSImageFormatPBINode(org.apache.hadoop.hdfs.server.namenode.FSImageFormatPBINode) INode(org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection.INode)

Example 3 with INode

use of org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection.INode in project hadoop by apache.

the class FSImageLoader method getXAttrList.

private List<XAttr> getXAttrList(String path) throws IOException {
    long id = lookup(path);
    FsImageProto.INodeSection.INode inode = fromINodeId(id);
    switch(inode.getType()) {
        case FILE:
            return FSImageFormatPBINode.Loader.loadXAttrs(inode.getFile().getXAttrs(), stringTable);
        case DIRECTORY:
            return FSImageFormatPBINode.Loader.loadXAttrs(inode.getDirectory().getXAttrs(), stringTable);
        default:
            return null;
    }
}
Also used : INode(org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection.INode)

Example 4 with INode

use of org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection.INode in project hadoop by apache.

the class FSImageLoader method getAclEntryList.

private List<AclEntry> getAclEntryList(String path) throws IOException {
    long id = lookup(path);
    FsImageProto.INodeSection.INode inode = fromINodeId(id);
    switch(inode.getType()) {
        case FILE:
            {
                FsImageProto.INodeSection.INodeFile f = inode.getFile();
                return FSImageFormatPBINode.Loader.loadAclEntries(f.getAcl(), stringTable);
            }
        case DIRECTORY:
            {
                FsImageProto.INodeSection.INodeDirectory d = inode.getDirectory();
                return FSImageFormatPBINode.Loader.loadAclEntries(d.getAcl(), stringTable);
            }
        default:
            {
                return new ArrayList<AclEntry>();
            }
    }
}
Also used : FsImageProto(org.apache.hadoop.hdfs.server.namenode.FsImageProto) AclEntry(org.apache.hadoop.fs.permission.AclEntry) INode(org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection.INode) INodeFile(org.apache.hadoop.hdfs.server.namenode.INodeFile)

Example 5 with INode

use of org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection.INode in project hadoop by apache.

the class FSImageLoader method getPermissionStatus.

private PermissionStatus getPermissionStatus(String path) throws IOException {
    long id = lookup(path);
    FsImageProto.INodeSection.INode inode = fromINodeId(id);
    switch(inode.getType()) {
        case FILE:
            {
                FsImageProto.INodeSection.INodeFile f = inode.getFile();
                return FSImageFormatPBINode.Loader.loadPermission(f.getPermission(), stringTable);
            }
        case DIRECTORY:
            {
                FsImageProto.INodeSection.INodeDirectory d = inode.getDirectory();
                return FSImageFormatPBINode.Loader.loadPermission(d.getPermission(), stringTable);
            }
        case SYMLINK:
            {
                FsImageProto.INodeSection.INodeSymlink s = inode.getSymlink();
                return FSImageFormatPBINode.Loader.loadPermission(s.getPermission(), stringTable);
            }
        default:
            {
                return null;
            }
    }
}
Also used : FsImageProto(org.apache.hadoop.hdfs.server.namenode.FsImageProto) INode(org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection.INode) INodeFile(org.apache.hadoop.hdfs.server.namenode.INodeFile)

Aggregations

INode (org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection.INode)8 FSImageFormatPBINode (org.apache.hadoop.hdfs.server.namenode.FSImageFormatPBINode)4 FsImageProto (org.apache.hadoop.hdfs.server.namenode.FsImageProto)2 INodeSection (org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection)2 INodeFile (org.apache.hadoop.hdfs.server.namenode.INodeFile)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 AclEntry (org.apache.hadoop.fs.permission.AclEntry)1