Apache9 commented on a change in pull request #975: HBASE-23624 Add a tool to dump the procedure info in HFile URL: https://github.com/apache/hbase/pull/975#discussion_r362321486
########## File path: hbase-server/src/main/java/org/apache/hadoop/hbase/procedure2/store/region/HFileProcedurePrettyPrinter.java ########## @@ -0,0 +1,174 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.procedure2.store.region; + +import java.io.IOException; +import java.io.PrintStream; +import java.io.UncheckedIOException; +import java.util.ArrayList; +import java.util.List; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.hbase.Cell; +import org.apache.hadoop.hbase.CellUtil; +import org.apache.hadoop.hbase.HBaseInterfaceAudience; +import org.apache.hadoop.hbase.PrivateCellUtil; +import org.apache.hadoop.hbase.client.RegionInfo; +import org.apache.hadoop.hbase.io.hfile.CacheConfig; +import org.apache.hadoop.hbase.io.hfile.HFile; +import org.apache.hadoop.hbase.io.hfile.HFileScanner; +import org.apache.hadoop.hbase.procedure2.Procedure; +import org.apache.hadoop.hbase.procedure2.ProcedureUtil; +import org.apache.hadoop.hbase.util.AbstractHBaseTool; +import org.apache.hadoop.hbase.util.Bytes; +import org.apache.hadoop.hbase.util.CommonFSUtils; +import org.apache.yetus.audience.InterfaceAudience; +import org.apache.yetus.audience.InterfaceStability; + +import org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine; +import org.apache.hbase.thirdparty.org.apache.commons.cli.Option; +import org.apache.hbase.thirdparty.org.apache.commons.cli.OptionGroup; + +import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos; + +/** + * A tool to dump the procedures in the HFiles. + * <p/> + * The different between this and {@link org.apache.hadoop.hbase.io.hfile.HFilePrettyPrinter} is + * that, this class will decode the procedure in the cell for better debugging. You are free to use + * {@link org.apache.hadoop.hbase.io.hfile.HFilePrettyPrinter} to dump the same file as well. + */ +@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.TOOLS) +@InterfaceStability.Evolving +public class HFileProcedurePrettyPrinter extends AbstractHBaseTool { + + private Long procId; + + private List<Path> files = new ArrayList<>(); + + private final PrintStream out; + + public HFileProcedurePrettyPrinter() { + this(System.out); + } + + public HFileProcedurePrettyPrinter(PrintStream out) { + this.out = out; + } + + @Override + protected void addOptions() { + addOptWithArg("w", "seekToPid", "Seek to this procedure id and print this procedure only"); + OptionGroup files = new OptionGroup(); + files.addOption(new Option("f", "file", true, + "File to scan. Pass full-path; e.g. hdfs://a:9000/MasterProcs/master/procedure/p/xxx")); + files.addOption(new Option("a", "all", false, "Scan the whole procedure region.")); Review comment: I did not use the -f option for WALProcedurePrettyPrinter but here I think it is better to have a -f. As we have a -a option which is used to scan all the files, which means we do not need to specify any 'args' here. But if we want to purge the -f option then we need to pass the files as args. And use a directory is not straight forward here, as a region can have multiple families, which are also sub directories under the region directory, then we need another -r option to recursively scan the directory? Seems more complicated then... ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services