if (component.equals(child.getName().toStringUtf8())) { found = true; id = child.getId(); break;
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);
private void outputINodes(InputStream in) throws IOException { INodeSection s = INodeSection.parseDelimitedFrom(in); LOG.info("Found {} INodes in the INode section", s.getNumInodes()); for (int i = 0; i < s.getNumInodes(); ++i) { INode p = INode.parseDelimitedFrom(in); String parentPath = metadataMap.getParentPath(p.getId()); out.println(getEntry(parentPath, p)); if (LOG.isDebugEnabled() && i % 100000 == 0) { LOG.debug("Outputted {} INodes.", i); } } LOG.info("Outputted {} INodes.", s.getNumInodes()); } }
private INodeSymlink loadINodeSymlink(INodeSection.INode n) { assert n.getType() == INodeSection.INode.Type.SYMLINK; INodeSection.INodeSymlink s = n.getSymlink(); final PermissionStatus permissions = loadPermission(s.getPermission(), parent.getLoaderContext().getStringTable()); INodeSymlink sym = new INodeSymlink(n.getId(), n.getName().toByteArray(), permissions, s.getModificationTime(), s.getAccessTime(), s.getTarget().toStringUtf8()); return sym; }
private INodeSymlink loadINodeSymlink(INodeSection.INode n) { assert n.getType() == INodeSection.INode.Type.SYMLINK; INodeSection.INodeSymlink s = n.getSymlink(); final PermissionStatus permissions = loadPermission(s.getPermission(), parent.getLoaderContext().getStringTable()); INodeSymlink sym = new INodeSymlink(n.getId(), n.getName().toByteArray(), permissions, s.getModificationTime(), s.getAccessTime(), s.getTarget().toStringUtf8()); return sym; }
map.put("fileId", inode.getId()); map.put("childrenNum", 0); return map; map.put("replication", 0); map.put("type", inode.getType()); map.put("fileId", inode.getId()); map.put("childrenNum", dirmap.containsKey(inode.getId()) ? dirmap.get(inode.getId()).length : 0); return map; map.put("type", inode.getType()); map.put("symlink", d.getTarget().toStringUtf8()); map.put("fileId", inode.getId()); map.put("childrenNum", 0); return map;
if (isStriped) { Preconditions.checkState(ecPolicy.getId() > 0, "File with ID " + n.getId() + " has an invalid erasure coding policy ID " + ecPolicy.getId()); blocks[i] = new BlockInfoStriped(PBHelperClient.convert(b), ecPolicy); parent.getLoaderContext().getStringTable()); final INodeFile file = new INodeFile(n.getId(), n.getName().toByteArray(), permissions, f.getModificationTime(), f.getAccessTime(), blocks, replication, ecPolicyID,
final INodeDirectory dir = new INodeDirectory(n.getId(), n.getName() .toByteArray(), permissions, d.getModificationTime()); final long nsQuota = d.getNsQuota(), dsQuota = d.getDsQuota();
public Builder mergeFrom(org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection.INode other) { if (other == org.apache.hadoop.hdfs.server.namenode.FsImageProto.INodeSection.INode.getDefaultInstance()) return this; if (other.hasType()) { setType(other.getType()); } if (other.hasId()) { setId(other.getId()); } if (other.hasName()) { setName(other.getName()); } if (other.hasFile()) { mergeFile(other.getFile()); } if (other.hasDirectory()) { mergeDirectory(other.getDirectory()); } if (other.hasSymlink()) { mergeSymlink(other.getSymlink()); } this.mergeUnknownFields(other.getUnknownFields()); return this; }
void loadINodeSection(InputStream in, StartupProgress prog, Step currentStep) throws IOException { INodeSection s = INodeSection.parseDelimitedFrom(in); fsn.dir.resetLastInodeId(s.getLastInodeId()); long numInodes = s.getNumInodes(); LOG.info("Loading " + numInodes + " INodes."); prog.setTotal(Phase.LOADING_FSIMAGE, currentStep, numInodes); Counter counter = prog.getCounter(Phase.LOADING_FSIMAGE, currentStep); for (int i = 0; i < numInodes; ++i) { INodeSection.INode p = INodeSection.INode.parseDelimitedFrom(in); if (p.getId() == INodeId.ROOT_INODE_ID) { loadRootINode(p); } else { INode n = loadINode(p); dir.addToInodeMap(n); } counter.increment(); } }
private FsImageProto.INodeSection.INode fromINodeId(final long id) throws IOException { int l = 0, r = inodes.length; while (l < r) { int mid = l + (r - l) / 2; FsImageProto.INodeSection.INode n = FsImageProto.INodeSection.INode .parseFrom(inodes[mid]); long nid = n.getId(); if (id > nid) { l = mid + 1; } else if (id < nid) { r = mid; } else { return n; } } return null; } }
@Override public int compare(byte[] o1, byte[] o2) { try { final FsImageProto.INodeSection.INode l = FsImageProto.INodeSection .INode.parseFrom(o1); final FsImageProto.INodeSection.INode r = FsImageProto.INodeSection .INode.parseFrom(o2); if (l.getId() < r.getId()) { return -1; } else if (l.getId() > r.getId()) { return 1; } else { return 0; } } catch (InvalidProtocolBufferException e) { throw new RuntimeException(e); } } };
private INodeSymlink loadINodeSymlink(INodeSection.INode n) { assert n.getType() == INodeSection.INode.Type.SYMLINK; INodeSection.INodeSymlink s = n.getSymlink(); final PermissionStatus permissions = loadPermission(s.getPermission(), parent.getLoaderContext().getStringTable()); INodeSymlink sym = new INodeSymlink(n.getId(), n.getName().toByteArray(), permissions, s.getModificationTime(), s.getAccessTime(), s.getTarget().toStringUtf8()); return sym; }
private void dumpINodeFields(INodeSection.INode p) { o(SECTION_ID, p.getId()).o(INODE_SECTION_TYPE, p.getType()) .o(SECTION_NAME, p.getName().toStringUtf8()); if (p.hasFile()) { dumpINodeFile(p.getFile()); } else if (p.hasDirectory()) { dumpINodeDirectory(p.getDirectory()); } else if (p.hasSymlink()) { dumpINodeSymlink(p.getSymlink()); } }