diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/backup/impl/RestoreClientImpl.java hbase-server/src/main/java/org/apache/hadoop/hbase/backup/impl/RestoreClientImpl.java index 9906f47..4b807bf 100644 --- hbase-server/src/main/java/org/apache/hadoop/hbase/backup/impl/RestoreClientImpl.java +++ hbase-server/src/main/java/org/apache/hadoop/hbase/backup/impl/RestoreClientImpl.java @@ -105,7 +105,7 @@ public final class RestoreClientImpl implements RestoreClient { } // check the target tables - checkTargetTables(tTableArray, isOverwrite); + checkTargetTables(tTableArray, autoRestore, isOverwrite); // start restore process @@ -155,9 +155,11 @@ public final class RestoreClientImpl implements RestoreClient { * Validate target Tables * @param tTableArray: target tables * @param isOverwrite overwrite existing table + * @param autorestore - restore all dependencies first * @throws IOException exception */ - private void checkTargetTables(TableName[] tTableArray, boolean isOverwrite) + private void checkTargetTables(TableName[] tTableArray, boolean autorestore, + boolean isOverwrite) throws IOException { ArrayList existTableList = new ArrayList<>(); ArrayList disabledTableList = new ArrayList<>(); @@ -177,25 +179,25 @@ public final class RestoreClientImpl implements RestoreClient { } } } - + // TODO: we have never tried to restore disabled tables! + if (disabledTableList.size() > 0) { + LOG.error("Found offline table in the restore target, " + + "please enable them before restore."); + LOG.info("Offline table list in restore target: " + + StringUtils.join(disabledTableList, ",")); + throw new IOException( + "Found offline table in the target: "+ StringUtils.join(disabledTableList, ",")); + } if (existTableList.size() > 0) { - if (!isOverwrite) { - LOG.error("Existing table found in the restore target, please add \"-overwrite\" " + if (!isOverwrite && autorestore) { + LOG.error("Existing table found in the restore target, autorestore is on, "+ + "please add \"-overwrite\" " + "option in the command if you mean to restore to these existing tables"); - LOG.info("Existing table list in restore target: " + existTableList); + LOG.info("Existing table list in restore target: " + StringUtils.join(existTableList, ",")); throw new IOException("Existing table found in target while no \"-overwrite\" " - + "option found"); - } else { - if (disabledTableList.size() > 0) { - LOG.error("Found offline table in the restore target, " - + "please enable them before restore with \"-overwrite\" option"); - LOG.info("Offline table list in restore target: " + disabledTableList); - throw new IOException( - "Found offline table in the target when restore with \"-overwrite\" option"); - } - } + + "option found and autorestore is on: "+ StringUtils.join(existTableList, ",")); + } } - } /**