1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18 package org.apache.hadoop.hbase.regionserver.wal;
19
20 import java.io.FileNotFoundException;
21 import java.io.IOException;
22 import java.io.PrintStream;
23 import java.util.ArrayList;
24 import java.util.Date;
25 import java.util.HashMap;
26 import java.util.List;
27 import java.util.Map;
28
29 import org.apache.commons.cli.CommandLine;
30 import org.apache.commons.cli.CommandLineParser;
31 import org.apache.commons.cli.HelpFormatter;
32 import org.apache.commons.cli.Options;
33 import org.apache.commons.cli.ParseException;
34 import org.apache.commons.cli.PosixParser;
35 import org.apache.hadoop.hbase.classification.InterfaceAudience;
36 import org.apache.hadoop.hbase.classification.InterfaceStability;
37 import org.apache.hadoop.conf.Configuration;
38 import org.apache.hadoop.fs.FileSystem;
39 import org.apache.hadoop.fs.Path;
40 import org.apache.hadoop.hbase.HBaseConfiguration;
41 import org.apache.hadoop.hbase.KeyValue;
42 import org.apache.hadoop.hbase.util.Bytes;
43 import org.apache.hadoop.hbase.util.FSUtils;
44 import org.apache.hadoop.hbase.HBaseInterfaceAudience;
45 import org.apache.hadoop.hbase.wal.WALPrettyPrinter;
46
47 /**
48 * HLogPrettyPrinter prints the contents of a given HLog with a variety of
49 * options affecting formatting and extent of content.
50 *
51 * It targets two usage cases: pretty printing for ease of debugging directly by
52 * humans, and JSON output for consumption by monitoring and/or maintenance
53 * scripts.
54 *
55 * It can filter by row, region, or sequence id.
56 *
57 * It can also toggle output of values.
58 *
59 * @deprecated use the "hbase wal" command
60 */
61 @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.TOOLS)
62 @InterfaceStability.Evolving
63 @Deprecated
64 public class HLogPrettyPrinter extends WALPrettyPrinter {
65
66 /**
67 * Basic constructor that simply initializes values to reasonable defaults.
68 */
69 public HLogPrettyPrinter() {
70 this(false, false, -1l, null, null, false, System.out);
71 }
72
73 /**
74 * Fully specified constructor.
75 *
76 * @param outputValues
77 * when true, enables output of values along with other log
78 * information
79 * @param outputJSON
80 * when true, enables output in JSON format rather than a
81 * "pretty string"
82 * @param sequence
83 * when nonnegative, serves as a filter; only log entries with this
84 * sequence id will be printed
85 * @param region
86 * when not null, serves as a filter; only log entries from this
87 * region will be printed
88 * @param row
89 * when not null, serves as a filter; only log entries from this row
90 * will be printed
91 * @param persistentOutput
92 * keeps a single list running for multiple files. if enabled, the
93 * endPersistentOutput() method must be used!
94 * @param out
95 * Specifies an alternative to stdout for the destination of this
96 * PrettyPrinter's output.
97 */
98 public HLogPrettyPrinter(boolean outputValues, boolean outputJSON,
99 long sequence, String region, String row, boolean persistentOutput,
100 PrintStream out) {
101 super(outputValues, outputJSON, sequence, region, row, persistentOutput, out);
102 }
103
104 public static void main(String[] args) throws IOException {
105 WALPrettyPrinter.main(args);
106 }
107
108 }