@Override void write(DataOutput out, ReferenceMap referenceMap) throws IOException { writeSnapshot(out); out.writeInt(childrenSize); // Write snapshotINode out.writeBoolean(isSnapshotRoot); if (!isSnapshotRoot) { if (snapshotINode != null) { out.writeBoolean(true); FSImageSerialization.writeINodeDirectoryAttributes(snapshotINode, out); } else { out.writeBoolean(false); } } // Write diff. Node need to write poseriorDiff, since diffs is a list. diff.write(out, referenceMap); }
@Override void write(DataOutput out, ReferenceMap referenceMap) throws IOException { writeSnapshot(out); out.writeInt(childrenSize); // write snapshotINode if (isSnapshotRoot()) { out.writeBoolean(true); } else { out.writeBoolean(false); if (snapshotINode != null) { out.writeBoolean(true); FSImageSerialization.writeINodeDirectoryAttributes(snapshotINode, out); } else { out.writeBoolean(false); } } // Write diff. Node need to write poseriorDiff, since diffs is a list. diff.write(out, referenceMap); }
/** Serialize a {@link INodeReference} node */ private static void writeINodeReference(INodeReference ref, DataOutput out, boolean writeUnderConstruction, ReferenceMap referenceMap ) throws IOException { writeLocalName(ref, out); out.writeLong(ref.getId()); out.writeShort(0); // replication out.writeLong(0); // modification time out.writeLong(0); // access time out.writeLong(0); // preferred block size out.writeInt(-3); // # of blocks final boolean isWithName = ref instanceof INodeReference.WithName; out.writeBoolean(isWithName); if (!isWithName) { Preconditions.checkState(ref instanceof INodeReference.DstReference); // dst snapshot id out.writeInt(((INodeReference.DstReference) ref).getDstSnapshotId()); } else { out.writeInt(((INodeReference.WithName) ref).getLastSnapshotId()); } final INodeReference.WithCount withCount = (INodeReference.WithCount)ref.getReferredINode(); referenceMap.writeINodeReferenceWithCount(withCount, out, writeUnderConstruction); }
/** * Save one inode's attributes to the image. */ public static void saveINode2Image(INode node, DataOutput out, boolean writeUnderConstruction, ReferenceMap referenceMap) throws IOException { if (node.isReference()) { writeINodeReference(node.asReference(), out, writeUnderConstruction, referenceMap); } else if (node.isDirectory()) { writeINodeDirectory(node.asDirectory(), out); } else if (node.isSymlink()) { writeINodeSymlink(node.asSymlink(), out); } else if (node.isFile()) { writeINodeFile(node.asFile(), out, writeUnderConstruction); } }
@Override void write(DataOutput out, ReferenceMap referenceMap) throws IOException { writeSnapshot(out); out.writeLong(fileSize); // write snapshotINode if (snapshotINode != null) { out.writeBoolean(true); FSImageSerialization.writeINodeFileAttributes(snapshotINode, out); } else { out.writeBoolean(false); } }
/** Serialize {@link #deleted} */ private void writeDeleted(DataOutput out, ReferenceMap referenceMap) throws IOException { final List<INode> deleted = getList(ListType.DELETED); out.writeInt(deleted.size()); for (INode node : deleted) { FSImageSerialization.saveINode2Image(node, out, true, referenceMap); } }
/** * Saves inode and increments progress counter. * * @param inode INode to save * @param out DataOutputStream to receive inode * @param writeUnderConstruction boolean true if this is under construction * @param referenceMap ReferenceMap containing reference inodes * @param counter Counter to increment for namenode startup progress * @throws IOException thrown if there is an I/O error */ private void saveINode2Image(INode inode, DataOutputStream out, boolean writeUnderConstruction, ReferenceMap referenceMap, Counter counter) throws IOException { FSImageSerialization.saveINode2Image(inode, out, writeUnderConstruction, referenceMap); // Intentionally do not increment counter for reference inodes, because it // is too difficult at this point to assess whether or not this is a // reference that counts toward quota. if (!(inode instanceof INodeReference)) { counter.increment(); } }
/** Serialize a {@link INodeReference} node */ private static void writeINodeReference(INodeReference ref, DataOutput out, boolean writeUnderConstruction, ReferenceMap referenceMap ) throws IOException { writeLocalName(ref, out); out.writeLong(ref.getId()); out.writeShort(0); // replication out.writeLong(0); // modification time out.writeLong(0); // access time out.writeLong(0); // preferred block size out.writeInt(-3); // # of blocks final boolean isWithName = ref instanceof INodeReference.WithName; out.writeBoolean(isWithName); if (!isWithName) { Preconditions.checkState(ref instanceof INodeReference.DstReference); // dst snapshot id out.writeInt(ref.getDstSnapshotId()); } else { out.writeInt(((INodeReference.WithName) ref).getLastSnapshotId()); } final INodeReference.WithCount withCount = (INodeReference.WithCount)ref.getReferredINode(); referenceMap.writeINodeReferenceWithCount(withCount, out, writeUnderConstruction); }