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.Collections;
25  import java.util.Date;
26  import java.util.HashMap;
27  import java.util.List;
28  import java.util.Map;
29  
30  import org.apache.commons.cli.CommandLine;
31  import org.apache.commons.cli.CommandLineParser;
32  import org.apache.commons.cli.HelpFormatter;
33  import org.apache.commons.cli.Options;
34  import org.apache.commons.cli.ParseException;
35  import org.apache.commons.cli.PosixParser;
36  import org.apache.hadoop.hbase.classification.InterfaceAudience;
37  import org.apache.hadoop.hbase.classification.InterfaceStability;
38  import org.apache.hadoop.conf.Configuration;
39  import org.apache.hadoop.fs.FileSystem;
40  import org.apache.hadoop.fs.Path;
41  import org.apache.hadoop.hbase.HBaseConfiguration;
42  import org.apache.hadoop.hbase.KeyValue;
43  import org.apache.hadoop.hbase.util.Bytes;
44  import org.apache.hadoop.hbase.util.FSUtils;
45  import org.apache.hadoop.hbase.HBaseInterfaceAudience;
46  import org.apache.hadoop.hbase.wal.WALPrettyPrinter;
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, 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 table
87     *          when not null, serves as a filter; only log entries from this
88     *          table will be printed
89     * @param region
90     *          when not null, serves as a filter; only log entries from this
91     *          region will be printed
92     * @param row
93     *          when not null, serves as a filter; only log entries from this row
94     *          will be printed
95     * @param rowPrefix
96     *          when not null, serves as a filter; only log entries with row key
97     *          having this prefix will be printed
98     * @param persistentOutput
99     *          keeps a single list running for multiple files. if enabled, the
100    *          endPersistentOutput() method must be used!
101    * @param out
102    *          Specifies an alternative to stdout for the destination of this
103    *          PrettyPrinter's output.
104    */
105   public HLogPrettyPrinter(boolean outputValues, boolean outputJSON,
106       long sequence, String table, String region, String row, String rowPrefix,
107       boolean persistentOutput, PrintStream out) {
108     super(outputValues, outputJSON, sequence, Collections.singleton(table), region,
109       row, rowPrefix,false, persistentOutput, out);
110   }
111 
112   public static void main(String[] args) throws IOException {
113     WALPrettyPrinter.main(args);
114   }
115 
116 }