Repository: hbase
Updated Branches:
  refs/heads/0.96 c3af2d25c -> c6abf4f0a


HBASE-11335 Fix the TABLE_DIR param in TableSnapshotInputFormat (deepankar)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/c6abf4f0
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/c6abf4f0
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/c6abf4f0

Branch: refs/heads/0.96
Commit: c6abf4f0a93a447bc8d0b4c926f7bba523069cad
Parents: c3af2d2
Author: Enis Soztutar <e...@apache.org>
Authored: Mon Jun 30 15:01:19 2014 -0700
Committer: Enis Soztutar <e...@apache.org>
Committed: Mon Jun 30 15:01:19 2014 -0700

----------------------------------------------------------------------
 .../hbase/mapreduce/TableSnapshotInputFormat.java       | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/c6abf4f0/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableSnapshotInputFormat.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableSnapshotInputFormat.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableSnapshotInputFormat.java
index 482d466..a60aab7 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableSnapshotInputFormat.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableSnapshotInputFormat.java
@@ -60,6 +60,7 @@ import 
org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils;
 import org.apache.hadoop.hbase.snapshot.SnapshotReferenceUtil;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.FSTableDescriptors;
+import org.apache.hadoop.hbase.util.FSUtils;
 import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.mapreduce.InputFormat;
 import org.apache.hadoop.mapreduce.InputSplit;
@@ -121,7 +122,8 @@ public class TableSnapshotInputFormat extends 
InputFormat<ImmutableBytesWritable
   private static final float DEFAULT_LOCALITY_CUTOFF_MULTIPLIER = 0.8f;
 
   private static final String SNAPSHOT_NAME_KEY = 
"hbase.TableSnapshotInputFormat.snapshot.name";
-  private static final String TABLE_DIR_KEY = 
"hbase.TableSnapshotInputFormat.table.dir";
+  // key for specifying the root dir of the restored snapshot
+  private static final String RESTORE_DIR_KEY = 
"hbase.TableSnapshotInputFormat.restore.dir";
 
   public static class TableSnapshotRegionSplit extends InputSplit implements 
Writable {
     private String regionName;
@@ -205,7 +207,7 @@ public class TableSnapshotInputFormat extends 
InputFormat<ImmutableBytesWritable
       Path rootDir = new Path(conf.get(HConstants.HBASE_DIR));
       FileSystem fs = rootDir.getFileSystem(conf);
 
-      Path tmpRootDir = new Path(conf.get(TABLE_DIR_KEY)); // This is the user 
specified root
+      Path tmpRootDir = new Path(conf.get(RESTORE_DIR_KEY)); // This is the 
user specified root
       // directory where snapshot was restored
 
       Path snapshotDir = 
SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, rootDir);
@@ -306,7 +308,9 @@ public class TableSnapshotInputFormat extends 
InputFormat<ImmutableBytesWritable
 
     Scan scan = TableMapReduceUtil.convertStringToScan(conf
       .get(TableInputFormat.SCAN));
-    Path tableDir = new Path(conf.get(TABLE_DIR_KEY));
+    // the temp dir where the snapshot is restored
+    Path restoreDir = new Path(conf.get(RESTORE_DIR_KEY));
+    Path tableDir = FSUtils.getTableDir(restoreDir, htd.getTableName());
 
     List<InputSplit> splits = new ArrayList<InputSplit>();
     for (String regionName : snapshotRegionNames) {
@@ -393,7 +397,7 @@ public class TableSnapshotInputFormat extends 
InputFormat<ImmutableBytesWritable
     // TODO: restore from record readers to parallelize.
     RestoreSnapshotHelper.copySnapshotForScanner(conf, fs, rootDir, 
restoreDir, snapshotName);
 
-    conf.set(TABLE_DIR_KEY, restoreDir.toString());
+    conf.set(RESTORE_DIR_KEY, restoreDir.toString());
   }
 
   private static String getSnapshotName(Configuration conf) {

Reply via email to