http://git-wip-us.apache.org/repos/asf/hbase-site/blob/89e23f78/devapidocs/src-html/org/apache/hadoop/hbase/backup/impl/BackupCommands.MergeCommand.html
----------------------------------------------------------------------
diff --git 
a/devapidocs/src-html/org/apache/hadoop/hbase/backup/impl/BackupCommands.MergeCommand.html
 
b/devapidocs/src-html/org/apache/hadoop/hbase/backup/impl/BackupCommands.MergeCommand.html
index 667152a..a12ad81 100644
--- 
a/devapidocs/src-html/org/apache/hadoop/hbase/backup/impl/BackupCommands.MergeCommand.html
+++ 
b/devapidocs/src-html/org/apache/hadoop/hbase/backup/impl/BackupCommands.MergeCommand.html
@@ -66,13 +66,13 @@
 <span class="sourceLineNo">058</span>import 
org.apache.hadoop.hbase.backup.BackupRestoreConstants;<a name="line.58"></a>
 <span class="sourceLineNo">059</span>import 
org.apache.hadoop.hbase.backup.BackupRestoreConstants.BackupCommand;<a 
name="line.59"></a>
 <span class="sourceLineNo">060</span>import 
org.apache.hadoop.hbase.backup.BackupType;<a name="line.60"></a>
-<span class="sourceLineNo">061</span>import 
org.apache.hadoop.hbase.backup.util.BackupSet;<a name="line.61"></a>
-<span class="sourceLineNo">062</span>import 
org.apache.hadoop.hbase.backup.util.BackupUtils;<a name="line.62"></a>
-<span class="sourceLineNo">063</span>import 
org.apache.hadoop.hbase.client.Connection;<a name="line.63"></a>
-<span class="sourceLineNo">064</span>import 
org.apache.hadoop.hbase.client.ConnectionFactory;<a name="line.64"></a>
-<span class="sourceLineNo">065</span>import 
org.apache.hadoop.hbase.util.EnvironmentEdgeManager;<a name="line.65"></a>
-<span class="sourceLineNo">066</span>import 
org.apache.yetus.audience.InterfaceAudience;<a name="line.66"></a>
-<span class="sourceLineNo">067</span><a name="line.67"></a>
+<span class="sourceLineNo">061</span>import 
org.apache.hadoop.hbase.backup.HBackupFileSystem;<a name="line.61"></a>
+<span class="sourceLineNo">062</span>import 
org.apache.hadoop.hbase.backup.util.BackupSet;<a name="line.62"></a>
+<span class="sourceLineNo">063</span>import 
org.apache.hadoop.hbase.backup.util.BackupUtils;<a name="line.63"></a>
+<span class="sourceLineNo">064</span>import 
org.apache.hadoop.hbase.client.Connection;<a name="line.64"></a>
+<span class="sourceLineNo">065</span>import 
org.apache.hadoop.hbase.client.ConnectionFactory;<a name="line.65"></a>
+<span class="sourceLineNo">066</span>import 
org.apache.hadoop.hbase.util.EnvironmentEdgeManager;<a name="line.66"></a>
+<span class="sourceLineNo">067</span>import 
org.apache.yetus.audience.InterfaceAudience;<a name="line.67"></a>
 <span class="sourceLineNo">068</span>import 
org.apache.hbase.thirdparty.com.google.common.collect.Lists;<a 
name="line.68"></a>
 <span class="sourceLineNo">069</span><a name="line.69"></a>
 <span class="sourceLineNo">070</span>/**<a name="line.70"></a>
@@ -411,7 +411,7 @@
 <span class="sourceLineNo">403</span>    }<a name="line.403"></a>
 <span class="sourceLineNo">404</span>  }<a name="line.404"></a>
 <span class="sourceLineNo">405</span><a name="line.405"></a>
-<span class="sourceLineNo">406</span>  private static class HelpCommand 
extends Command {<a name="line.406"></a>
+<span class="sourceLineNo">406</span>  public static class HelpCommand extends 
Command {<a name="line.406"></a>
 <span class="sourceLineNo">407</span>    HelpCommand(Configuration conf, 
CommandLine cmdline) {<a name="line.407"></a>
 <span class="sourceLineNo">408</span>      super(conf);<a name="line.408"></a>
 <span class="sourceLineNo">409</span>      this.cmdline = cmdline;<a 
name="line.409"></a>
@@ -462,7 +462,7 @@
 <span class="sourceLineNo">454</span>    }<a name="line.454"></a>
 <span class="sourceLineNo">455</span>  }<a name="line.455"></a>
 <span class="sourceLineNo">456</span><a name="line.456"></a>
-<span class="sourceLineNo">457</span>  private static class DescribeCommand 
extends Command {<a name="line.457"></a>
+<span class="sourceLineNo">457</span>  public static class DescribeCommand 
extends Command {<a name="line.457"></a>
 <span class="sourceLineNo">458</span>    DescribeCommand(Configuration conf, 
CommandLine cmdline) {<a name="line.458"></a>
 <span class="sourceLineNo">459</span>      super(conf);<a name="line.459"></a>
 <span class="sourceLineNo">460</span>      this.cmdline = cmdline;<a 
name="line.460"></a>
@@ -500,7 +500,7 @@
 <span class="sourceLineNo">492</span>    }<a name="line.492"></a>
 <span class="sourceLineNo">493</span>  }<a name="line.493"></a>
 <span class="sourceLineNo">494</span><a name="line.494"></a>
-<span class="sourceLineNo">495</span>  private static class ProgressCommand 
extends Command {<a name="line.495"></a>
+<span class="sourceLineNo">495</span>  public static class ProgressCommand 
extends Command {<a name="line.495"></a>
 <span class="sourceLineNo">496</span>    ProgressCommand(Configuration conf, 
CommandLine cmdline) {<a name="line.496"></a>
 <span class="sourceLineNo">497</span>      super(conf);<a name="line.497"></a>
 <span class="sourceLineNo">498</span>      this.cmdline = cmdline;<a 
name="line.498"></a>
@@ -555,7 +555,7 @@
 <span class="sourceLineNo">547</span>    }<a name="line.547"></a>
 <span class="sourceLineNo">548</span>  }<a name="line.548"></a>
 <span class="sourceLineNo">549</span><a name="line.549"></a>
-<span class="sourceLineNo">550</span>  private static class DeleteCommand 
extends Command {<a name="line.550"></a>
+<span class="sourceLineNo">550</span>  public static class DeleteCommand 
extends Command {<a name="line.550"></a>
 <span class="sourceLineNo">551</span>    DeleteCommand(Configuration conf, 
CommandLine cmdline) {<a name="line.551"></a>
 <span class="sourceLineNo">552</span>      super(conf);<a name="line.552"></a>
 <span class="sourceLineNo">553</span>      this.cmdline = cmdline;<a 
name="line.553"></a>
@@ -594,7 +594,7 @@
 <span class="sourceLineNo">586</span>    }<a name="line.586"></a>
 <span class="sourceLineNo">587</span>  }<a name="line.587"></a>
 <span class="sourceLineNo">588</span><a name="line.588"></a>
-<span class="sourceLineNo">589</span>  private static class RepairCommand 
extends Command {<a name="line.589"></a>
+<span class="sourceLineNo">589</span>  public static class RepairCommand 
extends Command {<a name="line.589"></a>
 <span class="sourceLineNo">590</span>    RepairCommand(Configuration conf, 
CommandLine cmdline) {<a name="line.590"></a>
 <span class="sourceLineNo">591</span>      super(conf);<a name="line.591"></a>
 <span class="sourceLineNo">592</span>      this.cmdline = cmdline;<a 
name="line.592"></a>
@@ -669,369 +669,405 @@
 <span class="sourceLineNo">661</span>      System.out.println("DELETE 
operation finished OK: " + StringUtils.join(backupIds));<a name="line.661"></a>
 <span class="sourceLineNo">662</span>    }<a name="line.662"></a>
 <span class="sourceLineNo">663</span><a name="line.663"></a>
-<span class="sourceLineNo">664</span>    private void 
repairFailedBackupMergeIfAny(Connection conn, BackupSystemTable sysTable)<a 
name="line.664"></a>
+<span class="sourceLineNo">664</span>    public static void 
repairFailedBackupMergeIfAny(Connection conn, BackupSystemTable sysTable)<a 
name="line.664"></a>
 <span class="sourceLineNo">665</span>        throws IOException {<a 
name="line.665"></a>
-<span class="sourceLineNo">666</span>      String[] backupIds = 
sysTable.getListOfBackupIdsFromMergeOperation();<a name="line.666"></a>
-<span class="sourceLineNo">667</span>      if (backupIds == null || 
backupIds.length == 0) {<a name="line.667"></a>
-<span class="sourceLineNo">668</span>        System.out.println("No failed 
backup MERGE operation found");<a name="line.668"></a>
-<span class="sourceLineNo">669</span>        // Delete backup table snapshot 
if exists<a name="line.669"></a>
-<span class="sourceLineNo">670</span>        
BackupSystemTable.deleteSnapshot(conn);<a name="line.670"></a>
-<span class="sourceLineNo">671</span>        return;<a name="line.671"></a>
-<span class="sourceLineNo">672</span>      }<a name="line.672"></a>
-<span class="sourceLineNo">673</span>      System.out.println("Found failed 
MERGE operation for: " + StringUtils.join(backupIds));<a name="line.673"></a>
-<span class="sourceLineNo">674</span>      System.out.println("Running MERGE 
again ...");<a name="line.674"></a>
-<span class="sourceLineNo">675</span>      // Restore table from snapshot<a 
name="line.675"></a>
-<span class="sourceLineNo">676</span>      
BackupSystemTable.restoreFromSnapshot(conn);<a name="line.676"></a>
-<span class="sourceLineNo">677</span>      // Unlock backupo system<a 
name="line.677"></a>
-<span class="sourceLineNo">678</span>      
sysTable.finishBackupExclusiveOperation();<a name="line.678"></a>
-<span class="sourceLineNo">679</span>      // Finish previous failed session<a 
name="line.679"></a>
-<span class="sourceLineNo">680</span>      sysTable.finishMergeOperation();<a 
name="line.680"></a>
-<span class="sourceLineNo">681</span>      try (BackupAdmin admin = new 
BackupAdminImpl(conn)) {<a name="line.681"></a>
-<span class="sourceLineNo">682</span>        admin.mergeBackups(backupIds);<a 
name="line.682"></a>
-<span class="sourceLineNo">683</span>      }<a name="line.683"></a>
-<span class="sourceLineNo">684</span>      System.out.println("MERGE operation 
finished OK: " + StringUtils.join(backupIds));<a name="line.684"></a>
-<span class="sourceLineNo">685</span>    }<a name="line.685"></a>
-<span class="sourceLineNo">686</span><a name="line.686"></a>
-<span class="sourceLineNo">687</span>    @Override<a name="line.687"></a>
-<span class="sourceLineNo">688</span>    protected void printUsage() {<a 
name="line.688"></a>
-<span class="sourceLineNo">689</span>      
System.out.println(REPAIR_CMD_USAGE);<a name="line.689"></a>
-<span class="sourceLineNo">690</span>    }<a name="line.690"></a>
-<span class="sourceLineNo">691</span>  }<a name="line.691"></a>
-<span class="sourceLineNo">692</span><a name="line.692"></a>
-<span class="sourceLineNo">693</span>  private static class MergeCommand 
extends Command {<a name="line.693"></a>
-<span class="sourceLineNo">694</span>    MergeCommand(Configuration conf, 
CommandLine cmdline) {<a name="line.694"></a>
-<span class="sourceLineNo">695</span>      super(conf);<a name="line.695"></a>
-<span class="sourceLineNo">696</span>      this.cmdline = cmdline;<a 
name="line.696"></a>
-<span class="sourceLineNo">697</span>    }<a name="line.697"></a>
-<span class="sourceLineNo">698</span><a name="line.698"></a>
-<span class="sourceLineNo">699</span>    @Override<a name="line.699"></a>
-<span class="sourceLineNo">700</span>    protected boolean 
requiresNoActiveSession() {<a name="line.700"></a>
-<span class="sourceLineNo">701</span>      return true;<a name="line.701"></a>
-<span class="sourceLineNo">702</span>    }<a name="line.702"></a>
-<span class="sourceLineNo">703</span><a name="line.703"></a>
-<span class="sourceLineNo">704</span>    @Override<a name="line.704"></a>
-<span class="sourceLineNo">705</span>    protected boolean 
requiresConsistentState() {<a name="line.705"></a>
-<span class="sourceLineNo">706</span>      return true;<a name="line.706"></a>
-<span class="sourceLineNo">707</span>    }<a name="line.707"></a>
-<span class="sourceLineNo">708</span><a name="line.708"></a>
-<span class="sourceLineNo">709</span>    @Override<a name="line.709"></a>
-<span class="sourceLineNo">710</span>    public void execute() throws 
IOException {<a name="line.710"></a>
-<span class="sourceLineNo">711</span>      super.execute();<a 
name="line.711"></a>
-<span class="sourceLineNo">712</span><a name="line.712"></a>
-<span class="sourceLineNo">713</span>      String[] args = cmdline == null ? 
null : cmdline.getArgs();<a name="line.713"></a>
-<span class="sourceLineNo">714</span>      if (args == null || (args.length != 
2)) {<a name="line.714"></a>
-<span class="sourceLineNo">715</span>        System.err.println("ERROR: wrong 
number of arguments: "<a name="line.715"></a>
-<span class="sourceLineNo">716</span>            + (args == null ? null : 
args.length));<a name="line.716"></a>
-<span class="sourceLineNo">717</span>        printUsage();<a 
name="line.717"></a>
-<span class="sourceLineNo">718</span>        throw new 
IOException(INCORRECT_USAGE);<a name="line.718"></a>
-<span class="sourceLineNo">719</span>      }<a name="line.719"></a>
-<span class="sourceLineNo">720</span><a name="line.720"></a>
-<span class="sourceLineNo">721</span>      String[] backupIds = 
args[1].split(",");<a name="line.721"></a>
-<span class="sourceLineNo">722</span>      if (backupIds.length &lt; 2) {<a 
name="line.722"></a>
-<span class="sourceLineNo">723</span>        String msg = "ERROR: can not 
merge a single backup image. "+<a name="line.723"></a>
-<span class="sourceLineNo">724</span>            "Number of images must be 
greater than 1.";<a name="line.724"></a>
-<span class="sourceLineNo">725</span>        System.err.println(msg);<a 
name="line.725"></a>
-<span class="sourceLineNo">726</span>        throw new IOException(msg);<a 
name="line.726"></a>
-<span class="sourceLineNo">727</span><a name="line.727"></a>
-<span class="sourceLineNo">728</span>      }<a name="line.728"></a>
-<span class="sourceLineNo">729</span>      Configuration conf = getConf() != 
null ? getConf() : HBaseConfiguration.create();<a name="line.729"></a>
-<span class="sourceLineNo">730</span>      try (final Connection conn = 
ConnectionFactory.createConnection(conf);<a name="line.730"></a>
-<span class="sourceLineNo">731</span>          final BackupAdminImpl admin = 
new BackupAdminImpl(conn)) {<a name="line.731"></a>
-<span class="sourceLineNo">732</span>        admin.mergeBackups(backupIds);<a 
name="line.732"></a>
-<span class="sourceLineNo">733</span>      }<a name="line.733"></a>
-<span class="sourceLineNo">734</span>    }<a name="line.734"></a>
-<span class="sourceLineNo">735</span><a name="line.735"></a>
-<span class="sourceLineNo">736</span>    @Override<a name="line.736"></a>
-<span class="sourceLineNo">737</span>    protected void printUsage() {<a 
name="line.737"></a>
-<span class="sourceLineNo">738</span>      
System.out.println(MERGE_CMD_USAGE);<a name="line.738"></a>
-<span class="sourceLineNo">739</span>    }<a name="line.739"></a>
-<span class="sourceLineNo">740</span>  }<a name="line.740"></a>
-<span class="sourceLineNo">741</span><a name="line.741"></a>
-<span class="sourceLineNo">742</span>  private static class HistoryCommand 
extends Command {<a name="line.742"></a>
-<span class="sourceLineNo">743</span>    private final static int 
DEFAULT_HISTORY_LENGTH = 10;<a name="line.743"></a>
+<span class="sourceLineNo">666</span><a name="line.666"></a>
+<span class="sourceLineNo">667</span>      String[] backupIds = 
sysTable.getListOfBackupIdsFromMergeOperation();<a name="line.667"></a>
+<span class="sourceLineNo">668</span>      if (backupIds == null || 
backupIds.length == 0) {<a name="line.668"></a>
+<span class="sourceLineNo">669</span>        System.out.println("No failed 
backup MERGE operation found");<a name="line.669"></a>
+<span class="sourceLineNo">670</span>        // Delete backup table snapshot 
if exists<a name="line.670"></a>
+<span class="sourceLineNo">671</span>        
BackupSystemTable.deleteSnapshot(conn);<a name="line.671"></a>
+<span class="sourceLineNo">672</span>        return;<a name="line.672"></a>
+<span class="sourceLineNo">673</span>      }<a name="line.673"></a>
+<span class="sourceLineNo">674</span>      System.out.println("Found failed 
MERGE operation for: " + StringUtils.join(backupIds));<a name="line.674"></a>
+<span class="sourceLineNo">675</span>      // Check if backup .tmp exists<a 
name="line.675"></a>
+<span class="sourceLineNo">676</span>      BackupInfo bInfo = 
sysTable.readBackupInfo(backupIds[0]);<a name="line.676"></a>
+<span class="sourceLineNo">677</span>      String backupRoot = 
bInfo.getBackupRootDir();<a name="line.677"></a>
+<span class="sourceLineNo">678</span>      FileSystem fs = FileSystem.get(new 
Path(backupRoot).toUri(), new Configuration());<a name="line.678"></a>
+<span class="sourceLineNo">679</span>      String backupId = 
BackupUtils.findMostRecentBackupId(backupIds);<a name="line.679"></a>
+<span class="sourceLineNo">680</span>      Path tmpPath = 
HBackupFileSystem.getBackupTmpDirPathForBackupId(backupRoot, backupId);<a 
name="line.680"></a>
+<span class="sourceLineNo">681</span>      if (fs.exists(tmpPath)) {<a 
name="line.681"></a>
+<span class="sourceLineNo">682</span>        // Move data back<a 
name="line.682"></a>
+<span class="sourceLineNo">683</span>        Path destPath = 
HBackupFileSystem.getBackupPath(backupRoot, backupId);<a name="line.683"></a>
+<span class="sourceLineNo">684</span>        if (!fs.delete(destPath, true)) 
{<a name="line.684"></a>
+<span class="sourceLineNo">685</span>          System.out.println("Failed to 
delete " + destPath);<a name="line.685"></a>
+<span class="sourceLineNo">686</span>        }<a name="line.686"></a>
+<span class="sourceLineNo">687</span>        boolean res = fs.rename(tmpPath, 
destPath);<a name="line.687"></a>
+<span class="sourceLineNo">688</span>        if (!res) {<a name="line.688"></a>
+<span class="sourceLineNo">689</span>          throw new IOException("MERGE 
repair: failed  to rename from "+ tmpPath+" to "+ destPath);<a 
name="line.689"></a>
+<span class="sourceLineNo">690</span>        }<a name="line.690"></a>
+<span class="sourceLineNo">691</span>        System.out.println("MERGE repair: 
renamed from "+ tmpPath+" to "+ destPath+" res="+ res);<a name="line.691"></a>
+<span class="sourceLineNo">692</span>      } else {<a name="line.692"></a>
+<span class="sourceLineNo">693</span>        checkRemoveBackupImages(fs, 
backupRoot, backupIds);<a name="line.693"></a>
+<span class="sourceLineNo">694</span>      }<a name="line.694"></a>
+<span class="sourceLineNo">695</span>      // Restore table from snapshot<a 
name="line.695"></a>
+<span class="sourceLineNo">696</span>      
BackupSystemTable.restoreFromSnapshot(conn);<a name="line.696"></a>
+<span class="sourceLineNo">697</span>      // Unlock backup system<a 
name="line.697"></a>
+<span class="sourceLineNo">698</span>      
sysTable.finishBackupExclusiveOperation();<a name="line.698"></a>
+<span class="sourceLineNo">699</span>      // Finish previous failed session<a 
name="line.699"></a>
+<span class="sourceLineNo">700</span>      sysTable.finishMergeOperation();<a 
name="line.700"></a>
+<span class="sourceLineNo">701</span><a name="line.701"></a>
+<span class="sourceLineNo">702</span>      System.out.println("MERGE repair 
operation finished OK: " + StringUtils.join(backupIds));<a name="line.702"></a>
+<span class="sourceLineNo">703</span>    }<a name="line.703"></a>
+<span class="sourceLineNo">704</span><a name="line.704"></a>
+<span class="sourceLineNo">705</span>    private static void 
checkRemoveBackupImages(FileSystem fs, String backupRoot,<a name="line.705"></a>
+<span class="sourceLineNo">706</span>      String[] backupIds) throws 
IOException {<a name="line.706"></a>
+<span class="sourceLineNo">707</span>      String mergedBackupId = 
BackupUtils.findMostRecentBackupId(backupIds);<a name="line.707"></a>
+<span class="sourceLineNo">708</span>      for (String backupId: backupIds) 
{<a name="line.708"></a>
+<span class="sourceLineNo">709</span>        if 
(backupId.equals(mergedBackupId)) {<a name="line.709"></a>
+<span class="sourceLineNo">710</span>          continue;<a name="line.710"></a>
+<span class="sourceLineNo">711</span>        }<a name="line.711"></a>
+<span class="sourceLineNo">712</span>        Path path = 
HBackupFileSystem.getBackupPath(backupRoot, backupId);<a name="line.712"></a>
+<span class="sourceLineNo">713</span>        if (fs.exists(path)) {<a 
name="line.713"></a>
+<span class="sourceLineNo">714</span>          if (!fs.delete(path, true)) {<a 
name="line.714"></a>
+<span class="sourceLineNo">715</span>            System.out.println("MERGE 
repair removing: "+ path +" - FAILED");<a name="line.715"></a>
+<span class="sourceLineNo">716</span>          } else {<a name="line.716"></a>
+<span class="sourceLineNo">717</span>            System.out.println("MERGE 
repair removing: "+ path +" - OK");<a name="line.717"></a>
+<span class="sourceLineNo">718</span>          }<a name="line.718"></a>
+<span class="sourceLineNo">719</span>        }<a name="line.719"></a>
+<span class="sourceLineNo">720</span>      }<a name="line.720"></a>
+<span class="sourceLineNo">721</span>    }<a name="line.721"></a>
+<span class="sourceLineNo">722</span><a name="line.722"></a>
+<span class="sourceLineNo">723</span>    @Override<a name="line.723"></a>
+<span class="sourceLineNo">724</span>    protected void printUsage() {<a 
name="line.724"></a>
+<span class="sourceLineNo">725</span>      
System.out.println(REPAIR_CMD_USAGE);<a name="line.725"></a>
+<span class="sourceLineNo">726</span>    }<a name="line.726"></a>
+<span class="sourceLineNo">727</span>  }<a name="line.727"></a>
+<span class="sourceLineNo">728</span><a name="line.728"></a>
+<span class="sourceLineNo">729</span>  public static class MergeCommand 
extends Command {<a name="line.729"></a>
+<span class="sourceLineNo">730</span>    MergeCommand(Configuration conf, 
CommandLine cmdline) {<a name="line.730"></a>
+<span class="sourceLineNo">731</span>      super(conf);<a name="line.731"></a>
+<span class="sourceLineNo">732</span>      this.cmdline = cmdline;<a 
name="line.732"></a>
+<span class="sourceLineNo">733</span>    }<a name="line.733"></a>
+<span class="sourceLineNo">734</span><a name="line.734"></a>
+<span class="sourceLineNo">735</span>    @Override<a name="line.735"></a>
+<span class="sourceLineNo">736</span>    protected boolean 
requiresNoActiveSession() {<a name="line.736"></a>
+<span class="sourceLineNo">737</span>      return true;<a name="line.737"></a>
+<span class="sourceLineNo">738</span>    }<a name="line.738"></a>
+<span class="sourceLineNo">739</span><a name="line.739"></a>
+<span class="sourceLineNo">740</span>    @Override<a name="line.740"></a>
+<span class="sourceLineNo">741</span>    protected boolean 
requiresConsistentState() {<a name="line.741"></a>
+<span class="sourceLineNo">742</span>      return true;<a name="line.742"></a>
+<span class="sourceLineNo">743</span>    }<a name="line.743"></a>
 <span class="sourceLineNo">744</span><a name="line.744"></a>
-<span class="sourceLineNo">745</span>    HistoryCommand(Configuration conf, 
CommandLine cmdline) {<a name="line.745"></a>
-<span class="sourceLineNo">746</span>      super(conf);<a name="line.746"></a>
-<span class="sourceLineNo">747</span>      this.cmdline = cmdline;<a 
name="line.747"></a>
-<span class="sourceLineNo">748</span>    }<a name="line.748"></a>
-<span class="sourceLineNo">749</span><a name="line.749"></a>
-<span class="sourceLineNo">750</span>    @Override<a name="line.750"></a>
-<span class="sourceLineNo">751</span>    public void execute() throws 
IOException {<a name="line.751"></a>
-<span class="sourceLineNo">752</span>      int n = parseHistoryLength();<a 
name="line.752"></a>
-<span class="sourceLineNo">753</span>      final TableName tableName = 
getTableName();<a name="line.753"></a>
-<span class="sourceLineNo">754</span>      final String setName = 
getTableSetName();<a name="line.754"></a>
-<span class="sourceLineNo">755</span>      BackupInfo.Filter tableNameFilter = 
new BackupInfo.Filter() {<a name="line.755"></a>
-<span class="sourceLineNo">756</span>        @Override<a name="line.756"></a>
-<span class="sourceLineNo">757</span>        public boolean apply(BackupInfo 
info) {<a name="line.757"></a>
-<span class="sourceLineNo">758</span>          if (tableName == null) {<a 
name="line.758"></a>
-<span class="sourceLineNo">759</span>            return true;<a 
name="line.759"></a>
-<span class="sourceLineNo">760</span>          }<a name="line.760"></a>
-<span class="sourceLineNo">761</span><a name="line.761"></a>
-<span class="sourceLineNo">762</span>          List&lt;TableName&gt; names = 
info.getTableNames();<a name="line.762"></a>
-<span class="sourceLineNo">763</span>          return 
names.contains(tableName);<a name="line.763"></a>
-<span class="sourceLineNo">764</span>        }<a name="line.764"></a>
-<span class="sourceLineNo">765</span>      };<a name="line.765"></a>
-<span class="sourceLineNo">766</span>      BackupInfo.Filter tableSetFilter = 
new BackupInfo.Filter() {<a name="line.766"></a>
-<span class="sourceLineNo">767</span>        @Override<a name="line.767"></a>
-<span class="sourceLineNo">768</span>        public boolean apply(BackupInfo 
info) {<a name="line.768"></a>
-<span class="sourceLineNo">769</span>          if (setName == null) {<a 
name="line.769"></a>
-<span class="sourceLineNo">770</span>            return true;<a 
name="line.770"></a>
-<span class="sourceLineNo">771</span>          }<a name="line.771"></a>
-<span class="sourceLineNo">772</span><a name="line.772"></a>
-<span class="sourceLineNo">773</span>          String backupId = 
info.getBackupId();<a name="line.773"></a>
-<span class="sourceLineNo">774</span>          return 
backupId.startsWith(setName);<a name="line.774"></a>
-<span class="sourceLineNo">775</span>        }<a name="line.775"></a>
-<span class="sourceLineNo">776</span>      };<a name="line.776"></a>
-<span class="sourceLineNo">777</span>      Path backupRootPath = 
getBackupRootPath();<a name="line.777"></a>
-<span class="sourceLineNo">778</span>      List&lt;BackupInfo&gt; history;<a 
name="line.778"></a>
-<span class="sourceLineNo">779</span>      if (backupRootPath == null) {<a 
name="line.779"></a>
-<span class="sourceLineNo">780</span>        // Load from backup system 
table<a name="line.780"></a>
-<span class="sourceLineNo">781</span>        super.execute();<a 
name="line.781"></a>
-<span class="sourceLineNo">782</span>        try (final BackupSystemTable 
sysTable = new BackupSystemTable(conn)) {<a name="line.782"></a>
-<span class="sourceLineNo">783</span>          history = 
sysTable.getBackupHistory(n, tableNameFilter, tableSetFilter);<a 
name="line.783"></a>
-<span class="sourceLineNo">784</span>        }<a name="line.784"></a>
-<span class="sourceLineNo">785</span>      } else {<a name="line.785"></a>
-<span class="sourceLineNo">786</span>        // load from backup FS<a 
name="line.786"></a>
-<span class="sourceLineNo">787</span>        history =<a name="line.787"></a>
-<span class="sourceLineNo">788</span>            
BackupUtils.getHistory(getConf(), n, backupRootPath, tableNameFilter, 
tableSetFilter);<a name="line.788"></a>
-<span class="sourceLineNo">789</span>      }<a name="line.789"></a>
-<span class="sourceLineNo">790</span>      for (BackupInfo info : history) {<a 
name="line.790"></a>
-<span class="sourceLineNo">791</span>        
System.out.println(info.getShortDescription());<a name="line.791"></a>
-<span class="sourceLineNo">792</span>      }<a name="line.792"></a>
-<span class="sourceLineNo">793</span>    }<a name="line.793"></a>
-<span class="sourceLineNo">794</span><a name="line.794"></a>
-<span class="sourceLineNo">795</span>    private Path getBackupRootPath() 
throws IOException {<a name="line.795"></a>
-<span class="sourceLineNo">796</span>      String value = null;<a 
name="line.796"></a>
-<span class="sourceLineNo">797</span>      try {<a name="line.797"></a>
-<span class="sourceLineNo">798</span>        value = 
cmdline.getOptionValue(OPTION_PATH);<a name="line.798"></a>
-<span class="sourceLineNo">799</span><a name="line.799"></a>
-<span class="sourceLineNo">800</span>        if (value == null) {<a 
name="line.800"></a>
-<span class="sourceLineNo">801</span>          return null;<a 
name="line.801"></a>
-<span class="sourceLineNo">802</span>        }<a name="line.802"></a>
-<span class="sourceLineNo">803</span><a name="line.803"></a>
-<span class="sourceLineNo">804</span>        return new Path(value);<a 
name="line.804"></a>
-<span class="sourceLineNo">805</span>      } catch (IllegalArgumentException 
e) {<a name="line.805"></a>
-<span class="sourceLineNo">806</span>        System.out.println("ERROR: 
Illegal argument for backup root path: " + value);<a name="line.806"></a>
-<span class="sourceLineNo">807</span>        printUsage();<a 
name="line.807"></a>
-<span class="sourceLineNo">808</span>        throw new 
IOException(INCORRECT_USAGE);<a name="line.808"></a>
-<span class="sourceLineNo">809</span>      }<a name="line.809"></a>
-<span class="sourceLineNo">810</span>    }<a name="line.810"></a>
-<span class="sourceLineNo">811</span><a name="line.811"></a>
-<span class="sourceLineNo">812</span>    private TableName getTableName() 
throws IOException {<a name="line.812"></a>
-<span class="sourceLineNo">813</span>      String value = 
cmdline.getOptionValue(OPTION_TABLE);<a name="line.813"></a>
-<span class="sourceLineNo">814</span><a name="line.814"></a>
-<span class="sourceLineNo">815</span>      if (value == null) {<a 
name="line.815"></a>
-<span class="sourceLineNo">816</span>        return null;<a 
name="line.816"></a>
-<span class="sourceLineNo">817</span>      }<a name="line.817"></a>
-<span class="sourceLineNo">818</span><a name="line.818"></a>
-<span class="sourceLineNo">819</span>      try {<a name="line.819"></a>
-<span class="sourceLineNo">820</span>        return 
TableName.valueOf(value);<a name="line.820"></a>
-<span class="sourceLineNo">821</span>      } catch (IllegalArgumentException 
e) {<a name="line.821"></a>
-<span class="sourceLineNo">822</span>        System.out.println("Illegal 
argument for table name: " + value);<a name="line.822"></a>
-<span class="sourceLineNo">823</span>        printUsage();<a 
name="line.823"></a>
-<span class="sourceLineNo">824</span>        throw new 
IOException(INCORRECT_USAGE);<a name="line.824"></a>
+<span class="sourceLineNo">745</span>    @Override<a name="line.745"></a>
+<span class="sourceLineNo">746</span>    public void execute() throws 
IOException {<a name="line.746"></a>
+<span class="sourceLineNo">747</span>      super.execute();<a 
name="line.747"></a>
+<span class="sourceLineNo">748</span><a name="line.748"></a>
+<span class="sourceLineNo">749</span>      String[] args = cmdline == null ? 
null : cmdline.getArgs();<a name="line.749"></a>
+<span class="sourceLineNo">750</span>      if (args == null || (args.length != 
2)) {<a name="line.750"></a>
+<span class="sourceLineNo">751</span>        System.err.println("ERROR: wrong 
number of arguments: "<a name="line.751"></a>
+<span class="sourceLineNo">752</span>            + (args == null ? null : 
args.length));<a name="line.752"></a>
+<span class="sourceLineNo">753</span>        printUsage();<a 
name="line.753"></a>
+<span class="sourceLineNo">754</span>        throw new 
IOException(INCORRECT_USAGE);<a name="line.754"></a>
+<span class="sourceLineNo">755</span>      }<a name="line.755"></a>
+<span class="sourceLineNo">756</span><a name="line.756"></a>
+<span class="sourceLineNo">757</span>      String[] backupIds = 
args[1].split(",");<a name="line.757"></a>
+<span class="sourceLineNo">758</span>      if (backupIds.length &lt; 2) {<a 
name="line.758"></a>
+<span class="sourceLineNo">759</span>        String msg = "ERROR: can not 
merge a single backup image. "+<a name="line.759"></a>
+<span class="sourceLineNo">760</span>            "Number of images must be 
greater than 1.";<a name="line.760"></a>
+<span class="sourceLineNo">761</span>        System.err.println(msg);<a 
name="line.761"></a>
+<span class="sourceLineNo">762</span>        throw new IOException(msg);<a 
name="line.762"></a>
+<span class="sourceLineNo">763</span><a name="line.763"></a>
+<span class="sourceLineNo">764</span>      }<a name="line.764"></a>
+<span class="sourceLineNo">765</span>      Configuration conf = getConf() != 
null ? getConf() : HBaseConfiguration.create();<a name="line.765"></a>
+<span class="sourceLineNo">766</span>      try (final Connection conn = 
ConnectionFactory.createConnection(conf);<a name="line.766"></a>
+<span class="sourceLineNo">767</span>          final BackupAdminImpl admin = 
new BackupAdminImpl(conn)) {<a name="line.767"></a>
+<span class="sourceLineNo">768</span>        admin.mergeBackups(backupIds);<a 
name="line.768"></a>
+<span class="sourceLineNo">769</span>      }<a name="line.769"></a>
+<span class="sourceLineNo">770</span>    }<a name="line.770"></a>
+<span class="sourceLineNo">771</span><a name="line.771"></a>
+<span class="sourceLineNo">772</span>    @Override<a name="line.772"></a>
+<span class="sourceLineNo">773</span>    protected void printUsage() {<a 
name="line.773"></a>
+<span class="sourceLineNo">774</span>      
System.out.println(MERGE_CMD_USAGE);<a name="line.774"></a>
+<span class="sourceLineNo">775</span>    }<a name="line.775"></a>
+<span class="sourceLineNo">776</span>  }<a name="line.776"></a>
+<span class="sourceLineNo">777</span><a name="line.777"></a>
+<span class="sourceLineNo">778</span>  public static class HistoryCommand 
extends Command {<a name="line.778"></a>
+<span class="sourceLineNo">779</span>    private final static int 
DEFAULT_HISTORY_LENGTH = 10;<a name="line.779"></a>
+<span class="sourceLineNo">780</span><a name="line.780"></a>
+<span class="sourceLineNo">781</span>    HistoryCommand(Configuration conf, 
CommandLine cmdline) {<a name="line.781"></a>
+<span class="sourceLineNo">782</span>      super(conf);<a name="line.782"></a>
+<span class="sourceLineNo">783</span>      this.cmdline = cmdline;<a 
name="line.783"></a>
+<span class="sourceLineNo">784</span>    }<a name="line.784"></a>
+<span class="sourceLineNo">785</span><a name="line.785"></a>
+<span class="sourceLineNo">786</span>    @Override<a name="line.786"></a>
+<span class="sourceLineNo">787</span>    public void execute() throws 
IOException {<a name="line.787"></a>
+<span class="sourceLineNo">788</span>      int n = parseHistoryLength();<a 
name="line.788"></a>
+<span class="sourceLineNo">789</span>      final TableName tableName = 
getTableName();<a name="line.789"></a>
+<span class="sourceLineNo">790</span>      final String setName = 
getTableSetName();<a name="line.790"></a>
+<span class="sourceLineNo">791</span>      BackupInfo.Filter tableNameFilter = 
new BackupInfo.Filter() {<a name="line.791"></a>
+<span class="sourceLineNo">792</span>        @Override<a name="line.792"></a>
+<span class="sourceLineNo">793</span>        public boolean apply(BackupInfo 
info) {<a name="line.793"></a>
+<span class="sourceLineNo">794</span>          if (tableName == null) {<a 
name="line.794"></a>
+<span class="sourceLineNo">795</span>            return true;<a 
name="line.795"></a>
+<span class="sourceLineNo">796</span>          }<a name="line.796"></a>
+<span class="sourceLineNo">797</span><a name="line.797"></a>
+<span class="sourceLineNo">798</span>          List&lt;TableName&gt; names = 
info.getTableNames();<a name="line.798"></a>
+<span class="sourceLineNo">799</span>          return 
names.contains(tableName);<a name="line.799"></a>
+<span class="sourceLineNo">800</span>        }<a name="line.800"></a>
+<span class="sourceLineNo">801</span>      };<a name="line.801"></a>
+<span class="sourceLineNo">802</span>      BackupInfo.Filter tableSetFilter = 
new BackupInfo.Filter() {<a name="line.802"></a>
+<span class="sourceLineNo">803</span>        @Override<a name="line.803"></a>
+<span class="sourceLineNo">804</span>        public boolean apply(BackupInfo 
info) {<a name="line.804"></a>
+<span class="sourceLineNo">805</span>          if (setName == null) {<a 
name="line.805"></a>
+<span class="sourceLineNo">806</span>            return true;<a 
name="line.806"></a>
+<span class="sourceLineNo">807</span>          }<a name="line.807"></a>
+<span class="sourceLineNo">808</span><a name="line.808"></a>
+<span class="sourceLineNo">809</span>          String backupId = 
info.getBackupId();<a name="line.809"></a>
+<span class="sourceLineNo">810</span>          return 
backupId.startsWith(setName);<a name="line.810"></a>
+<span class="sourceLineNo">811</span>        }<a name="line.811"></a>
+<span class="sourceLineNo">812</span>      };<a name="line.812"></a>
+<span class="sourceLineNo">813</span>      Path backupRootPath = 
getBackupRootPath();<a name="line.813"></a>
+<span class="sourceLineNo">814</span>      List&lt;BackupInfo&gt; history;<a 
name="line.814"></a>
+<span class="sourceLineNo">815</span>      if (backupRootPath == null) {<a 
name="line.815"></a>
+<span class="sourceLineNo">816</span>        // Load from backup system 
table<a name="line.816"></a>
+<span class="sourceLineNo">817</span>        super.execute();<a 
name="line.817"></a>
+<span class="sourceLineNo">818</span>        try (final BackupSystemTable 
sysTable = new BackupSystemTable(conn)) {<a name="line.818"></a>
+<span class="sourceLineNo">819</span>          history = 
sysTable.getBackupHistory(n, tableNameFilter, tableSetFilter);<a 
name="line.819"></a>
+<span class="sourceLineNo">820</span>        }<a name="line.820"></a>
+<span class="sourceLineNo">821</span>      } else {<a name="line.821"></a>
+<span class="sourceLineNo">822</span>        // load from backup FS<a 
name="line.822"></a>
+<span class="sourceLineNo">823</span>        history =<a name="line.823"></a>
+<span class="sourceLineNo">824</span>            
BackupUtils.getHistory(getConf(), n, backupRootPath, tableNameFilter, 
tableSetFilter);<a name="line.824"></a>
 <span class="sourceLineNo">825</span>      }<a name="line.825"></a>
-<span class="sourceLineNo">826</span>    }<a name="line.826"></a>
-<span class="sourceLineNo">827</span><a name="line.827"></a>
-<span class="sourceLineNo">828</span>    private String getTableSetName() {<a 
name="line.828"></a>
-<span class="sourceLineNo">829</span>      return 
cmdline.getOptionValue(OPTION_SET);<a name="line.829"></a>
-<span class="sourceLineNo">830</span>    }<a name="line.830"></a>
-<span class="sourceLineNo">831</span><a name="line.831"></a>
-<span class="sourceLineNo">832</span>    private int parseHistoryLength() 
throws IOException {<a name="line.832"></a>
-<span class="sourceLineNo">833</span>      String value = 
cmdline.getOptionValue(OPTION_RECORD_NUMBER);<a name="line.833"></a>
-<span class="sourceLineNo">834</span>      try {<a name="line.834"></a>
-<span class="sourceLineNo">835</span>        if (value == null) {<a 
name="line.835"></a>
-<span class="sourceLineNo">836</span>          return 
DEFAULT_HISTORY_LENGTH;<a name="line.836"></a>
-<span class="sourceLineNo">837</span>        }<a name="line.837"></a>
-<span class="sourceLineNo">838</span><a name="line.838"></a>
-<span class="sourceLineNo">839</span>        return Integer.parseInt(value);<a 
name="line.839"></a>
-<span class="sourceLineNo">840</span>      } catch (NumberFormatException e) 
{<a name="line.840"></a>
-<span class="sourceLineNo">841</span>        System.out.println("Illegal 
argument for history length: " + value);<a name="line.841"></a>
-<span class="sourceLineNo">842</span>        printUsage();<a 
name="line.842"></a>
-<span class="sourceLineNo">843</span>        throw new 
IOException(INCORRECT_USAGE);<a name="line.843"></a>
-<span class="sourceLineNo">844</span>      }<a name="line.844"></a>
-<span class="sourceLineNo">845</span>    }<a name="line.845"></a>
-<span class="sourceLineNo">846</span><a name="line.846"></a>
-<span class="sourceLineNo">847</span>    @Override<a name="line.847"></a>
-<span class="sourceLineNo">848</span>    protected void printUsage() {<a 
name="line.848"></a>
-<span class="sourceLineNo">849</span>      
System.out.println(HISTORY_CMD_USAGE);<a name="line.849"></a>
-<span class="sourceLineNo">850</span>      Options options = new Options();<a 
name="line.850"></a>
-<span class="sourceLineNo">851</span>      
options.addOption(OPTION_RECORD_NUMBER, true, OPTION_RECORD_NUMBER_DESC);<a 
name="line.851"></a>
-<span class="sourceLineNo">852</span>      options.addOption(OPTION_PATH, 
true, OPTION_PATH_DESC);<a name="line.852"></a>
-<span class="sourceLineNo">853</span>      options.addOption(OPTION_TABLE, 
true, OPTION_TABLE_DESC);<a name="line.853"></a>
-<span class="sourceLineNo">854</span>      options.addOption(OPTION_SET, true, 
OPTION_SET_DESC);<a name="line.854"></a>
-<span class="sourceLineNo">855</span><a name="line.855"></a>
-<span class="sourceLineNo">856</span>      HelpFormatter helpFormatter = new 
HelpFormatter();<a name="line.856"></a>
-<span class="sourceLineNo">857</span>      helpFormatter.setLeftPadding(2);<a 
name="line.857"></a>
-<span class="sourceLineNo">858</span>      helpFormatter.setDescPadding(8);<a 
name="line.858"></a>
-<span class="sourceLineNo">859</span>      helpFormatter.setWidth(100);<a 
name="line.859"></a>
-<span class="sourceLineNo">860</span>      
helpFormatter.setSyntaxPrefix("Options:");<a name="line.860"></a>
-<span class="sourceLineNo">861</span>      helpFormatter.printHelp(" ", null, 
options, USAGE_FOOTER);<a name="line.861"></a>
+<span class="sourceLineNo">826</span>      for (BackupInfo info : history) {<a 
name="line.826"></a>
+<span class="sourceLineNo">827</span>        
System.out.println(info.getShortDescription());<a name="line.827"></a>
+<span class="sourceLineNo">828</span>      }<a name="line.828"></a>
+<span class="sourceLineNo">829</span>    }<a name="line.829"></a>
+<span class="sourceLineNo">830</span><a name="line.830"></a>
+<span class="sourceLineNo">831</span>    private Path getBackupRootPath() 
throws IOException {<a name="line.831"></a>
+<span class="sourceLineNo">832</span>      String value = null;<a 
name="line.832"></a>
+<span class="sourceLineNo">833</span>      try {<a name="line.833"></a>
+<span class="sourceLineNo">834</span>        value = 
cmdline.getOptionValue(OPTION_PATH);<a name="line.834"></a>
+<span class="sourceLineNo">835</span><a name="line.835"></a>
+<span class="sourceLineNo">836</span>        if (value == null) {<a 
name="line.836"></a>
+<span class="sourceLineNo">837</span>          return null;<a 
name="line.837"></a>
+<span class="sourceLineNo">838</span>        }<a name="line.838"></a>
+<span class="sourceLineNo">839</span><a name="line.839"></a>
+<span class="sourceLineNo">840</span>        return new Path(value);<a 
name="line.840"></a>
+<span class="sourceLineNo">841</span>      } catch (IllegalArgumentException 
e) {<a name="line.841"></a>
+<span class="sourceLineNo">842</span>        System.out.println("ERROR: 
Illegal argument for backup root path: " + value);<a name="line.842"></a>
+<span class="sourceLineNo">843</span>        printUsage();<a 
name="line.843"></a>
+<span class="sourceLineNo">844</span>        throw new 
IOException(INCORRECT_USAGE);<a name="line.844"></a>
+<span class="sourceLineNo">845</span>      }<a name="line.845"></a>
+<span class="sourceLineNo">846</span>    }<a name="line.846"></a>
+<span class="sourceLineNo">847</span><a name="line.847"></a>
+<span class="sourceLineNo">848</span>    private TableName getTableName() 
throws IOException {<a name="line.848"></a>
+<span class="sourceLineNo">849</span>      String value = 
cmdline.getOptionValue(OPTION_TABLE);<a name="line.849"></a>
+<span class="sourceLineNo">850</span><a name="line.850"></a>
+<span class="sourceLineNo">851</span>      if (value == null) {<a 
name="line.851"></a>
+<span class="sourceLineNo">852</span>        return null;<a 
name="line.852"></a>
+<span class="sourceLineNo">853</span>      }<a name="line.853"></a>
+<span class="sourceLineNo">854</span><a name="line.854"></a>
+<span class="sourceLineNo">855</span>      try {<a name="line.855"></a>
+<span class="sourceLineNo">856</span>        return 
TableName.valueOf(value);<a name="line.856"></a>
+<span class="sourceLineNo">857</span>      } catch (IllegalArgumentException 
e) {<a name="line.857"></a>
+<span class="sourceLineNo">858</span>        System.out.println("Illegal 
argument for table name: " + value);<a name="line.858"></a>
+<span class="sourceLineNo">859</span>        printUsage();<a 
name="line.859"></a>
+<span class="sourceLineNo">860</span>        throw new 
IOException(INCORRECT_USAGE);<a name="line.860"></a>
+<span class="sourceLineNo">861</span>      }<a name="line.861"></a>
 <span class="sourceLineNo">862</span>    }<a name="line.862"></a>
-<span class="sourceLineNo">863</span>  }<a name="line.863"></a>
-<span class="sourceLineNo">864</span><a name="line.864"></a>
-<span class="sourceLineNo">865</span>  private static class BackupSetCommand 
extends Command {<a name="line.865"></a>
-<span class="sourceLineNo">866</span>    private final static String 
SET_ADD_CMD = "add";<a name="line.866"></a>
-<span class="sourceLineNo">867</span>    private final static String 
SET_REMOVE_CMD = "remove";<a name="line.867"></a>
-<span class="sourceLineNo">868</span>    private final static String 
SET_DELETE_CMD = "delete";<a name="line.868"></a>
-<span class="sourceLineNo">869</span>    private final static String 
SET_DESCRIBE_CMD = "describe";<a name="line.869"></a>
-<span class="sourceLineNo">870</span>    private final static String 
SET_LIST_CMD = "list";<a name="line.870"></a>
-<span class="sourceLineNo">871</span><a name="line.871"></a>
-<span class="sourceLineNo">872</span>    BackupSetCommand(Configuration conf, 
CommandLine cmdline) {<a name="line.872"></a>
-<span class="sourceLineNo">873</span>      super(conf);<a name="line.873"></a>
-<span class="sourceLineNo">874</span>      this.cmdline = cmdline;<a 
name="line.874"></a>
-<span class="sourceLineNo">875</span>    }<a name="line.875"></a>
-<span class="sourceLineNo">876</span><a name="line.876"></a>
-<span class="sourceLineNo">877</span>    @Override<a name="line.877"></a>
-<span class="sourceLineNo">878</span>    public void execute() throws 
IOException {<a name="line.878"></a>
-<span class="sourceLineNo">879</span>      // Command-line must have at least 
one element<a name="line.879"></a>
-<span class="sourceLineNo">880</span>      if (cmdline == null || 
cmdline.getArgs() == null || cmdline.getArgs().length &lt; 2) {<a 
name="line.880"></a>
-<span class="sourceLineNo">881</span>        printUsage();<a 
name="line.881"></a>
-<span class="sourceLineNo">882</span>        throw new 
IOException(INCORRECT_USAGE);<a name="line.882"></a>
-<span class="sourceLineNo">883</span>      }<a name="line.883"></a>
-<span class="sourceLineNo">884</span><a name="line.884"></a>
-<span class="sourceLineNo">885</span>      String[] args = 
cmdline.getArgs();<a name="line.885"></a>
-<span class="sourceLineNo">886</span>      String cmdStr = args[1];<a 
name="line.886"></a>
-<span class="sourceLineNo">887</span>      BackupCommand cmd = 
getCommand(cmdStr);<a name="line.887"></a>
-<span class="sourceLineNo">888</span><a name="line.888"></a>
-<span class="sourceLineNo">889</span>      switch (cmd) {<a 
name="line.889"></a>
-<span class="sourceLineNo">890</span>        case SET_ADD:<a 
name="line.890"></a>
-<span class="sourceLineNo">891</span>          processSetAdd(args);<a 
name="line.891"></a>
-<span class="sourceLineNo">892</span>          break;<a name="line.892"></a>
-<span class="sourceLineNo">893</span>        case SET_REMOVE:<a 
name="line.893"></a>
-<span class="sourceLineNo">894</span>          processSetRemove(args);<a 
name="line.894"></a>
-<span class="sourceLineNo">895</span>          break;<a name="line.895"></a>
-<span class="sourceLineNo">896</span>        case SET_DELETE:<a 
name="line.896"></a>
-<span class="sourceLineNo">897</span>          processSetDelete(args);<a 
name="line.897"></a>
-<span class="sourceLineNo">898</span>          break;<a name="line.898"></a>
-<span class="sourceLineNo">899</span>        case SET_DESCRIBE:<a 
name="line.899"></a>
-<span class="sourceLineNo">900</span>          processSetDescribe(args);<a 
name="line.900"></a>
-<span class="sourceLineNo">901</span>          break;<a name="line.901"></a>
-<span class="sourceLineNo">902</span>        case SET_LIST:<a 
name="line.902"></a>
-<span class="sourceLineNo">903</span>          processSetList(args);<a 
name="line.903"></a>
-<span class="sourceLineNo">904</span>          break;<a name="line.904"></a>
-<span class="sourceLineNo">905</span>        default:<a name="line.905"></a>
-<span class="sourceLineNo">906</span>          break;<a name="line.906"></a>
-<span class="sourceLineNo">907</span>      }<a name="line.907"></a>
-<span class="sourceLineNo">908</span>    }<a name="line.908"></a>
-<span class="sourceLineNo">909</span><a name="line.909"></a>
-<span class="sourceLineNo">910</span>    private void processSetList(String[] 
args) throws IOException {<a name="line.910"></a>
-<span class="sourceLineNo">911</span>      super.execute();<a 
name="line.911"></a>
+<span class="sourceLineNo">863</span><a name="line.863"></a>
+<span class="sourceLineNo">864</span>    private String getTableSetName() {<a 
name="line.864"></a>
+<span class="sourceLineNo">865</span>      return 
cmdline.getOptionValue(OPTION_SET);<a name="line.865"></a>
+<span class="sourceLineNo">866</span>    }<a name="line.866"></a>
+<span class="sourceLineNo">867</span><a name="line.867"></a>
+<span class="sourceLineNo">868</span>    private int parseHistoryLength() 
throws IOException {<a name="line.868"></a>
+<span class="sourceLineNo">869</span>      String value = 
cmdline.getOptionValue(OPTION_RECORD_NUMBER);<a name="line.869"></a>
+<span class="sourceLineNo">870</span>      try {<a name="line.870"></a>
+<span class="sourceLineNo">871</span>        if (value == null) {<a 
name="line.871"></a>
+<span class="sourceLineNo">872</span>          return 
DEFAULT_HISTORY_LENGTH;<a name="line.872"></a>
+<span class="sourceLineNo">873</span>        }<a name="line.873"></a>
+<span class="sourceLineNo">874</span><a name="line.874"></a>
+<span class="sourceLineNo">875</span>        return Integer.parseInt(value);<a 
name="line.875"></a>
+<span class="sourceLineNo">876</span>      } catch (NumberFormatException e) 
{<a name="line.876"></a>
+<span class="sourceLineNo">877</span>        System.out.println("Illegal 
argument for history length: " + value);<a name="line.877"></a>
+<span class="sourceLineNo">878</span>        printUsage();<a 
name="line.878"></a>
+<span class="sourceLineNo">879</span>        throw new 
IOException(INCORRECT_USAGE);<a name="line.879"></a>
+<span class="sourceLineNo">880</span>      }<a name="line.880"></a>
+<span class="sourceLineNo">881</span>    }<a name="line.881"></a>
+<span class="sourceLineNo">882</span><a name="line.882"></a>
+<span class="sourceLineNo">883</span>    @Override<a name="line.883"></a>
+<span class="sourceLineNo">884</span>    protected void printUsage() {<a 
name="line.884"></a>
+<span class="sourceLineNo">885</span>      
System.out.println(HISTORY_CMD_USAGE);<a name="line.885"></a>
+<span class="sourceLineNo">886</span>      Options options = new Options();<a 
name="line.886"></a>
+<span class="sourceLineNo">887</span>      
options.addOption(OPTION_RECORD_NUMBER, true, OPTION_RECORD_NUMBER_DESC);<a 
name="line.887"></a>
+<span class="sourceLineNo">888</span>      options.addOption(OPTION_PATH, 
true, OPTION_PATH_DESC);<a name="line.888"></a>
+<span class="sourceLineNo">889</span>      options.addOption(OPTION_TABLE, 
true, OPTION_TABLE_DESC);<a name="line.889"></a>
+<span class="sourceLineNo">890</span>      options.addOption(OPTION_SET, true, 
OPTION_SET_DESC);<a name="line.890"></a>
+<span class="sourceLineNo">891</span><a name="line.891"></a>
+<span class="sourceLineNo">892</span>      HelpFormatter helpFormatter = new 
HelpFormatter();<a name="line.892"></a>
+<span class="sourceLineNo">893</span>      helpFormatter.setLeftPadding(2);<a 
name="line.893"></a>
+<span class="sourceLineNo">894</span>      helpFormatter.setDescPadding(8);<a 
name="line.894"></a>
+<span class="sourceLineNo">895</span>      helpFormatter.setWidth(100);<a 
name="line.895"></a>
+<span class="sourceLineNo">896</span>      
helpFormatter.setSyntaxPrefix("Options:");<a name="line.896"></a>
+<span class="sourceLineNo">897</span>      helpFormatter.printHelp(" ", null, 
options, USAGE_FOOTER);<a name="line.897"></a>
+<span class="sourceLineNo">898</span>    }<a name="line.898"></a>
+<span class="sourceLineNo">899</span>  }<a name="line.899"></a>
+<span class="sourceLineNo">900</span><a name="line.900"></a>
+<span class="sourceLineNo">901</span>  public static class BackupSetCommand 
extends Command {<a name="line.901"></a>
+<span class="sourceLineNo">902</span>    private final static String 
SET_ADD_CMD = "add";<a name="line.902"></a>
+<span class="sourceLineNo">903</span>    private final static String 
SET_REMOVE_CMD = "remove";<a name="line.903"></a>
+<span class="sourceLineNo">904</span>    private final static String 
SET_DELETE_CMD = "delete";<a name="line.904"></a>
+<span class="sourceLineNo">905</span>    private final static String 
SET_DESCRIBE_CMD = "describe";<a name="line.905"></a>
+<span class="sourceLineNo">906</span>    private final static String 
SET_LIST_CMD = "list";<a name="line.906"></a>
+<span class="sourceLineNo">907</span><a name="line.907"></a>
+<span class="sourceLineNo">908</span>    BackupSetCommand(Configuration conf, 
CommandLine cmdline) {<a name="line.908"></a>
+<span class="sourceLineNo">909</span>      super(conf);<a name="line.909"></a>
+<span class="sourceLineNo">910</span>      this.cmdline = cmdline;<a 
name="line.910"></a>
+<span class="sourceLineNo">911</span>    }<a name="line.911"></a>
 <span class="sourceLineNo">912</span><a name="line.912"></a>
-<span class="sourceLineNo">913</span>      // List all backup set names<a 
name="line.913"></a>
-<span class="sourceLineNo">914</span>      // does not expect any args<a 
name="line.914"></a>
-<span class="sourceLineNo">915</span>      try (BackupAdminImpl admin = new 
BackupAdminImpl(conn)) {<a name="line.915"></a>
-<span class="sourceLineNo">916</span>        List&lt;BackupSet&gt; list = 
admin.listBackupSets();<a name="line.916"></a>
-<span class="sourceLineNo">917</span>        for (BackupSet bs : list) {<a 
name="line.917"></a>
-<span class="sourceLineNo">918</span>          System.out.println(bs);<a 
name="line.918"></a>
-<span class="sourceLineNo">919</span>        }<a name="line.919"></a>
-<span class="sourceLineNo">920</span>      }<a name="line.920"></a>
-<span class="sourceLineNo">921</span>    }<a name="line.921"></a>
-<span class="sourceLineNo">922</span><a name="line.922"></a>
-<span class="sourceLineNo">923</span>    private void 
processSetDescribe(String[] args) throws IOException {<a name="line.923"></a>
-<span class="sourceLineNo">924</span>      if (args == null || args.length != 
3) {<a name="line.924"></a>
-<span class="sourceLineNo">925</span>        printUsage();<a 
name="line.925"></a>
-<span class="sourceLineNo">926</span>        throw new 
IOException(INCORRECT_USAGE);<a name="line.926"></a>
-<span class="sourceLineNo">927</span>      }<a name="line.927"></a>
-<span class="sourceLineNo">928</span>      super.execute();<a 
name="line.928"></a>
-<span class="sourceLineNo">929</span><a name="line.929"></a>
-<span class="sourceLineNo">930</span>      String setName = args[2];<a 
name="line.930"></a>
-<span class="sourceLineNo">931</span>      try (final BackupSystemTable 
sysTable = new BackupSystemTable(conn)) {<a name="line.931"></a>
-<span class="sourceLineNo">932</span>        List&lt;TableName&gt; tables = 
sysTable.describeBackupSet(setName);<a name="line.932"></a>
-<span class="sourceLineNo">933</span>        BackupSet set = tables == null ? 
null : new BackupSet(setName, tables);<a name="line.933"></a>
-<span class="sourceLineNo">934</span>        if (set == null) {<a 
name="line.934"></a>
-<span class="sourceLineNo">935</span>          System.out.println("Set '" + 
setName + "' does not exist.");<a name="line.935"></a>
-<span class="sourceLineNo">936</span>        } else {<a name="line.936"></a>
-<span class="sourceLineNo">937</span>          System.out.println(set);<a 
name="line.937"></a>
-<span class="sourceLineNo">938</span>        }<a name="line.938"></a>
-<span class="sourceLineNo">939</span>      }<a name="line.939"></a>
-<span class="sourceLineNo">940</span>    }<a name="line.940"></a>
-<span class="sourceLineNo">941</span><a name="line.941"></a>
-<span class="sourceLineNo">942</span>    private void 
processSetDelete(String[] args) throws IOException {<a name="line.942"></a>
-<span class="sourceLineNo">943</span>      if (args == null || args.length != 
3) {<a name="line.943"></a>
-<span class="sourceLineNo">944</span>        printUsage();<a 
name="line.944"></a>
-<span class="sourceLineNo">945</span>        throw new 
IOException(INCORRECT_USAGE);<a name="line.945"></a>
-<span class="sourceLineNo">946</span>      }<a name="line.946"></a>
+<span class="sourceLineNo">913</span>    @Override<a name="line.913"></a>
+<span class="sourceLineNo">914</span>    public void execute() throws 
IOException {<a name="line.914"></a>
+<span class="sourceLineNo">915</span>      // Command-line must have at least 
one element<a name="line.915"></a>
+<span class="sourceLineNo">916</span>      if (cmdline == null || 
cmdline.getArgs() == null || cmdline.getArgs().length &lt; 2) {<a 
name="line.916"></a>
+<span class="sourceLineNo">917</span>        printUsage();<a 
name="line.917"></a>
+<span class="sourceLineNo">918</span>        throw new 
IOException(INCORRECT_USAGE);<a name="line.918"></a>
+<span class="sourceLineNo">919</span>      }<a name="line.919"></a>
+<span class="sourceLineNo">920</span><a name="line.920"></a>
+<span class="sourceLineNo">921</span>      String[] args = 
cmdline.getArgs();<a name="line.921"></a>
+<span class="sourceLineNo">922</span>      String cmdStr = args[1];<a 
name="line.922"></a>
+<span class="sourceLineNo">923</span>      BackupCommand cmd = 
getCommand(cmdStr);<a name="line.923"></a>
+<span class="sourceLineNo">924</span><a name="line.924"></a>
+<span class="sourceLineNo">925</span>      switch (cmd) {<a 
name="line.925"></a>
+<span class="sourceLineNo">926</span>        case SET_ADD:<a 
name="line.926"></a>
+<span class="sourceLineNo">927</span>          processSetAdd(args);<a 
name="line.927"></a>
+<span class="sourceLineNo">928</span>          break;<a name="line.928"></a>
+<span class="sourceLineNo">929</span>        case SET_REMOVE:<a 
name="line.929"></a>
+<span class="sourceLineNo">930</span>          processSetRemove(args);<a 
name="line.930"></a>
+<span class="sourceLineNo">931</span>          break;<a name="line.931"></a>
+<span class="sourceLineNo">932</span>        case SET_DELETE:<a 
name="line.932"></a>
+<span class="sourceLineNo">933</span>          processSetDelete(args);<a 
name="line.933"></a>
+<span class="sourceLineNo">934</span>          break;<a name="line.934"></a>
+<span class="sourceLineNo">935</span>        case SET_DESCRIBE:<a 
name="line.935"></a>
+<span class="sourceLineNo">936</span>          processSetDescribe(args);<a 
name="line.936"></a>
+<span class="sourceLineNo">937</span>          break;<a name="line.937"></a>
+<span class="sourceLineNo">938</span>        case SET_LIST:<a 
name="line.938"></a>
+<span class="sourceLineNo">939</span>          processSetList(args);<a 
name="line.939"></a>
+<span class="sourceLineNo">940</span>          break;<a name="line.940"></a>
+<span class="sourceLineNo">941</span>        default:<a name="line.941"></a>
+<span class="sourceLineNo">942</span>          break;<a name="line.942"></a>
+<span class="sourceLineNo">943</span>      }<a name="line.943"></a>
+<span class="sourceLineNo">944</span>    }<a name="line.944"></a>
+<span class="sourceLineNo">945</span><a name="line.945"></a>
+<span class="sourceLineNo">946</span>    private void processSetList(String[] 
args) throws IOException {<a name="line.946"></a>
 <span class="sourceLineNo">947</span>      super.execute();<a 
name="line.947"></a>
 <span class="sourceLineNo">948</span><a name="line.948"></a>
-<span class="sourceLineNo">949</span>      String setName = args[2];<a 
name="line.949"></a>
-<span class="sourceLineNo">950</span>      try (final BackupAdminImpl admin = 
new BackupAdminImpl(conn)) {<a name="line.950"></a>
-<span class="sourceLineNo">951</span>        boolean result = 
admin.deleteBackupSet(setName);<a name="line.951"></a>
-<span class="sourceLineNo">952</span>        if (result) {<a 
name="line.952"></a>
-<span class="sourceLineNo">953</span>          System.out.println("Delete set 
" + setName + " OK.");<a name="line.953"></a>
-<span class="sourceLineNo">954</span>        } else {<a name="line.954"></a>
-<span class="sourceLineNo">955</span>          System.out.println("Set " + 
setName + " does not exist");<a name="line.955"></a>
-<span class="sourceLineNo">956</span>        }<a name="line.956"></a>
-<span class="sourceLineNo">957</span>      }<a name="line.957"></a>
-<span class="sourceLineNo">958</span>    }<a name="line.958"></a>
-<span class="sourceLineNo">959</span><a name="line.959"></a>
-<span class="sourceLineNo">960</span>    private void 
processSetRemove(String[] args) throws IOException {<a name="line.960"></a>
-<span class="sourceLineNo">961</span>      if (args == null || args.length != 
4) {<a name="line.961"></a>
-<span class="sourceLineNo">962</span>        printUsage();<a 
name="line.962"></a>
-<span class="sourceLineNo">963</span>        throw new 
IOException(INCORRECT_USAGE);<a name="line.963"></a>
-<span class="sourceLineNo">964</span>      }<a name="line.964"></a>
-<span class="sourceLineNo">965</span>      super.execute();<a 
name="line.965"></a>
-<span class="sourceLineNo">966</span><a name="line.966"></a>
-<span class="sourceLineNo">967</span>      String setName = args[2];<a 
name="line.967"></a>
-<span class="sourceLineNo">968</span>      String[] tables = 
args[3].split(",");<a name="line.968"></a>
-<span class="sourceLineNo">969</span>      TableName[] tableNames = 
toTableNames(tables);<a name="line.969"></a>
-<span class="sourceLineNo">970</span>      try (final BackupAdminImpl admin = 
new BackupAdminImpl(conn)) {<a name="line.970"></a>
-<span class="sourceLineNo">971</span>        
admin.removeFromBackupSet(setName, tableNames);<a name="line.971"></a>
-<span class="sourceLineNo">972</span>      }<a name="line.972"></a>
-<span class="sourceLineNo">973</span>    }<a name="line.973"></a>
-<span class="sourceLineNo">974</span><a name="line.974"></a>
-<span class="sourceLineNo">975</span>    private TableName[] 
toTableNames(String[] tables) {<a name="line.975"></a>
-<span class="sourceLineNo">976</span>      TableName[] arr = new 
TableName[tables.length];<a name="line.976"></a>
-<span class="sourceLineNo">977</span>      for (int i = 0; i &lt; 
tables.length; i++) {<a name="line.977"></a>
-<span class="sourceLineNo">978</span>        arr[i] = 
TableName.valueOf(tables[i]);<a name="line.978"></a>
-<span class="sourceLineNo">979</span>      }<a name="line.979"></a>
-<span class="sourceLineNo">980</span>      return arr;<a name="line.980"></a>
-<span class="sourceLineNo">981</span>    }<a name="line.981"></a>
-<span class="sourceLineNo">982</span><a name="line.982"></a>
-<span class="sourceLineNo">983</span>    private void processSetAdd(String[] 
args) throws IOException {<a name="line.983"></a>
-<span class="sourceLineNo">984</span>      if (args == null || args.length != 
4) {<a name="line.984"></a>
-<span class="sourceLineNo">985</span>        printUsage();<a 
name="line.985"></a>
-<span class="sourceLineNo">986</span>        throw new 
IOException(INCORRECT_USAGE);<a name="line.986"></a>
-<span class="sourceLineNo">987</span>      }<a name="line.987"></a>
-<span class="sourceLineNo">988</span>      super.execute();<a 
name="line.988"></a>
-<span class="sourceLineNo">989</span><a name="line.989"></a>
-<span class="sourceLineNo">990</span>      String setName = args[2];<a 
name="line.990"></a>
-<span class="sourceLineNo">991</span>      String[] tables = 
args[3].split(",");<a name="line.991"></a>
-<span class="sourceLineNo">992</span>      TableName[] tableNames = new 
TableName[tables.length];<a name="line.992"></a>
-<span class="sourceLineNo">993</span>      for (int i = 0; i &lt; 
tables.length; i++) {<a name="line.993"></a>
-<span class="sourceLineNo">994</span>        tableNames[i] = 
TableName.valueOf(tables[i]);<a name="line.994"></a>
-<span class="sourceLineNo">995</span>      }<a name="line.995"></a>
-<span class="sourceLineNo">996</span>      try (final BackupAdminImpl admin = 
new BackupAdminImpl(conn)) {<a name="line.996"></a>
-<span class="sourceLineNo">997</span>        admin.addToBackupSet(setName, 
tableNames);<a name="line.997"></a>
-<span class="sourceLineNo">998</span>      }<a name="line.998"></a>
-<span class="sourceLineNo">999</span><a name="line.999"></a>
-<span class="sourceLineNo">1000</span>    }<a name="line.1000"></a>
-<span class="sourceLineNo">1001</span><a name="line.1001"></a>
-<span class="sourceLineNo">1002</span>    private BackupCommand 
getCommand(String cmdStr) throws IOException {<a name="line.1002"></a>
-<span class="sourceLineNo">1003</span>      switch (cmdStr) {<a 
name="line.1003"></a>
-<span class="sourceLineNo">1004</span>        case SET_ADD_CMD:<a 
name="line.1004"></a>
-<span class="sourceLineNo">1005</span>          return 
BackupCommand.SET_ADD;<a name="line.1005"></a>
-<span class="sourceLineNo">1006</span>        case SET_REMOVE_CMD:<a 
name="line.1006"></a>
-<span class="sourceLineNo">1007</span>          return 
BackupCommand.SET_REMOVE;<a name="line.1007"></a>
-<span class="sourceLineNo">1008</span>        case SET_DELETE_CMD:<a 
name="line.1008"></a>
-<span class="sourceLineNo">1009</span>          return 
BackupCommand.SET_DELETE;<a name="line.1009"></a>
-<span class="sourceLineNo">1010</span>        case SET_DESCRIBE_CMD:<a 
name="line.1010"></a>
-<span class="sourceLineNo">1011</span>          return 
BackupCommand.SET_DESCRIBE;<a name="line.1011"></a>
-<span class="sourceLineNo">1012</span>        case SET_LIST_CMD:<a 
name="line.1012"></a>
-<span class="sourceLineNo">1013</span>          return 
BackupCommand.SET_LIST;<a name="line.1013"></a>
-<span class="sourceLineNo">1014</span>        default:<a name="line.1014"></a>
-<span class="sourceLineNo">1015</span>          System.out.println("ERROR: 
Unknown command for 'set' :" + cmdStr);<a name="line.1015"></a>
-<span class="sourceLineNo">1016</span>          printUsage();<a 
name="line.1016"></a>
-<span class="sourceLineNo">1017</span>          throw new 
IOException(INCORRECT_USAGE);<a name="line.1017"></a>
-<span class="sourceLineNo">1018</span>      }<a name="line.1018"></a>
-<span class="sourceLineNo">1019</span>    }<a name="line.1019"></a>
-<span class="sourceLineNo">1020</span><a name="line.1020"></a>
-<span class="sourceLineNo">1021</span>    @Override<a name="line.1021"></a>
-<span class="sourceLineNo">1022</span>    protected void printUsage() {<a 
name="line.1022"></a>
-<span class="sourceLineNo">1023</span>      
System.out.println(SET_CMD_USAGE);<a name="line.1023"></a>
-<span class="sourceLineNo">1024</span>    }<a name="line.1024"></a>
-<span class="sourceLineNo">1025</span>  }<a name="line.1025"></a>
-<span class="sourceLineNo">1026</span>}<a name="line.1026"></a>
+<span class="sourceLineNo">949</span>      // List all backup set names<a 
name="line.949"></a>
+<span class="sourceLineNo">950</span>      // does not expect any args<a 
name="line.950"></a>
+<span class="sourceLineNo">951</span>      try (BackupAdminImpl admin = new 
BackupAdminImpl(conn)) {<a name="line.951"></a>
+<span class="sourceLineNo">952</span>        List&lt;BackupSet&gt; list = 
admin.listBackupSets();<a name="line.952"></a>
+<span class="sourceLineNo">953</span>        for (BackupSet bs : list) {<a 
name="line.953"></a>
+<span class="sourceLineNo">954</span>          System.out.println(bs);<a 
name="line.954"></a>
+<span class="sourceLineNo">955</span>        }<a name="line.955"></a>
+<span class="sourceLineNo">956</span>      }<a name="line.956"></a>
+<span class="sourceLineNo">957</span>    }<a name="line.957"></a>
+<span class="sourceLineNo">958</span><a name="line.958"></a>
+<span class="sourceLineNo">959</span>    private void 
processSetDescribe(String[] args) throws IOException {<a name="line.959"></a>
+<span class="sourceLineNo">960</span>      if (args == null || args.length != 
3) {<a name="line.960"></a>
+<span class="sourceLineNo">961</span>        printUsage();<a 
name="line.961"></a>
+<span class="sourceLineNo">962</span>        throw new 
IOException(INCORRECT_USAGE);<a name="line.962"></a>
+<span class="sourceLineNo">963</span>      }<a name="line.963"></a>
+<span class="sourceLineNo">964</span>      super.execute();<a 
name="line.964"></a>
+<span class="sourceLineNo">965</span><a name="line.965"></a>
+<span class="sourceLineNo">966</span>      String setName = args[2];<a 
name="line.966"></a>
+<span class="sourceLineNo">967</span>      try (final BackupSystemTable 
sysTable = new BackupSystemTable(conn)) {<a name="line.967"></a>
+<span class="sourceLineNo">968</span>        List&lt;TableName&gt; tables = 
sysTable.describeBackupSet(setName);<a name="line.968"></a>
+<span class="sourceLineNo">969</span>        BackupSet set = tables == null ? 
null : new BackupSet(setName, tables);<a name="line.969"></a>
+<span class="sourceLineNo">970</span>        if (set == null) {<a 
name="line.970"></a>
+<span class="sourceLineNo">971</span>          System.out.println("Set '" + 
setName + "' does not exist.");<a name="line.971"></a>
+<span class="sourceLineNo">972</span>        } else {<a name="line.972"></a>
+<span class="sourceLineNo">973</span>          System.out.println(set);<a 
name="line.973"></a>
+<span class="sourceLineNo">974</span>        }<a name="line.974"></a>
+<span class="sourceLineNo">975</span>      }<a name="line.975"></a>
+<span class="sourceLineNo">976</span>    }<a name="line.976"></a>
+<span class="sourceLineNo">977</span><a name="line.977"></a>
+<span class="sourceLineNo">978</span>    private void 
processSetDelete(String[] args) throws IOException {<a name="line.978"></a>
+<span class="sourceLineNo">979</span>      if (args == null || args.length != 
3) {<a name="line.979"></a>
+<span class="sourceLineNo">980</span>        printUsage();<a 
name="line.980"></a>
+<span class="sourceLineNo">981</span>        throw new 
IOException(INCORRECT_USAGE);<a name="line.981"></a>
+<span class="sourceLineNo">982</span>      }<a name="line.982"></a>
+<span class="sourceLineNo">983</span>      super.execute();<a 
name="line.983"></a>
+<span class="sourceLineNo">984</span><a name="line.984"></a>
+<span class="sourceLineNo">985</span>      String setName = args[2];<a 
name="line.985"></a>
+<span class="sourceLineNo">986</span>      try (final BackupAdminImpl admin = 
new BackupAdminImpl(conn)) {<a name="line.986"></a>
+<span class="sourceLineNo">987</span>        boolean result = 
admin.deleteBackupSet(setName);<a name="line.987"></a>
+<span class="sourceLineNo">988</span>        if (result) {<a 
name="line.988"></a>
+<span class="sourceLineNo">989</span>          System.out.println("Delete set 
" + setName + " OK.");<a name="line.989"></a>
+<span class="sourceLineNo">990</span>        } else {<a name="line.990"></a>
+<span class="sourceLineNo">991</span>          System.out.println("Set " + 
setName + " does not exist");<a name="line.991"></a>
+<span class="sourceLineNo">992</span>        }<a name="line.992"></a>
+<span class="sourceLineNo">993</span>      }<a name="line.993"></a>
+<span class="sourceLineNo">994</span>    }<a name="line.994"></a>
+<span class="sourceLineNo">995</span><a name="line.995"></a>
+<span class="sourceLineNo">996</span>    private void 
processSetRemove(String[] args) throws IOException {<a name="line.996"></a>
+<span class="sourceLineNo">997</span>      if (args == null || args.length != 
4) {<a name="line.997"></a>
+<span class="sourceLineNo">998</span>        printUsage();<a 
name="line.998"></a>
+<span class="sourceLineNo">999</span>        throw new 
IOException(INCORRECT_USAGE);<a name="line.999"></a>
+<span class="sourceLineNo">1000</span>      }<a name="line.1000"></a>
+<span class="sourceLineNo">1001</span>      super.execute();<a 
name="line.1001"></a>
+<span class="sourceLineNo">1002</span><a name="line.1002"></a>
+<span class="sourceLineNo">1003</span>      String setName = args[2];<a 
name="line.1003"></a>
+<span class="sourceLineNo">1004</span>      String[] tables = 
args[3].split(",");<a name="line.1004"></a>
+<span class="sourceLineNo">1005</span>      TableName[] tableNames = 
toTableNames(tables);<a name="line.1005"></a>
+<span class="sourceLineNo">1006</span>      try (final BackupAdminImpl admin = 
new BackupAdminImpl(conn)) {<a name="line.1006"></a>
+<span class="sourceLineNo">1007</span>        
admin.removeFromBackupSet(setName, tableNames);<a name="line.1007"></a>
+<span class="sourceLineNo">1008</span>      }<a name="line.1008"></a>
+<span class="sourceLineNo">1009</span>    }<a name="line.1009"></a>
+<span class="sourceLineNo">1010</span><a name="line.1010"></a>
+<span class="sourceLineNo">1011</span>    private TableName[] 
toTableNames(String[] tables) {<a name="line.1011"></a>
+<span class="sourceLineNo">1012</span>      TableName[] arr = new 
TableName[tables.length];<a name="line.1012"></a>
+<span class="sourceLineNo">1013</span>      for (int i = 0; i &lt; 
tables.length; i++) {<a name="line.1013"></a>
+<span class="sourceLineNo">1014</span>        arr[i] = 
TableName.valueOf(tables[i]);<a name="line.1014"></a>
+<span class="sourceLineNo">1015</span>      }<a name="line.1015"></a>
+<span class="sourceLineNo">1016</span>      return arr;<a name="line.1016"></a>
+<span class="sourceLineNo">1017</span>    }<a name="line.1017"></a>
+<span class="sourceLineNo">1018</span><a name="line.1018"></a>
+<span class="sourceLineNo">1019</span>    private void processSetAdd(String[] 
args) throws IOException {<a name="line.1019"></a>
+<span class="sourceLineNo">1020</span>      if (args == null || args.length != 
4) {<a name="line.1020"></a>
+<span class="sourceLineNo">1021</span>        printUsage();<a 
name="line.1021"></a>
+<span class="sourceLineNo">1022</span>        throw new 
IOException(INCORRECT_USAGE);<a name="line.1022"></a>
+<span class="sourceLineNo">1023</span>      }<a name="line.1023"></a>
+<span class="sourceLineNo">1024</span>      super.execute();<a 
name="line.1024"></a>
+<span class="sourceLineNo">1025</span><a name="line.1025"></a>
+<span class="sourceLineNo">1026</span>      String setName = args[2];<a 
name="line.1026"></a>
+<span class="sourceLineNo">1027</span>      String[] tables = 
args[3].split(",");<a name="line.1027"></a>
+<span class="sourceLineNo">1028</span>      TableName[] tableNames = new 
TableName[tables.length];<a name="line.1028"></a>
+<span class="sourceLineNo">1029</span>      for (int i = 0; i &lt; 
tables.length; i++) {<a name="line.1029"></a>
+<span class="sourceLineNo">1030</span>        tableNames[i] = 
TableName.valueOf(tables[i]);<a name="line.1030"></a>
+<span class="sourceLineNo">1031</span>      }<a name="line.1031"></a>
+<span class="sourceLineNo">1032</span>      try (final BackupAdminImpl admin = 
new BackupAdminImpl(conn)) {<a name="line.1032"></a>
+<span class="sourceLineNo">1033</span>        admin.addToBackupSet(setName, 
tableNames);<a name="line.1033"></a>
+<span class="sourceLineNo">1034</span>      }<a name="line.1034"></a>
+<span class="sourceLineNo">1035</span><a name="line.1035"></a>
+<span class="sourceLineNo">1036</span>    }<a name="line.1036"></a>
+<span class="sourceLineNo">1037</span><a name="line.1037"></a>
+<span class="sourceLineNo">1038</span>    private BackupCommand 
getCommand(String cmdStr) throws IOException {<a name="line.1038"></a>
+<span class="sourceLineNo">1039</span>      switch (cmdStr) {<a 
name="line.1039"></a>
+<span class="sourceLineNo">1040</span>        case SET_ADD_CMD:<a 
name="line.1040"></a>
+<span class="sourceLineNo">1041</span>          return 
BackupCommand.SET_ADD;<a name="line.1041"></a>
+<span class="sourceLineNo">1042</span>        case SET_REMOVE_CMD:<a 
name="line.1042"></a>
+<span class="sourceLineNo">1043</span>          return 
BackupCommand.SET_REMOVE;<a name="line.1043"></a>
+<span class="sourceLineNo">1044</span>        case SET_DELETE_CMD:<a 
name="line.1044"></a>
+<span class="sourceLineNo">1045</span>          return 
BackupCommand.SET_DELETE;<a name="line.1045"></a>
+<span class="sourceLineNo">1046</span>        case SET_DESCRIBE_CMD:<a 
name="line.1046"></a>
+<span class="sourceLineNo">1047</span>          return 
BackupCommand.SET_DESCRIBE;<a name="line.1047"></a>
+<span class="sourceLineNo">1048</span>        case SET_LIST_CMD:<a 
name="line.1048"></a>
+<span class="sourceLineNo">1049</span>          return 
BackupCommand.SET_LIST;<a name="line.1049"></a>
+<span class="sourceLineNo">1050</span>        default:<a name="line.1050"></a>
+<span class="sourceLineNo">1051</span>          System.out.println("ERROR: 
Unknown command for 'set' :" + cmdStr);<a name="line.1051"></a>
+<span class="sourceLineNo">1052</span>          printUsage();<a 
name="line.1052"></a>
+<span class="sourceLineNo">1053</span>          throw new 
IOException(INCORRECT_USAGE);<a name="line.1053"></a>
+<span class="sourceLineNo">1054</span>      }<a name="line.1054"></a>
+<span class="sourceLineNo">1055</span>    }<a name="line.1055"></a>
+<span class="sourceLineNo">1056</span><a name="line.1056"></a>
+<span class="sourceLineNo">1057</span>    @Override<a name="line.1057"></a>
+<span class="sourceLineNo">1058</span>    protected void printUsage() {<a 
name="line.1058"></a>
+<span class="sourceLineNo">1059</span>      
System.out.println(SET_CMD_USAGE);<a name="line.1059"></a>
+<span class="sourceLineNo">1060</span>    }<a name="line.1060"></a>
+<span class="sourceLineNo">1061</span>  }<a name="line.1061"></a>
+<span class="sourceLineNo">1062</span>}<a name="line.1062"></a>
 
 
 

Reply via email to