PBImageCorruptionDetector (Apache Hadoop HDFS 3.5.0 API)
Description: declaration: package: org.apache.hadoop.hdfs.tools.offlineImageViewer, class: PBImageCorruptionDetector

Package org.apache.hadoop.hdfs.tools.offlineImageViewer

# Class PBImageCorruptionDetector

java.lang.Object
org.apache.hadoop.hdfs.tools.offlineImageViewer.PBImageCorruptionDetector

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`

public class PBImageCorruptionDetector extends Object
The PBImageCorruptionDetector detects corruptions in the image. It produces a file with the found issues similar to the Delimited processor. The default delimiter is tab, as this is an unlikely value to be included in an inode path. The delimiter value can be changed via the constructor. It looks for the following kinds of corruptions: - an INode id is mentioned in the INodeDirectorySection, but not present in the INodeSection (corrupt INode case) - an INode has children, but at least one of them is corrupted (missing children case) If multiple layers of directory structure are damaged then it is possible that an INode is corrupted and also having corrupted children. Note that the OIV DetectCorruption processor check is not exhaustive, and only catches the corruptions like above. This processor may be up to extension in the future when new aspects of corruption are found.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `afterOutput()`
  Method called at the end of output() phase after all the inodes with known parentPath has been printed out.
  `protected void`
  `buildNamespace(InputStream in, List<Long> refIdList)`
  Scan the INodeDirectory section to construct the namespace.
  `protected void`
  `checkNode(FsImageProto.INodeSection.INode p, AtomicInteger numDirs)`
  Checks the inode (saves if directory), and counts them.
  `void`
  `close()`
  `String`
  `getEntry(String parentPath, FsImageProto.INodeSection.INode inode)`
  Get text output for the given inode.
  `String`
  `getErasureCodingPolicyName(FsImageProto.INodeSection.XAttrFeatureProto xattrFeatureProto)`
  `String`
  `getHeader()`
  Get text output for the header line.
  `protected org.apache.hadoop.fs.permission.PermissionStatus`
  `getPermission(long perm)`
  `int`
  `getStoragePolicy(FsImageProto.INodeSection.XAttrFeatureProto xattrFeatureProto)`
  `static void`
  `mergeFiles(String[] srcPaths, String resultPath)`
  `protected PrintStream`
  `serialOutStream()`
  `void`
  `visit(String filePath)`

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

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

- ## Method Details

  - ### getHeader

    public String getHeader()
    Get text output for the header line.

  - ### getEntry

    public String getEntry(String parentPath, FsImageProto.INodeSection.INode inode)
    Get text output for the given inode.
    Parameters:
      `parentPath` - the path of parent directory
      `inode` - the INode object to output.

  - ### checkNode

    protected void checkNode(FsImageProto.INodeSection.INode p, AtomicInteger numDirs) throws IOException
    Checks the inode (saves if directory), and counts them. Can be overridden if additional steps are taken when iterating through INodeSection.
    Throws:
      `IOException`

  - ### buildNamespace

    protected void buildNamespace(InputStream in, List<Long> refIdList) throws IOException
    Scan the INodeDirectory section to construct the namespace.
    Throws:
      `IOException`

  - ### afterOutput

    public void afterOutput() throws IOException
    Method called at the end of output() phase after all the inodes with known parentPath has been printed out. Can be used to print additional data depending on the written inodes.
    Throws:
      `IOException`

  - ### serialOutStream

    protected PrintStream serialOutStream()

  - ### close

    public void close() throws IOException
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `Closeable`
    Throws:
      `IOException`

  - ### visit

    public void visit(String filePath) throws IOException
    Throws:
      `IOException`

  - ### getPermission

    protected org.apache.hadoop.fs.permission.PermissionStatus getPermission(long perm)

  - ### getStoragePolicy

    public int getStoragePolicy(FsImageProto.INodeSection.XAttrFeatureProto xattrFeatureProto)

  - ### mergeFiles

    public static void mergeFiles(String[] srcPaths, String resultPath) throws IOException
    Parameters:
      `srcPaths` - Source files of contents to be merged
      `resultPath` - Merged file path
    Throws:
      `IOException`

  - ### getErasureCodingPolicyName

    public String getErasureCodingPolicyName(FsImageProto.INodeSection.XAttrFeatureProto xattrFeatureProto)