diff --git hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java index 8ba26ba..1f0b803 100644 --- hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java +++ hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java @@ -62,6 +62,7 @@ import org.apache.hadoop.hbase.TableNotFoundException; import org.apache.hadoop.hbase.UnknownRegionException; import org.apache.hadoop.hbase.ZooKeeperConnectionException; import org.apache.hadoop.hbase.backup.BackupRequest; +import org.apache.hadoop.hbase.backup.BackupType; import org.apache.hadoop.hbase.backup.util.BackupClientUtil; import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceStability; @@ -1588,11 +1589,42 @@ public class HBaseAdmin implements Admin { return new TableBackupFuture(this, TableName.BACKUP_TABLE_NAME, response); } - String backupTables(final BackupRequest userRequest) throws IOException { - return get( - backupTablesAsync(userRequest), - backupWaitTimeout, - TimeUnit.SECONDS); + String backupTables(final BackupRequest userRequest) throws IOException { + boolean[] currentSettings = null; + boolean balancer = false; + String backupId = null; + + boolean isFullBackup = userRequest.getBackupType() == BackupType.FULL; + if (isFullBackup) { + currentSettings = setSplitOrMergeEnabled(false, true, MasterSwitchType.SPLIT, + MasterSwitchType.MERGE); + LOG.debug("Table splits and merges was disabled"); + + balancer = isBalancerEnabled(); + if (balancer) { + setBalancerRunning(false, true); + LOG.debug("Auto-balancing was turned off"); + } + } + try{ + backupId = get( + backupTablesAsync(userRequest), + backupWaitTimeout, + TimeUnit.SECONDS); + } finally { + if (isFullBackup) { + LOG.debug("Set SPLIT_ENABLED to "+ currentSettings[0]); + setSplitOrMergeEnabled(currentSettings[0], true, MasterSwitchType.SPLIT); + LOG.debug("Set MERGE_ENABLED to "+ currentSettings[1]); + setSplitOrMergeEnabled(currentSettings[1], true, MasterSwitchType.MERGE); + LOG.debug("Table splits and merges was restored"); + if (balancer) { + setBalancerRunning(true, true); + LOG.debug("Auto-balancing was enabled"); + } + } + } + return backupId; } public static class TableBackupFuture extends TableFuture {