From d17ecb48318d1bf57a3006ed7d97c809f6818708 Mon Sep 17 00:00:00 2001 From: meiyi Date: Fri, 12 Oct 2018 15:19:22 +0800 Subject: [PATCH] HBASE-21300 Fix the wrong reference file path when restoring snapshots for tables with MOB columns --- .../main/java/org/apache/hadoop/hbase/mob/MobUtils.java | 14 +++++++++++++- .../hadoop/hbase/snapshot/RestoreSnapshotHelper.java | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mob/MobUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mob/MobUtils.java index 9fa4e4c..141b68d 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mob/MobUtils.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mob/MobUtils.java @@ -391,7 +391,19 @@ public final class MobUtils { * @return The region dir of the mob files. */ public static Path getMobRegionPath(Configuration conf, TableName tableName) { - Path tablePath = FSUtils.getTableDir(getMobHome(conf), tableName); + return getMobRegionPath(new Path(conf.get(HConstants.HBASE_DIR)), tableName); + } + + /** + * Gets the region dir of the mob files under the specified root dir. + * {rootDir}/mobdir/{namespace}/{tableName}/{regionEncodedName}. + * @param rootDir The root dir. + * @param tableName The current table name. + * @return The region dir of the mob files. + */ + public static Path getMobRegionPath(Path rootDir, TableName tableName) { + Path mobHome = new Path(rootDir, MobConstants.MOB_DIR_NAME); + Path tablePath = FSUtils.getTableDir(mobHome, tableName); RegionInfo regionInfo = getMobRegionInfo(tableName); return new Path(tablePath, regionInfo.getEncodedName()); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/RestoreSnapshotHelper.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/RestoreSnapshotHelper.java index 7edf734..b3bd2ff 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/RestoreSnapshotHelper.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/RestoreSnapshotHelper.java @@ -621,7 +621,7 @@ public class RestoreSnapshotHelper { private void cloneHdfsMobRegion(final Map regionManifests, final RegionInfo region) throws IOException { // clone region info (change embedded tableName with the new one) - Path clonedRegionPath = MobUtils.getMobRegionPath(conf, tableDesc.getTableName()); + Path clonedRegionPath = MobUtils.getMobRegionPath(rootDir, tableDesc.getTableName()); cloneRegion(clonedRegionPath, region, regionManifests.get(region.getEncodedName())); } -- 2.7.4