Package org.apache.hadoop.hbase.wal
Class WALPrettyPrinter
java.lang.Object
org.apache.hadoop.hbase.wal.WALPrettyPrinter
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
FieldsModifier and TypeFieldDescriptionprivate booleanprivate static final org.apache.hbase.thirdparty.com.google.gson.Gsonprivate static final org.slf4j.Loggerprivate PrintStreamprivate booleanprivate booleanprivate static final Stringprivate booleanprivate booleanprivate longprivate Stringprivate Stringprivate Stringprivate long -
Constructor Summary
ConstructorsConstructorDescriptionBasic constructor that simply initializes values to reasonable defaults. -
Method Summary
Modifier and TypeMethodDescriptionvoidenables output as a single, persistent list.voidturns JSON output off, and turns on "pretty strings" for human consumptionvoidturns value output offvoidturns JSON output onvoidturns value output onvoidends output of a single, persistent list.static voidstatic voidprintCell(PrintStream out, Map<String, Object> op, boolean outputValues, boolean outputOnlyRowKey) voidprocessFile(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 voidPass one or more log file names and formatting options and it will dump out a text version of the contents onstdout.voidOption to print the row key only in case you just need the row keys from the WALvoidsetPosition(long position) sets the position to start seeking the WAL file initial position to start seeking the given WAL filevoidsetRegionFilter(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 printedvoidsetRowFilter(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 printedvoidsetRowPrefixFilter(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 printedvoidsetSequenceFilter(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 printedvoidsetTableFilter(String tablesWithDelimiter) Sets the tables filter.toStringMap(ExtendedCell cell) toStringMap(ExtendedCell cell, boolean printRowKeyOnly, String rowPrefix, String row, boolean outputValues)
-
Field Details
-
LOG
-
outputTmpl
- See Also:
-
outputValues
-
outputJSON
-
sequence
-
tableSet
-
region
-
row
-
rowPrefix
-
outputOnlyRowKey
-
persistentOutput
-
firstTxn
-
out
-
GSON
-
position
-
-
Constructor Details
-
WALPrettyPrinter
public WALPrettyPrinter()Basic constructor that simply initializes values to reasonable defaults.
-
-
Method Details
-
enableValues
turns value output on -
disableValues
turns value output off -
enableJSON
turns JSON output on -
disableJSON
turns JSON output off, and turns on "pretty strings" for human consumption -
setSequenceFilter
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
Sets the tables filter. Only log entries for these tables are printed.- Parameters:
tablesWithDelimiter- table names separated with comma.
-
setRegionFilter
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
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
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
Option to print the row key only in case you just need the row keys from the WAL -
setPosition
sets the position to start seeking the WAL file initial position to start seeking the given WAL file -
beginPersistentOutput
enables output as a single, persistent list. at present, only relevant in the case of JSON output. -
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(ExtendedCell cell, boolean printRowKeyOnly, String rowPrefix, String row, boolean outputValues) -
toStringMap
-
main
- Throws:
IOException
-
run
Pass one or more log file names and formatting options and it will dump out a text version of the contents onstdout. Command line arguments Thrown upon file system errors etc.- Throws:
IOException
-