Search in sources :

Example 6 with INode

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

the class FSImageLoader method fillDirSummary.

private void fillDirSummary(long id, long[] data) throws IOException {
    data[0]++;
    long[] children = dirmap.get(id);
    if (children == null) {
        return;
    }
    for (long cid : children) {
        INode node = fromINodeId(cid);
        switch(node.getType()) {
            case DIRECTORY:
                fillDirSummary(cid, data);
                break;
            case FILE:
                FsImageProto.INodeSection.INodeFile f = node.getFile();
                long curLength = getFileSize(f);
                data[1]++;
                data[2] += curLength;
                data[3] += (curLength) * (f.getReplication());
                break;
            case SYMLINK:
                data[1]++;
                break;
            default:
                break;
        }
    }
}
Also used : FSImageFormatPBINode(org.apache.hadoop.hdfs.server.namenode.FSImageFormatPBINode) INode(org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection.INode)

Example 7 with INode

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

the class FSImageLoader method getFileStatusList.

private List<Map<String, Object>> getFileStatusList(String path) throws IOException {
    List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
    long id = lookup(path);
    FsImageProto.INodeSection.INode inode = fromINodeId(id);
    if (inode.getType() == FsImageProto.INodeSection.INode.Type.DIRECTORY) {
        if (!dirmap.containsKey(id)) {
            // if the directory is empty, return empty list
            return list;
        }
        long[] children = dirmap.get(id);
        for (long cid : children) {
            list.add(getFileStatus(fromINodeId(cid), true));
        }
    } else {
        list.add(getFileStatus(inode, false));
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) INode(org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection.INode) Map(java.util.Map)

Example 8 with INode

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

the class PBImageTextWriter method loadDirectoriesInINodeSection.

/**
   * Load the filenames of the directories from the INode section.
   */
private void loadDirectoriesInINodeSection(InputStream in) throws IOException {
    INodeSection s = INodeSection.parseDelimitedFrom(in);
    LOG.info("Loading directories in INode section.");
    int numDirs = 0;
    for (int i = 0; i < s.getNumInodes(); ++i) {
        INode p = INode.parseDelimitedFrom(in);
        if (LOG.isDebugEnabled() && i % 10000 == 0) {
            LOG.debug("Scanned {} inodes.", i);
        }
        if (p.hasDirectory()) {
            metadataMap.putDir(p);
            numDirs++;
        }
    }
    LOG.info("Found {} directories in INode section.", numDirs);
}
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)

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