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;
}
}
}
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;
}
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);
}
Aggregations