From 2eec39fa48f24f6ca3a075f47fcdf4aa4a8811c9 Mon Sep 17 00:00:00 2001 From: Nicolas Spiegelberg Date: Tue, 23 Aug 2011 21:37:32 +0000 Subject: [PATCH] HBASE-4244 Refactor bin/hbase help git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1160890 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 1 + bin/hbase | 38 +++++++++++++------ .../regionserver/wal/HLogPrettyPrinter.java | 6 ++- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 697604df1ef..f6d5c0ff631 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -396,6 +396,7 @@ Release 0.91.0 - Unreleased (Benoit Sigoure) HBASE-4199 blockCache summary - backend (Doug Meil) HBASE-4240 Allow Loadbalancer to be pluggable + HBASE-4244 Refactor bin/hbase help TASKS HBASE-3559 Move report of split to master OFF the heartbeat channel diff --git a/bin/hbase b/bin/hbase index d1670932764..3e569ba91fb 100755 --- a/bin/hbase +++ b/bin/hbase @@ -65,20 +65,28 @@ fi # if no args specified, show usage if [ $# = 0 ]; then echo "Usage: hbase " - echo "where is one of:" + echo "where an option from one of these categories:" + echo "" + echo "DBA TOOLS" echo " shell run the HBase shell" + echo " hbck run the hbase 'fsck' tool" + echo " hlog write-ahead-log analyzer" + echo " hfile store file analyzer" + echo " migrate upgrade an hbase.rootdir" echo " zkcli run the ZooKeeper shell" + echo "" + echo "PROCESS MANAGEMENT" echo " master run an HBase HMaster node" echo " regionserver run an HBase HRegionServer node" echo " zookeeper run a Zookeeper server" echo " rest run an HBase REST server" echo " thrift run an HBase Thrift server" echo " avro run an HBase Avro server" - echo " migrate upgrade an hbase.rootdir" - echo " hbck run the hbase 'fsck' tool" + echo "" + echo "PACKAGE MANAGEMENT" echo " classpath dump hbase CLASSPATH" echo " version print the version" - + echo "" echo " or" echo " CLASSNAME run the class named CLASSNAME" echo "Most commands print help when invoked w/o parameters." @@ -243,6 +251,19 @@ unset IFS # figure out which class to run if [ "$COMMAND" = "shell" ] ; then CLASS="org.jruby.Main ${HBASE_HOME}/bin/hirb.rb" +elif [ "$COMMAND" = "hbck" ] ; then + CLASS='org.apache.hadoop.hbase.util.HBaseFsck' +elif [ "$COMMAND" = "hlog" ] ; then + CLASS='org.apache.hadoop.hbase.regionserver.wal.HLogPrettyPrinter' +elif [ "$COMMAND" = "hfile" ] ; then + CLASS='org.apache.hadoop.hbase.io.hfile.HFile' +elif [ "$COMMAND" = "migrate" ] ; then + CLASS='org.apache.hadoop.hbase.util.Migrate' +elif [ "$COMMAND" = "zkcli" ] ; then + # ZooKeeperMainServerArg returns '-server HOST:PORT' or empty string. + SERVER_ARG=`"$bin"/hbase org.apache.hadoop.hbase.zookeeper.ZooKeeperMainServerArg` + CLASS="org.apache.zookeeper.ZooKeeperMain ${SERVER_ARG}" + elif [ "$COMMAND" = "master" ] ; then CLASS='org.apache.hadoop.hbase.master.HMaster' if [ "$1" != "stop" ] ; then @@ -268,19 +289,12 @@ elif [ "$COMMAND" = "avro" ] ; then if [ "$1" != "stop" ] ; then HBASE_OPTS="$HBASE_OPTS $HBASE_AVRO_OPTS" fi -elif [ "$COMMAND" = "migrate" ] ; then - CLASS='org.apache.hadoop.hbase.util.Migrate' -elif [ "$COMMAND" = "hbck" ] ; then - CLASS='org.apache.hadoop.hbase.util.HBaseFsck' elif [ "$COMMAND" = "zookeeper" ] ; then CLASS='org.apache.hadoop.hbase.zookeeper.HQuorumPeer' if [ "$1" != "stop" ] ; then HBASE_OPTS="$HBASE_OPTS $HBASE_ZOOKEEPER_OPTS" fi -elif [ "$COMMAND" = "zkcli" ] ; then - # ZooKeeperMainServerArg returns '-server HOST:PORT' or empty string. - SERVER_ARG=`"$bin"/hbase org.apache.hadoop.hbase.zookeeper.ZooKeeperMainServerArg` - CLASS="org.apache.zookeeper.ZooKeeperMain ${SERVER_ARG}" + elif [ "$COMMAND" = "classpath" ] ; then echo $CLASSPATH exit 0 diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogPrettyPrinter.java b/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogPrettyPrinter.java index 570c063cc49..d0e85f35342 100644 --- a/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogPrettyPrinter.java +++ b/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogPrettyPrinter.java @@ -298,6 +298,10 @@ public class HLogPrettyPrinter { } } + public static void main(String[] args) throws IOException { + run(args); + } + /** * Pass one or more log file names and formatting options and it will dump out * a text version of the contents on stdout. @@ -329,7 +333,7 @@ public class HLogPrettyPrinter { files = cmd.getArgList(); if (files.size() == 0 || cmd.hasOption("h")) { HelpFormatter formatter = new HelpFormatter(); - formatter.printHelp("HFile filename(s) ", options, true); + formatter.printHelp("HLog ", options, true); System.exit(-1); } // configure the pretty printer using command line options