View Javadoc

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  import org.codehaus.jackson.map.ObjectMapper;
47  
48  /**
49   * HLogPrettyPrinter prints the contents of a given HLog with a variety of
50   * options affecting formatting and extent of content.
51   *
52   * It targets two usage cases: pretty printing for ease of debugging directly by
53   * humans, and JSON output for consumption by monitoring and/or maintenance
54   * scripts.
55   *
56   * It can filter by row, region, or sequence id.
57   *
58   * It can also toggle output of values.
59   *
60   * @deprecated use the "hbase wal" command
61   */
62  @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.TOOLS)
63  @InterfaceStability.Evolving
64  @Deprecated
65  public class HLogPrettyPrinter extends WALPrettyPrinter {
66  
67    /**
68     * Basic constructor that simply initializes values to reasonable defaults.
69     */
70    public HLogPrettyPrinter() {
71      this(false, false, -1l, null, null, false, System.out);
72    }
73  
74    /**
75     * Fully specified constructor.
76     *
77     * @param outputValues
78     *          when true, enables output of values along with other log
79     *          information
80     * @param outputJSON
81     *          when true, enables output in JSON format rather than a
82     *          "pretty string"
83     * @param sequence
84     *          when nonnegative, serves as a filter; only log entries with this
85     *          sequence id will be printed
86     * @param region
87     *          when not null, serves as a filter; only log entries from this
88     *          region will be printed
89     * @param row
90     *          when not null, serves as a filter; only log entries from this row
91     *          will be printed
92     * @param persistentOutput
93     *          keeps a single list running for multiple files. if enabled, the
94     *          endPersistentOutput() method must be used!
95     * @param out
96     *          Specifies an alternative to stdout for the destination of this
97     *          PrettyPrinter's output.
98     */
99    public HLogPrettyPrinter(boolean outputValues, boolean outputJSON,
100       long sequence, String region, String row, boolean persistentOutput,
101       PrintStream out) {
102     super(outputValues, outputJSON, sequence, region, row, persistentOutput, out);
103   }
104 
105   public static void main(String[] args) throws IOException {
106     WALPrettyPrinter.main(args);
107   }
108 
109 }