Class KeyValueContainerMetadataInspector

java.lang.Object
org.apache.hadoop.ozone.container.keyvalue.KeyValueContainerMetadataInspector
All Implemented Interfaces:
ContainerInspector

public class KeyValueContainerMetadataInspector extends Object implements ContainerInspector
Container inspector for key value container metadata. It is capable of logging metadata information about a container, and repairing the metadata database values of #BLOCKCOUNT and #BYTESUSED. To enable this inspector in inspect mode, pass the java system property -Dozone.datanode.container.metadata.inspector=inspect on datanode startup. This will cause the inspector to log metadata information about all containers on datanode startup whose aggregate values of #BLOCKCOUNT and #BYTESUSED do not match the sum of their parts in the database at the ERROR level, and information about correct containers at the TRACE level. Changing the `inspect` argument to `repair` will update these aggregate values to match the database. When run, the inspector will output json to the logger named in the REPORT_LOG variable. The log4j configuration can be modified to send this output to a separate file without log information prefixes interfering with the json. For example: log4j.logger.ContainerMetadataInspectorReport=INFO,inspectorAppender log4j.appender.inspectorAppender=org.apache.log4j.FileAppender log4j.appender.inspectorAppender.File=${hadoop.log.dir}/\ containerMetadataInspector.log log4j.appender.inspectorAppender.layout=org.apache.log4j.PatternLayout
  • Field Details

    • REPORT_LOG

      public static final org.slf4j.Logger REPORT_LOG
    • SYSTEM_PROPERTY

      public static final String SYSTEM_PROPERTY
      See Also:
  • Constructor Details

    • KeyValueContainerMetadataInspector

      public KeyValueContainerMetadataInspector(KeyValueContainerMetadataInspector.Mode mode)
    • KeyValueContainerMetadataInspector

      public KeyValueContainerMetadataInspector()
  • Method Details

    • load

      public boolean load()
      Validate configuration here so that an invalid config value is only logged once, and not once per container.
      Specified by:
      load in interface ContainerInspector
      Returns:
      true if the inspector will operate when process is called. False otherwise.
    • unload

      public void unload()
      Description copied from interface: ContainerInspector
      Removes configurations to run the inspector, so that the process method becomes a no-op.
      Specified by:
      unload in interface ContainerInspector
    • isReadOnly

      public boolean isReadOnly()
      Description copied from interface: ContainerInspector
      Determines whether the inspector will be modifying containers as part of the process method.
      Specified by:
      isReadOnly in interface ContainerInspector
      Returns:
      true if the inspector will only read the container, false if it will be making modifications/repairs.
    • process

      public void process(ContainerData containerData, DatanodeStore store)
      Description copied from interface: ContainerInspector
      Operates on the container as the inspector is configured. This may involve logging information or fixing errors. Multiple containers may be processed in parallel by calling this method on the same inspector instance, but only one process call will be invoked per container at a time. Implementations must ensure that: 1. Information they log is batched so that log output from other inspectors working on other containers is not interleaved. 2. Multiple process calls to the same inspector instance with different containers are thread safe.
      Specified by:
      process in interface ContainerInspector
      Parameters:
      containerData - Container data for the container to process.
      store - The metadata store for this container.
    • process

      public String process(ContainerData containerData, DatanodeStore store, org.slf4j.Logger log)