You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by bb...@apache.org on 2023/01/24 13:38:59 UTC
[hbase] branch branch-2 updated (8f02a61c7d7 -> cfab38a5106)
This is an automated email from the ASF dual-hosted git repository.
bbeaudreault pushed a change to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git
from 8f02a61c7d7 HBASE-27551 Add config options to delay assignment to retain last region location (#4945)
new e206b974c85 HBASE-27542 Remove unneeded distcp log cleanup after incremental backups (#4934)
new 140e0de7487 HBASE-26300 Skip archived master wals during incremental backups (#4932)
new cfab38a5106 HBASE-27541 Backups should be able to be restored to a separate filesystem (#4933)
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../org/apache/hadoop/hbase/backup/RestoreJob.java | 5 +-
.../apache/hadoop/hbase/backup/RestoreRequest.java | 15 ++++++
.../hbase/backup/impl/RestoreTablesClient.java | 18 +++++--
.../hbase/backup/impl/TableBackupClient.java | 22 +--------
.../backup/mapreduce/MapReduceRestoreJob.java | 9 ++--
.../hadoop/hbase/backup/util/BackupUtils.java | 40 ++++++++++++----
.../hadoop/hbase/backup/util/RestoreTool.java | 12 +++--
.../hadoop/hbase/backup/TestBackupUtils.java | 28 ++++++++++-
.../hadoop/hbase/backup/TestRemoteRestore.java | 55 ++++++++++++++++++++++
9 files changed, 156 insertions(+), 48 deletions(-)
[hbase] 01/03: HBASE-27542 Remove unneeded distcp log cleanup after incremental backups (#4934)
Posted by bb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bbeaudreault pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git
commit e206b974c858bbf451249c6bae61a247eb957277
Author: Jarryd Lee <ja...@gmail.com>
AuthorDate: Wed Dec 21 13:16:39 2022 -0800
HBASE-27542 Remove unneeded distcp log cleanup after incremental backups (#4934)
Signed-off-by: Bryan Beaudreault <bb...@apache.org>
---
.../hbase/backup/impl/TableBackupClient.java | 22 +---------------------
1 file changed, 1 insertion(+), 21 deletions(-)
diff --git a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/TableBackupClient.java b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/TableBackupClient.java
index 2bb2c13e4dd..60dbc6470a7 100644
--- a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/TableBackupClient.java
+++ b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/TableBackupClient.java
@@ -335,25 +335,6 @@ public abstract class TableBackupClient {
return sb.toString();
}
- /**
- * Clean up directories with prefix "_distcp_logs-", which are generated when DistCp copying
- * hlogs.
- * @throws IOException exception
- */
- protected void cleanupDistCpLog(BackupInfo backupInfo, Configuration conf) throws IOException {
- Path rootPath = new Path(backupInfo.getHLogTargetDir()).getParent();
- FileStatus[] files = CommonFSUtils.listStatus(fs, rootPath);
- if (files == null) {
- return;
- }
- for (FileStatus file : files) {
- if (file.getPath().getName().startsWith("_distcp_logs")) {
- LOG.debug("Delete log files of DistCp: " + file.getPath().getName());
- CommonFSUtils.delete(fs, file.getPath(), true);
- }
- }
- }
-
/**
* Complete the overall backup.
* @param backupInfo backup info
@@ -381,11 +362,10 @@ public abstract class TableBackupClient {
// - delete HBase snapshot
// - clean up directories with prefix "exportSnapshot-", which are generated when exporting
// snapshots
+ // incremental backups use distcp, which handles cleaning up its own directories
if (type == BackupType.FULL) {
deleteSnapshots(conn, backupInfo, conf);
cleanupExportSnapshotLog(conf);
- } else if (type == BackupType.INCREMENTAL) {
- cleanupDistCpLog(backupInfo, conf);
}
BackupSystemTable.deleteSnapshot(conn);
backupManager.updateBackupInfo(backupInfo);
[hbase] 02/03: HBASE-26300 Skip archived master wals during incremental backups (#4932)
Posted by bb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bbeaudreault pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git
commit 140e0de7487b5e21d5f7f8369064b384a748df93
Author: Jarryd Lee <ja...@gmail.com>
AuthorDate: Tue Jan 3 18:14:53 2023 -0800
HBASE-26300 Skip archived master wals during incremental backups (#4932)
Signed-off-by: Bryan Beaudreault <bb...@apache.org>
---
.../hadoop/hbase/backup/util/BackupUtils.java | 5 ++++
.../hadoop/hbase/backup/TestBackupUtils.java | 28 +++++++++++++++++++++-
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/BackupUtils.java b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/BackupUtils.java
index 164ae7e7376..56cbcc3e10c 100644
--- a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/BackupUtils.java
+++ b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/BackupUtils.java
@@ -53,6 +53,7 @@ import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.client.TableDescriptor;
+import org.apache.hadoop.hbase.master.region.MasterRegionFactory;
import org.apache.hadoop.hbase.tool.BulkLoadHFiles;
import org.apache.hadoop.hbase.util.CommonFSUtils;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
@@ -359,6 +360,10 @@ public final class BackupUtils {
* @return host name
*/
public static String parseHostFromOldLog(Path p) {
+ // Skip master wals
+ if (p.getName().endsWith(MasterRegionFactory.ARCHIVED_WAL_SUFFIX)) {
+ return null;
+ }
try {
String n = p.getName();
int idx = n.lastIndexOf(LOGNAME_SEPARATOR);
diff --git a/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupUtils.java b/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupUtils.java
index 023acd79fb8..831ec309cfc 100644
--- a/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupUtils.java
+++ b/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupUtils.java
@@ -24,8 +24,14 @@ import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.backup.util.BackupUtils;
+import org.apache.hadoop.hbase.master.region.MasterRegionFactory;
import org.apache.hadoop.hbase.testclassification.SmallTests;
+import org.apache.hadoop.hbase.util.Addressing;
+import org.apache.hadoop.hbase.util.CommonFSUtils;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.security.UserGroupInformation;
import org.junit.Assert;
import org.junit.ClassRule;
@@ -45,7 +51,7 @@ public class TestBackupUtils {
protected static Configuration conf = TEST_UTIL.getConfiguration();
@Test
- public void TestGetBulkOutputDir() {
+ public void testGetBulkOutputDir() {
// Create a user who is not the current user
String fooUserName = "foo1234";
String fooGroupName = "group1";
@@ -78,4 +84,24 @@ public class TestBackupUtils {
// Make sure the directory is in foo1234's home directory
Assert.assertTrue(bulkOutputDir.toString().startsWith(fooHomeDirectory.toString()));
}
+
+ @Test
+ public void testFilesystemWalHostNameParsing() throws IOException {
+ String host = "localhost";
+ int port = 60030;
+ ServerName serverName = ServerName.valueOf(host, port, 1234);
+ Path walRootDir = CommonFSUtils.getWALRootDir(conf);
+ Path oldLogDir = new Path(walRootDir, HConstants.HREGION_OLDLOGDIR_NAME);
+
+ Path testWalPath = new Path(oldLogDir,
+ serverName.toString() + BackupUtils.LOGNAME_SEPARATOR + EnvironmentEdgeManager.currentTime());
+ Path testMasterWalPath =
+ new Path(oldLogDir, testWalPath.getName() + MasterRegionFactory.ARCHIVED_WAL_SUFFIX);
+
+ String parsedHost = BackupUtils.parseHostFromOldLog(testMasterWalPath);
+ Assert.assertNull(parsedHost);
+
+ parsedHost = BackupUtils.parseHostFromOldLog(testWalPath);
+ Assert.assertEquals(parsedHost, host + Addressing.HOSTNAME_PORT_SEPARATOR + port);
+ }
}
[hbase] 03/03: HBASE-27541 Backups should be able to be restored to a separate filesystem (#4933)
Posted by bb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bbeaudreault pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git
commit cfab38a510670efc752082ee0754c3f3a9092c8a
Author: Jarryd Lee <ja...@gmail.com>
AuthorDate: Tue Jan 17 17:09:01 2023 -0800
HBASE-27541 Backups should be able to be restored to a separate filesystem (#4933)
Signed-off-by: Bryan Beaudreault <bb...@apache.org>
---
.../org/apache/hadoop/hbase/backup/RestoreJob.java | 5 +-
.../apache/hadoop/hbase/backup/RestoreRequest.java | 15 ++++++
.../hbase/backup/impl/RestoreTablesClient.java | 18 +++++--
.../backup/mapreduce/MapReduceRestoreJob.java | 9 ++--
.../hadoop/hbase/backup/util/BackupUtils.java | 35 ++++++++++----
.../hadoop/hbase/backup/util/RestoreTool.java | 12 +++--
.../hadoop/hbase/backup/TestRemoteRestore.java | 55 ++++++++++++++++++++++
7 files changed, 123 insertions(+), 26 deletions(-)
diff --git a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/RestoreJob.java b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/RestoreJob.java
index b014e6693bb..831e097cb92 100644
--- a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/RestoreJob.java
+++ b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/RestoreJob.java
@@ -34,10 +34,11 @@ public interface RestoreJob extends Configurable {
* Run restore operation
* @param dirPaths path array of WAL log directories
* @param fromTables from tables
+ * @param restoreRootDir output file system
* @param toTables to tables
* @param fullBackupRestore full backup restore
* @throws IOException if running the job fails
*/
- void run(Path[] dirPaths, TableName[] fromTables, TableName[] toTables, boolean fullBackupRestore)
- throws IOException;
+ void run(Path[] dirPaths, TableName[] fromTables, Path restoreRootDir, TableName[] toTables,
+ boolean fullBackupRestore) throws IOException;
}
diff --git a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/RestoreRequest.java b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/RestoreRequest.java
index eb4786f5786..f7f1d848d95 100644
--- a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/RestoreRequest.java
+++ b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/RestoreRequest.java
@@ -37,6 +37,11 @@ public final class RestoreRequest {
return this;
}
+ public Builder withRestoreRootDir(String restoreRootDir) {
+ request.setRestoreRootDir(restoreRootDir);
+ return this;
+ }
+
public Builder withBackupId(String backupId) {
request.setBackupId(backupId);
return this;
@@ -68,6 +73,7 @@ public final class RestoreRequest {
}
private String backupRootDir;
+ private String restoreRootDir;
private String backupId;
private boolean check = false;
private TableName[] fromTables;
@@ -86,6 +92,15 @@ public final class RestoreRequest {
return this;
}
+ public String getRestoreRootDir() {
+ return restoreRootDir;
+ }
+
+ private RestoreRequest setRestoreRootDir(String restoreRootDir) {
+ this.restoreRootDir = restoreRootDir;
+ return this;
+ }
+
public String getBackupId() {
return backupId;
}
diff --git a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/RestoreTablesClient.java b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/RestoreTablesClient.java
index 9ec2442a3d9..05685c8e091 100644
--- a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/RestoreTablesClient.java
+++ b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/RestoreTablesClient.java
@@ -35,6 +35,7 @@ import org.apache.hadoop.hbase.backup.BackupType;
import org.apache.hadoop.hbase.backup.HBackupFileSystem;
import org.apache.hadoop.hbase.backup.RestoreRequest;
import org.apache.hadoop.hbase.backup.impl.BackupManifest.BackupImage;
+import org.apache.hadoop.hbase.backup.util.BackupUtils;
import org.apache.hadoop.hbase.backup.util.RestoreTool;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
@@ -55,11 +56,12 @@ public class RestoreTablesClient {
private String backupId;
private TableName[] sTableArray;
private TableName[] tTableArray;
- private String targetRootDir;
+ private String backupRootDir;
+ private Path restoreRootDir;
private boolean isOverwrite;
- public RestoreTablesClient(Connection conn, RestoreRequest request) {
- this.targetRootDir = request.getBackupRootDir();
+ public RestoreTablesClient(Connection conn, RestoreRequest request) throws IOException {
+ this.backupRootDir = request.getBackupRootDir();
this.backupId = request.getBackupId();
this.sTableArray = request.getFromTables();
this.tTableArray = request.getToTables();
@@ -69,6 +71,12 @@ public class RestoreTablesClient {
this.isOverwrite = request.isOverwrite();
this.conn = conn;
this.conf = conn.getConfiguration();
+ if (request.getRestoreRootDir() != null) {
+ restoreRootDir = new Path(request.getRestoreRootDir());
+ } else {
+ FileSystem fs = FileSystem.get(conf);
+ this.restoreRootDir = BackupUtils.getTmpRestoreOutputDir(fs, conf);
+ }
}
/**
@@ -131,7 +139,7 @@ public class RestoreTablesClient {
String rootDir = image.getRootDir();
String backupId = image.getBackupId();
Path backupRoot = new Path(rootDir);
- RestoreTool restoreTool = new RestoreTool(conf, backupRoot, backupId);
+ RestoreTool restoreTool = new RestoreTool(conf, backupRoot, restoreRootDir, backupId);
Path tableBackupPath = HBackupFileSystem.getTableBackupPath(sTable, backupRoot, backupId);
String lastIncrBackupId = images.length == 1 ? null : images[images.length - 1].getBackupId();
// We need hFS only for full restore (see the code)
@@ -249,7 +257,7 @@ public class RestoreTablesClient {
// case RESTORE_IMAGES:
HashMap<TableName, BackupManifest> backupManifestMap = new HashMap<>();
// check and load backup image manifest for the tables
- Path rootPath = new Path(targetRootDir);
+ Path rootPath = new Path(backupRootDir);
HBackupFileSystem.checkImageManifestExist(backupManifestMap, sTableArray, conf, rootPath,
backupId);
diff --git a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/mapreduce/MapReduceRestoreJob.java b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/mapreduce/MapReduceRestoreJob.java
index e6046bf5fb9..55f6bff04cb 100644
--- a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/mapreduce/MapReduceRestoreJob.java
+++ b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/mapreduce/MapReduceRestoreJob.java
@@ -50,8 +50,8 @@ public class MapReduceRestoreJob implements RestoreJob {
}
@Override
- public void run(Path[] dirPaths, TableName[] tableNames, TableName[] newTableNames,
- boolean fullBackupRestore) throws IOException {
+ public void run(Path[] dirPaths, TableName[] tableNames, Path restoreRootDir,
+ TableName[] newTableNames, boolean fullBackupRestore) throws IOException {
String bulkOutputConfKey;
player = new MapReduceHFileSplitterJob();
@@ -70,9 +70,8 @@ public class MapReduceRestoreJob implements RestoreJob {
for (int i = 0; i < tableNames.length; i++) {
LOG.info("Restore " + tableNames[i] + " into " + newTableNames[i]);
-
- Path bulkOutputPath = BackupUtils
- .getBulkOutputDir(BackupUtils.getFileNameCompatibleString(newTableNames[i]), getConf());
+ Path bulkOutputPath = BackupUtils.getBulkOutputDir(restoreRootDir,
+ BackupUtils.getFileNameCompatibleString(newTableNames[i]), getConf());
Configuration conf = getConf();
conf.set(bulkOutputConfKey, bulkOutputPath.toString());
String[] playerArgs = { dirs,
diff --git a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/BackupUtils.java b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/BackupUtils.java
index 56cbcc3e10c..5be8eed3952 100644
--- a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/BackupUtils.java
+++ b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/BackupUtils.java
@@ -689,21 +689,38 @@ public final class BackupUtils {
return isValid;
}
- public static Path getBulkOutputDir(String tableName, Configuration conf, boolean deleteOnExit)
- throws IOException {
- FileSystem fs = FileSystem.get(conf);
- String tmp =
- conf.get(HConstants.TEMPORARY_FS_DIRECTORY_KEY, fs.getHomeDirectory() + "/hbase-staging");
- Path path = new Path(tmp + Path.SEPARATOR + "bulk_output-" + tableName + "-"
- + EnvironmentEdgeManager.currentTime());
+ public static Path getBulkOutputDir(Path restoreRootDir, String tableName, Configuration conf,
+ boolean deleteOnExit) throws IOException {
+ FileSystem fs = restoreRootDir.getFileSystem(conf);
+ Path path = new Path(restoreRootDir,
+ "bulk_output-" + tableName + "-" + EnvironmentEdgeManager.currentTime());
if (deleteOnExit) {
fs.deleteOnExit(path);
}
return path;
}
- public static Path getBulkOutputDir(String tableName, Configuration conf) throws IOException {
- return getBulkOutputDir(tableName, conf, true);
+ public static Path getBulkOutputDir(Path restoreRootDir, String tableName, Configuration conf)
+ throws IOException {
+ return getBulkOutputDir(restoreRootDir, tableName, conf, true);
+ }
+
+ public static Path getBulkOutputDir(String tableName, Configuration conf, boolean deleteOnExit)
+ throws IOException {
+ FileSystem fs = FileSystem.get(conf);
+ return getBulkOutputDir(getTmpRestoreOutputDir(fs, conf), tableName, conf, deleteOnExit);
+ }
+
+ /**
+ * Build temporary output path
+ * @param fs filesystem for default output dir
+ * @param conf configuration
+ * @return output path
+ */
+ public static Path getTmpRestoreOutputDir(FileSystem fs, Configuration conf) {
+ String tmp =
+ conf.get(HConstants.TEMPORARY_FS_DIRECTORY_KEY, fs.getHomeDirectory() + "/hbase-staging");
+ return new Path(tmp);
}
public static String getFileNameCompatibleString(TableName table) {
diff --git a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/RestoreTool.java b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/RestoreTool.java
index bf2aa14046d..8ca80d1301f 100644
--- a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/RestoreTool.java
+++ b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/RestoreTool.java
@@ -67,18 +67,20 @@ public class RestoreTool {
private final String[] ignoreDirs = { HConstants.RECOVERED_EDITS_DIR };
protected Configuration conf;
protected Path backupRootPath;
+ protected Path restoreRootDir;
protected String backupId;
protected FileSystem fs;
// store table name and snapshot dir mapping
private final HashMap<TableName, Path> snapshotMap = new HashMap<>();
- public RestoreTool(Configuration conf, final Path backupRootPath, final String backupId)
- throws IOException {
+ public RestoreTool(Configuration conf, final Path backupRootPath, final Path restoreRootDir,
+ final String backupId) throws IOException {
this.conf = conf;
this.backupRootPath = backupRootPath;
this.backupId = backupId;
this.fs = backupRootPath.getFileSystem(conf);
+ this.restoreRootDir = restoreRootDir;
}
/**
@@ -200,7 +202,7 @@ public class RestoreTool {
}
RestoreJob restoreService = BackupRestoreFactory.getRestoreJob(conf);
- restoreService.run(logDirs, tableNames, newTableNames, false);
+ restoreService.run(logDirs, tableNames, restoreRootDir, newTableNames, false);
}
}
@@ -350,8 +352,8 @@ public class RestoreTool {
RestoreJob restoreService = BackupRestoreFactory.getRestoreJob(conf);
Path[] paths = new Path[regionPathList.size()];
regionPathList.toArray(paths);
- restoreService.run(paths, new TableName[] { tableName }, new TableName[] { newTableName },
- true);
+ restoreService.run(paths, new TableName[] { tableName }, restoreRootDir,
+ new TableName[] { newTableName }, true);
} catch (Exception e) {
LOG.error(e.toString(), e);
diff --git a/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestRemoteRestore.java b/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestRemoteRestore.java
index f2e2b612b2c..53ef8955df3 100644
--- a/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestRemoteRestore.java
+++ b/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestRemoteRestore.java
@@ -17,13 +17,21 @@
*/
package org.apache.hadoop.hbase.backup;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.backup.impl.BackupAdminImpl;
+import org.apache.hadoop.hbase.backup.mapreduce.MapReduceHFileSplitterJob;
import org.apache.hadoop.hbase.backup.util.BackupUtils;
import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.junit.BeforeClass;
import org.junit.ClassRule;
@@ -72,4 +80,51 @@ public class TestRemoteRestore extends TestBackupBase {
TEST_UTIL.deleteTable(table1_restore);
hba.close();
}
+
+ /**
+ * Verify that restore jobs can be run on a standalone mapreduce cluster. Ensures hfiles output
+ * via {@link MapReduceHFileSplitterJob} exist on correct filesystem.
+ * @throws Exception if doing the backup or an operation on the tables fails
+ */
+ @Test
+ public void testFullRestoreRemoteWithAlternateRestoreOutputDir() throws Exception {
+ LOG.info("test remote full backup on a single table with alternate restore output dir");
+ String backupId =
+ backupTables(BackupType.FULL, toList(table1.getNameAsString()), BACKUP_REMOTE_ROOT_DIR);
+ LOG.info("backup complete");
+ TableName[] tableset = new TableName[] { table1 };
+ TableName[] tablemap = new TableName[] { table1_restore };
+
+ HBaseTestingUtility mrTestUtil = new HBaseTestingUtility();
+ mrTestUtil.setZkCluster(TEST_UTIL.getZkCluster());
+ mrTestUtil.startMiniDFSCluster(3);
+ mrTestUtil.startMiniMapReduceCluster();
+
+ Configuration testUtilConf = TEST_UTIL.getConnection().getConfiguration();
+ Configuration conf = new Configuration(mrTestUtil.getConfiguration());
+ conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT,
+ testUtilConf.get(HConstants.ZOOKEEPER_ZNODE_PARENT));
+ conf.set(HConstants.MASTER_ADDRS_KEY, testUtilConf.get(HConstants.MASTER_ADDRS_KEY));
+
+ new BackupAdminImpl(ConnectionFactory.createConnection(conf))
+ .restore(new RestoreRequest.Builder().withBackupRootDir(BACKUP_REMOTE_ROOT_DIR)
+ .withRestoreRootDir(BACKUP_ROOT_DIR).withBackupId(backupId).withCheck(false)
+ .withFromTables(tableset).withToTables(tablemap).withOvewrite(false).build());
+
+ Path hfileOutputPath = new Path(
+ new Path(conf.get(MapReduceHFileSplitterJob.BULK_OUTPUT_CONF_KEY)).toUri().getPath());
+
+ // files exist on hbase cluster
+ FileSystem fileSystem = FileSystem.get(TEST_UTIL.getConfiguration());
+ assertTrue(fileSystem.exists(hfileOutputPath));
+
+ // files don't exist on MR cluster
+ fileSystem = FileSystem.get(conf);
+ assertFalse(fileSystem.exists(hfileOutputPath));
+
+ Admin hba = TEST_UTIL.getAdmin();
+ assertTrue(hba.tableExists(table1_restore));
+ TEST_UTIL.deleteTable(table1_restore);
+ hba.close();
+ }
}