Class WALPrettyPrinter

java.lang.Object
org.apache.hadoop.hbase.wal.WALPrettyPrinter

@LimitedPrivate("Tools") @Evolving public class WALPrettyPrinter extends Object
WALPrettyPrinter prints the contents of a given WAL with a variety of options affecting formatting and extent of content. It targets two usage cases: pretty printing for ease of debugging directly by humans, and JSON output for consumption by monitoring and/or maintenance scripts. It can filter by row, region, or sequence id. It can also toggle output of values.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private boolean
     
    private static final org.apache.hbase.thirdparty.com.google.gson.Gson
     
    private static final org.slf4j.Logger
     
    private PrintStream
     
    private boolean
     
    private boolean
     
    private static final String
     
    private boolean
     
    private boolean
     
    private long
     
    private String
     
    private String
     
    private String
     
    private long
     
    private final Set<String>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Basic constructor that simply initializes values to reasonable defaults.
    WALPrettyPrinter(boolean outputValues, boolean outputJSON, long sequence, Set<String> tableSet, String region, String row, String rowPrefix, boolean outputOnlyRowKey, boolean persistentOutput, PrintStream out)
    Fully specified constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    enables output as a single, persistent list.
    void
    turns JSON output off, and turns on "pretty strings" for human consumption
    void
    turns value output off
    void
    turns JSON output on
    void
    turns value output on
    void
    ends output of a single, persistent list.
    static void
    main(String[] args)
     
    static void
    printCell(PrintStream out, Map<String,Object> op, boolean outputValues, boolean outputOnlyRowKey)
     
    void
    processFile(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path p)
    reads a log file and outputs its contents, one transaction at a time, as specified by the currently configured options the HBase configuration relevant to this log file the path of the log file to be read may be unable to access the configured filesystem or requested file.
    static void
    run(String[] args)
    Pass one or more log file names and formatting options and it will dump out a text version of the contents on stdout.
    void
    Option to print the row key only in case you just need the row keys from the WAL
    void
    setPosition(long position)
    sets the position to start seeking the WAL file initial position to start seeking the given WAL file
    void
    sets the region by which output will be filtered when not null, serves as a filter; only log entries from this region will be printed
    void
    sets the row key by which output will be filtered when not null, serves as a filter; only log entries from this row will be printed
    void
    sets the rowPrefix key prefix by which output will be filtered when not null, serves as a filter; only log entries with rows having this prefix will be printed
    void
    setSequenceFilter(long sequence)
    sets the region by which output will be filtered when nonnegative, serves as a filter; only log entries with this sequence id will be printed
    void
    setTableFilter(String tablesWithDelimiter)
    Sets the tables filter.
    static Map<String,Object>
     
    static Map<String,Object>
    toStringMap(Cell cell, boolean printRowKeyOnly, String rowPrefix, String row, boolean outputValues)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • WALPrettyPrinter

      Basic constructor that simply initializes values to reasonable defaults.
    • WALPrettyPrinter

      public WALPrettyPrinter(boolean outputValues, boolean outputJSON, long sequence, Set<String> tableSet, String region, String row, String rowPrefix, boolean outputOnlyRowKey, boolean persistentOutput, PrintStream out)
      Fully specified constructor.
      Parameters:
      outputValues - when true, enables output of values along with other log information
      outputJSON - when true, enables output in JSON format rather than a "pretty string"
      sequence - when nonnegative, serves as a filter; only log entries with this sequence id will be printed
      tableSet - when non null, serves as a filter. only entries corresponding to tables in the tableSet are printed
      region - when not null, serves as a filter; only log entries from this region will be printed
      row - when not null, serves as a filter; only log entries from this row will be printed
      rowPrefix - when not null, serves as a filter; only log entries with row key having this prefix will be printed
      persistentOutput - keeps a single list running for multiple files. if enabled, the endPersistentOutput() method must be used!
      out - Specifies an alternative to stdout for the destination of this PrettyPrinter's output.
  • Method Details

    • enableValues

      public void enableValues()
      turns value output on
    • disableValues

      public void disableValues()
      turns value output off
    • enableJSON

      public void enableJSON()
      turns JSON output on
    • disableJSON

      public void disableJSON()
      turns JSON output off, and turns on "pretty strings" for human consumption
    • setSequenceFilter

      public void setSequenceFilter(long sequence)
      sets the region by which output will be filtered when nonnegative, serves as a filter; only log entries with this sequence id will be printed
    • setTableFilter

      public void setTableFilter(String tablesWithDelimiter)
      Sets the tables filter. Only log entries for these tables are printed.
      Parameters:
      tablesWithDelimiter - table names separated with comma.
    • setRegionFilter

      public void setRegionFilter(String region)
      sets the region by which output will be filtered when not null, serves as a filter; only log entries from this region will be printed
    • setRowFilter

      public void setRowFilter(String row)
      sets the row key by which output will be filtered when not null, serves as a filter; only log entries from this row will be printed
    • setRowPrefixFilter

      public void setRowPrefixFilter(String rowPrefix)
      sets the rowPrefix key prefix by which output will be filtered when not null, serves as a filter; only log entries with rows having this prefix will be printed
    • setOutputOnlyRowKey

      public void setOutputOnlyRowKey()
      Option to print the row key only in case you just need the row keys from the WAL
    • setPosition

      public void setPosition(long position)
      sets the position to start seeking the WAL file initial position to start seeking the given WAL file
    • beginPersistentOutput

      public void beginPersistentOutput()
      enables output as a single, persistent list. at present, only relevant in the case of JSON output.
    • endPersistentOutput

      public void endPersistentOutput()
      ends output of a single, persistent list. at present, only relevant in the case of JSON output.
    • processFile

      public void processFile(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path p) throws IOException
      reads a log file and outputs its contents, one transaction at a time, as specified by the currently configured options the HBase configuration relevant to this log file the path of the log file to be read may be unable to access the configured filesystem or requested file.
      Throws:
      IOException
    • printCell

      public static void printCell(PrintStream out, Map<String,Object> op, boolean outputValues, boolean outputOnlyRowKey)
    • toStringMap

      public static Map<String,Object> toStringMap(Cell cell, boolean printRowKeyOnly, String rowPrefix, String row, boolean outputValues)
    • toStringMap

      public static Map<String,Object> toStringMap(Cell cell)
    • main

      public static void main(String[] args) throws IOException
      Throws:
      IOException
    • run

      public static void run(String[] args) throws IOException
      Pass one or more log file names and formatting options and it will dump out a text version of the contents on stdout. Command line arguments Thrown upon file system errors etc.
      Throws:
      IOException