FSImageSerialization (Apache Hadoop HDFS 3.5.0 API)
Description: declaration: package: org.apache.hadoop.hdfs.server.namenode, class: FSImageSerialization

Package org.apache.hadoop.hdfs.server.namenode

# Class FSImageSerialization

java.lang.Object
org.apache.hadoop.hdfs.server.namenode.FSImageSerialization

@Private @Evolving public class FSImageSerialization extends Object
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 Type
  Method
  Description
  `static byte`
  `readByte(DataInput in)`
  `static byte[]`
  `readBytes(DataInput in)`
  `static org.apache.hadoop.hdfs.protocol.CacheDirectiveInfo`
  `readCacheDirectiveInfo(DataInput in)`
  `static org.apache.hadoop.hdfs.protocol.CacheDirectiveInfo`
  `readCacheDirectiveInfo(XMLUtils.Stanza st)`
  `static org.apache.hadoop.hdfs.protocol.CachePoolInfo`
  `readCachePoolInfo(DataInput in)`
  `static org.apache.hadoop.hdfs.protocol.CachePoolInfo`
  `readCachePoolInfo(XMLUtils.Stanza st)`
  `static org.apache.hadoop.hdfs.protocol.Block[]`
  `readCompactBlockArray(DataInput in, int logVersion)`
  `static org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy`
  `readErasureCodingPolicy(DataInput in)`
  `static byte[]`
  `readLocalName(DataInput in)`
  `static byte[][]`
  `readPathComponents(DataInput in)`
  Reading the path from the image and converting it to byte[][] directly this saves us an array copy and conversions to and from String
  `static String`
  `readString(DataInput in)`
  `static void`
  `saveINode2Image(INode node, DataOutput out, boolean writeUnderConstruction, SnapshotFSImageFormat.ReferenceMap referenceMap)`
  Save one inode's attributes to the image.
  `static void`
  `writeBytes(byte[] data, DataOutput out)`
  `static void`
  `writeCacheDirectiveInfo(DataOutputStream out, org.apache.hadoop.hdfs.protocol.CacheDirectiveInfo directive)`
  `static void`
  `writeCacheDirectiveInfo(ContentHandler contentHandler, org.apache.hadoop.hdfs.protocol.CacheDirectiveInfo directive)`
  `static void`
  `writeCachePoolInfo(DataOutputStream out, org.apache.hadoop.hdfs.protocol.CachePoolInfo info)`
  `static void`
  `writeCachePoolInfo(ContentHandler contentHandler, org.apache.hadoop.hdfs.protocol.CachePoolInfo info)`
  `static void`
  `writeCompactBlockArray(org.apache.hadoop.hdfs.protocol.Block[] blocks, DataOutputStream out)`
  Write an array of blocks as compactly as possible.
  `static void`
  `writeErasureCodingPolicy(DataOutputStream out, org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy ecPolicy)`
  `static void`
  `writeINodeDirectory(INodeDirectory node, DataOutput out)`
  Serialize a `INodeDirectory`
  `static void`
  `writeINodeDirectoryAttributes(INodeDirectoryAttributes a, DataOutput out)`
  Serialize a `INodeDirectory`
  `static void`
  `writeINodeFile(INodeFile file, DataOutput out, boolean writeUnderConstruction)`
  Serialize a `INodeFile` node
  `static void`
  `writeINodeFileAttributes(INodeFileAttributes file, DataOutput out)`
  Serialize an `INodeFileAttributes`.
  `static void`
  `writeString(String str, DataOutput out)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### writeINodeFile

    public static void writeINodeFile(INodeFile file, DataOutput out, boolean writeUnderConstruction) throws IOException
    Serialize a `INodeFile` node
    Parameters:
      `file` - The INodeFile to write
      `out` - The `DataOutputStream` where the fields are written
      `writeUnderConstruction` - Whether to write under construction information
    Throws:
      `IOException`

  - ### writeINodeFileAttributes

    public static void writeINodeFileAttributes(INodeFileAttributes file, DataOutput out) throws IOException
    Serialize an `INodeFileAttributes`.
    Throws:
      `IOException`

  - ### writeINodeDirectory

    public static void writeINodeDirectory(INodeDirectory node, DataOutput out) throws IOException
    Serialize a `INodeDirectory`
    Parameters:
      `node` - The node to write
      `out` - The `DataOutput` where the fields are written
    Throws:
      `IOException`

  - ### writeINodeDirectoryAttributes

    public static void writeINodeDirectoryAttributes(INodeDirectoryAttributes a, DataOutput out) throws IOException
    Serialize a `INodeDirectory`
    Parameters:
      `a` - The node to write
      `out` - The `DataOutput` where 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

    public static String readString(DataInput in) throws IOException
    Throws:
      `IOException`

  - ### writeString

    public static void writeString(String str, DataOutput out) throws IOException
    Throws:
      `IOException`

  - ### readBytes

    public static byte[] readBytes(DataInput in) throws IOException
    Throws:
      `IOException`

  - ### readByte

    public static byte readByte(DataInput in) throws IOException
    Throws:
      `IOException`

  - ### readPathComponents

    public static byte[][] readPathComponents(DataInput in) throws IOException
    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

    public static byte[] readLocalName(DataInput in) throws IOException
    Throws:
      `IOException`

  - ### writeBytes

    public static void writeBytes(byte[] data, DataOutput out) throws IOException
    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`