Class FSImageSerialization
java.lang.Object
org.apache.hadoop.hdfs.server.namenode.FSImageSerialization
Static utility functions for serializing various pieces of data in the correct
format for the FSImage file.
Some members are currently public for the benefit of the Offline Image Viewer
which is located outside of this package. These members should be made
package-protected when the OIV is refactored.
-
Method Summary
Modifier and TypeMethodDescriptionstatic bytestatic byte[]static org.apache.hadoop.hdfs.protocol.CacheDirectiveInfostatic org.apache.hadoop.hdfs.protocol.CacheDirectiveInfostatic org.apache.hadoop.hdfs.protocol.CachePoolInfostatic org.apache.hadoop.hdfs.protocol.CachePoolInfostatic org.apache.hadoop.hdfs.protocol.Block[]readCompactBlockArray(DataInput in, int logVersion) static org.apache.hadoop.hdfs.protocol.ErasureCodingPolicystatic byte[]static byte[][]Reading the path from the image and converting it to byte[][] directly this saves us an array copy and conversions to and from Stringstatic StringreadString(DataInput in) static voidsaveINode2Image(INode node, DataOutput out, boolean writeUnderConstruction, SnapshotFSImageFormat.ReferenceMap referenceMap) Save one inode's attributes to the image.static voidwriteBytes(byte[] data, DataOutput out) static voidwriteCacheDirectiveInfo(DataOutputStream out, org.apache.hadoop.hdfs.protocol.CacheDirectiveInfo directive) static voidwriteCacheDirectiveInfo(ContentHandler contentHandler, org.apache.hadoop.hdfs.protocol.CacheDirectiveInfo directive) static voidwriteCachePoolInfo(DataOutputStream out, org.apache.hadoop.hdfs.protocol.CachePoolInfo info) static voidwriteCachePoolInfo(ContentHandler contentHandler, org.apache.hadoop.hdfs.protocol.CachePoolInfo info) static voidwriteCompactBlockArray(org.apache.hadoop.hdfs.protocol.Block[] blocks, DataOutputStream out) Write an array of blocks as compactly as possible.static voidwriteErasureCodingPolicy(DataOutputStream out, org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy ecPolicy) static voidwriteINodeDirectory(INodeDirectory node, DataOutput out) Serialize aINodeDirectorystatic voidSerialize aINodeDirectorystatic voidwriteINodeFile(INodeFile file, DataOutput out, boolean writeUnderConstruction) Serialize aINodeFilenodestatic voidSerialize anINodeFileAttributes.static voidwriteString(String str, DataOutput out)
-
Method Details
-
writeINodeFile
public static void writeINodeFile(INodeFile file, DataOutput out, boolean writeUnderConstruction) throws IOException Serialize aINodeFilenode- Parameters:
file- The INodeFile to writeout- TheDataOutputStreamwhere the fields are writtenwriteUnderConstruction- Whether to write under construction information- Throws:
IOException
-
writeINodeFileAttributes
public static void writeINodeFileAttributes(INodeFileAttributes file, DataOutput out) throws IOException Serialize anINodeFileAttributes.- Throws:
IOException
-
writeINodeDirectory
Serialize aINodeDirectory- Parameters:
node- The node to writeout- TheDataOutputwhere the fields are written- Throws:
IOException
-
writeINodeDirectoryAttributes
public static void writeINodeDirectoryAttributes(INodeDirectoryAttributes a, DataOutput out) throws IOException Serialize aINodeDirectory- Parameters:
a- The node to writeout- TheDataOutputwhere the fields are written- Throws:
IOException
-
saveINode2Image
public static void saveINode2Image(INode node, DataOutput out, boolean writeUnderConstruction, SnapshotFSImageFormat.ReferenceMap referenceMap) throws IOException Save one inode's attributes to the image.- Throws:
IOException
-
readString
- Throws:
IOException
-
writeString
- Throws:
IOException
-
readBytes
- Throws:
IOException
-
readByte
- Throws:
IOException
-
readPathComponents
Reading the path from the image and converting it to byte[][] directly this saves us an array copy and conversions to and from String- Parameters:
in- input to read from- Returns:
- the array each element of which is a byte[] representation of a path component
- Throws:
IOException
-
readLocalName
- Throws:
IOException
-
writeBytes
- Throws:
IOException
-
writeCompactBlockArray
public static void writeCompactBlockArray(org.apache.hadoop.hdfs.protocol.Block[] blocks, DataOutputStream out) throws IOException Write an array of blocks as compactly as possible. This uses delta-encoding for the generation stamp and size, following the principle that genstamp increases relatively slowly, and size is equal for all but the last block of a file.- Throws:
IOException
-
readCompactBlockArray
public static org.apache.hadoop.hdfs.protocol.Block[] readCompactBlockArray(DataInput in, int logVersion) throws IOException - Throws:
IOException
-
writeCacheDirectiveInfo
public static void writeCacheDirectiveInfo(DataOutputStream out, org.apache.hadoop.hdfs.protocol.CacheDirectiveInfo directive) throws IOException - Throws:
IOException
-
readCacheDirectiveInfo
public static org.apache.hadoop.hdfs.protocol.CacheDirectiveInfo readCacheDirectiveInfo(DataInput in) throws IOException - Throws:
IOException
-
readCacheDirectiveInfo
public static org.apache.hadoop.hdfs.protocol.CacheDirectiveInfo readCacheDirectiveInfo(XMLUtils.Stanza st) throws XMLUtils.InvalidXmlException - Throws:
XMLUtils.InvalidXmlException
-
writeCacheDirectiveInfo
public static void writeCacheDirectiveInfo(ContentHandler contentHandler, org.apache.hadoop.hdfs.protocol.CacheDirectiveInfo directive) throws SAXException - Throws:
SAXException
-
writeCachePoolInfo
public static void writeCachePoolInfo(DataOutputStream out, org.apache.hadoop.hdfs.protocol.CachePoolInfo info) throws IOException - Throws:
IOException
-
readCachePoolInfo
public static org.apache.hadoop.hdfs.protocol.CachePoolInfo readCachePoolInfo(DataInput in) throws IOException - Throws:
IOException
-
writeCachePoolInfo
public static void writeCachePoolInfo(ContentHandler contentHandler, org.apache.hadoop.hdfs.protocol.CachePoolInfo info) throws SAXException - Throws:
SAXException
-
readCachePoolInfo
public static org.apache.hadoop.hdfs.protocol.CachePoolInfo readCachePoolInfo(XMLUtils.Stanza st) throws XMLUtils.InvalidXmlException - Throws:
XMLUtils.InvalidXmlException
-
writeErasureCodingPolicy
public static void writeErasureCodingPolicy(DataOutputStream out, org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy ecPolicy) throws IOException - Throws:
IOException
-
readErasureCodingPolicy
public static org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy readErasureCodingPolicy(DataInput in) throws IOException - Throws:
IOException
-