From 47eb79311f8c82bbdf03f1c0483c271a313b0ef4 Mon Sep 17 00:00:00 2001 From: Matteo Bertozzi Date: Wed, 23 Mar 2016 10:38:13 -0700 Subject: [PATCH] HBASE-15508 Add command for exporting snapshot in hbase command script (Yufeng Jiang) --- bin/hbase | 33 +++++++++++++++---- .../hadoop/hbase/snapshot/ExportSnapshot.java | 4 +-- .../hadoop/hbase/snapshot/SnapshotInfo.java | 4 +-- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/bin/hbase b/bin/hbase index 7901033950c..fbf3998380e 100755 --- a/bin/hbase +++ b/bin/hbase @@ -71,19 +71,22 @@ if [ -d "${HBASE_HOME}/target" ]; then in_dev_env=true fi +read -d '' options_string << EOF +Options: + --config DIR Configuration direction to use. Default: ./conf + --hosts HOSTS Override the list in 'regionservers' file + --auth-as-server Authenticate to ZooKeeper using servers configuration +EOF # if no args specified, show usage if [ $# = 0 ]; then echo "Usage: hbase [] []" - echo "Options:" - echo " --config DIR Configuration direction to use. Default: ./conf" - echo " --hosts HOSTS Override the list in 'regionservers' file" - echo " --auth-as-server Authenticate to ZooKeeper using servers configuration" + echo "$options_string" echo "" echo "Commands:" echo "Some commands take arguments. Pass no args or -h for usage." echo " shell Run the HBase shell" echo " hbck Run the hbase 'fsck' tool" - echo " snapshot Create a new snapshot of a table" + echo " snapshot Tool for managing snapshots" echo " snapshotinfo Tool for dumping snapshot information" echo " wal Write-ahead-log analyzer" echo " hfile Store file analyzer" @@ -317,8 +320,26 @@ elif [ "$COMMAND" = "zkcli" ] ; then elif [ "$COMMAND" = "upgrade" ] ; then CLASS="org.apache.hadoop.hbase.migration.UpgradeTo96" elif [ "$COMMAND" = "snapshot" ] ; then - CLASS="org.apache.hadoop.hbase.snapshot.CreateSnapshot" + SUBCOMMAND=$1 + shift + if [ "$SUBCOMMAND" = "create" ] ; then + CLASS="org.apache.hadoop.hbase.snapshot.CreateSnapshot" + elif [ "$SUBCOMMAND" = "info" ] ; then + CLASS="org.apache.hadoop.hbase.snapshot.SnapshotInfo" + elif [ "$SUBCOMMAND" = "export" ] ; then + CLASS="org.apache.hadoop.hbase.snapshot.ExportSnapshot" + else + echo "Usage: hbase [] snapshot []" + echo "$options_string" + echo "" + echo "Subcommands:" + echo " create Create a new snapshot of a table" + echo " info Tool for dumping snapshot information" + echo " export Export an existing snapshot" + exit 1 + fi elif [ "$COMMAND" = "snapshotinfo" ] ; then + >&2 echo "'hbase snapshotinfo' is deprecated and will not be available in HBase 2. Please use 'hbase snapshot info' instead." CLASS="org.apache.hadoop.hbase.snapshot.SnapshotInfo" elif [ "$COMMAND" = "master" ] ; then CLASS='org.apache.hadoop.hbase.master.HMaster' diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java index 00135ca6808..35ce2d73fab 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java @@ -1048,11 +1048,11 @@ public class ExportSnapshot extends Configured implements Tool { System.err.println(" -bandwidth Limit bandwidth to this value in MB/second."); System.err.println(); System.err.println("Examples:"); - System.err.println(" hbase " + getClass().getName() + " \\"); + System.err.println(" hbase snapshot export \\"); System.err.println(" -snapshot MySnapshot -copy-to hdfs://srv2:8082/hbase \\"); System.err.println(" -chuser MyUser -chgroup MyGroup -chmod 700 -mappers 16"); System.err.println(); - System.err.println(" hbase " + getClass().getName() + " \\"); + System.err.println(" hbase snapshot export \\"); System.err.println(" -snapshot MySnapshot -copy-from hdfs://srv2:8082/hbase \\"); System.err.println(" -copy-to hdfs://srv1:50070/hbase \\"); System.exit(1); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotInfo.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotInfo.java index 46a5f5b2bee..d93535b3d87 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotInfo.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotInfo.java @@ -446,7 +446,7 @@ public final class SnapshotInfo extends Configured implements Tool { } private void printUsageAndExit() { - System.err.printf("Usage: bin/hbase %s [options]%n", getClass().getName()); + System.err.printf("Usage: bin/hbase snapshot info [options]%n"); System.err.println(" where [options] are:"); System.err.println(" -h|-help Show this help and exit."); System.err.println(" -remote-dir Root directory that contains the snapshots."); @@ -458,7 +458,7 @@ public final class SnapshotInfo extends Configured implements Tool { System.err.println(" -schema Describe the snapshotted table."); System.err.println(); System.err.println("Examples:"); - System.err.println(" hbase " + getClass() + " \\"); + System.err.println(" hbase snapshot info \\"); System.err.println(" -snapshot MySnapshot -files"); System.exit(1); }