org.apache.hadoop.hbase.regionserver.wal
Class HLogPrettyPrinter

java.lang.Object
  extended by org.apache.hadoop.hbase.regionserver.wal.HLogPrettyPrinter

public class HLogPrettyPrinter
extends Object

HLogPrettyPrinter prints the contents of a given HLog 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.


Constructor Summary
HLogPrettyPrinter()
          Basic constructor that simply initializes values to reasonable defaults.
HLogPrettyPrinter(boolean outputValues, boolean outputJSON, long sequence, String region, String row, boolean persistentOutput, PrintStream out)
          Fully specified constructor.
 
Method Summary
 void beginPersistentOutput()
          enables output as a single, persistent list.
 void disableJSON()
          turns JSON output off, and turns on "pretty strings" for human consumption
 void disableValues()
          turns value output off
 void enableJSON()
          turns JSON output on
 void enableValues()
          turns value output on
 void endPersistentOutput()
          ends output of a single, persistent list.
 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
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 setRegionFilter(String region)
          sets the region by which output will be filtered
 void setRowFilter(String row)
          sets the region by which output will be filtered
 void setSequenceFilter(long sequence)
          sets the region by which output will be filtered
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HLogPrettyPrinter

public HLogPrettyPrinter()
Basic constructor that simply initializes values to reasonable defaults.


HLogPrettyPrinter

public HLogPrettyPrinter(boolean outputValues,
                         boolean outputJSON,
                         long sequence,
                         String region,
                         String row,
                         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
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
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 Detail

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

Parameters:
sequence - when nonnegative, serves as a filter; only log entries with this sequence id will be printed

setRegionFilter

public void setRegionFilter(String region)
sets the region by which output will be filtered

Parameters:
region - when not null, serves as a filter; only log entries from this region will be printed

setRowFilter

public void setRowFilter(String row)
sets the region by which output will be filtered

Parameters:
row - when not null, serves as a filter; only log entries from this row will be printed

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

Parameters:
conf - the HBase configuration relevant to this log file
p - the path of the log file to be read
Throws:
IOException - may be unable to access the configured filesystem or requested file.

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.

Parameters:
args - Command line arguments
Throws:
IOException - Thrown upon file system errors etc.
org.apache.commons.cli.ParseException - Thrown if command-line parsing fails.


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.