You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by te...@apache.org on 2016/06/02 22:19:22 UTC

hbase git commit: HBASE-15899 HBase incremental restore should handle namespaces properly (Vladimir)

Repository: hbase
Updated Branches:
  refs/heads/HBASE-7912 e97e7bdca -> c51700180


HBASE-15899 HBase incremental restore should handle namespaces properly (Vladimir)


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

Branch: refs/heads/HBASE-7912
Commit: c5170018096921e373596b103cc97e9e0d94fd32
Parents: e97e7bd
Author: tedyu <yu...@gmail.com>
Authored: Thu Jun 2 15:19:13 2016 -0700
Committer: tedyu <yu...@gmail.com>
Committed: Thu Jun 2 15:19:13 2016 -0700

----------------------------------------------------------------------
 .../mapreduce/MapReduceRestoreService.java      |  8 ++++--
 .../hadoop/hbase/backup/TestBackupBase.java     | 30 ++++++++++++++------
 2 files changed, 28 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/c5170018/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/mapreduce/MapReduceRestoreService.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/mapreduce/MapReduceRestoreService.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/mapreduce/MapReduceRestoreService.java
index 7c10d3c..fa08adf 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/mapreduce/MapReduceRestoreService.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/mapreduce/MapReduceRestoreService.java
@@ -60,7 +60,7 @@ public class MapReduceRestoreService implements IncrementalRestoreService {
       
       LOG.info("Restore "+ tableNames[i] + " into "+ newTableNames[i]);
       
-      Path bulkOutputPath = getBulkOutputDir(newTableNames[i].getNameAsString());
+      Path bulkOutputPath = getBulkOutputDir(getFileNameCompatibleString(newTableNames[i]));
       String[] playerArgs =
           { logDirs, tableNames[i].getNameAsString(), newTableNames[i].getNameAsString()};
 
@@ -96,7 +96,11 @@ public class MapReduceRestoreService implements IncrementalRestoreService {
     }
   }
 
-
+  private String getFileNameCompatibleString(TableName table)
+  {
+    return table.getNamespaceAsString() +"-"+ table.getQualifierAsString();
+  }
+  
   private boolean failed(int result) {
     return result != 0;
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/c5170018/hbase-server/src/test/java/org/apache/hadoop/hbase/backup/TestBackupBase.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/backup/TestBackupBase.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/backup/TestBackupBase.java
index 3678df2..9683e16 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/backup/TestBackupBase.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/backup/TestBackupBase.java
@@ -35,6 +35,7 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.NamespaceDescriptor;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.backup.BackupInfo.BackupState;
 import org.apache.hadoop.hbase.backup.impl.BackupSystemTable;
@@ -71,10 +72,10 @@ public class TestBackupBase {
   protected static TableName table3 = TableName.valueOf("table3");
   protected static TableName table4 = TableName.valueOf("table4");
 
-  protected static TableName table1_restore = TableName.valueOf("table1_restore");
-  protected static TableName table2_restore = TableName.valueOf("table2_restore");
-  protected static TableName table3_restore = TableName.valueOf("table3_restore");
-  protected static TableName table4_restore = TableName.valueOf("table4_restore");
+  protected static TableName table1_restore = TableName.valueOf("ns1:table1_restore");
+  protected static TableName table2_restore = TableName.valueOf("ns2:table2_restore");
+  protected static TableName table3_restore = TableName.valueOf("ns3:table3_restore");
+  protected static TableName table4_restore = TableName.valueOf("ns4:table4_restore");
 
   protected static final int NB_ROWS_IN_BATCH = 999;
   protected static final byte[] qualName = Bytes.toBytes("q1");
@@ -189,8 +190,21 @@ public class TestBackupBase {
   protected static void createTables() throws Exception {
 
     long tid = System.currentTimeMillis();
-    table1 = TableName.valueOf("test-" + tid);
+    table1 = TableName.valueOf("ns1:test-" + tid);
     HBaseAdmin ha = TEST_UTIL.getHBaseAdmin();
+    
+    // Create namespaces
+    NamespaceDescriptor desc1 = NamespaceDescriptor.create("ns1").build();
+    NamespaceDescriptor desc2 = NamespaceDescriptor.create("ns2").build();
+    NamespaceDescriptor desc3 = NamespaceDescriptor.create("ns3").build();
+    NamespaceDescriptor desc4 = NamespaceDescriptor.create("ns4").build();
+    
+    ha.createNamespace(desc1);
+    ha.createNamespace(desc2);
+    ha.createNamespace(desc3);
+    ha.createNamespace(desc4);
+
+    
     HTableDescriptor desc = new HTableDescriptor(table1);
     HColumnDescriptor fam = new HColumnDescriptor(famName);
     desc.addFamily(fam);
@@ -199,17 +213,17 @@ public class TestBackupBase {
     HTable table = (HTable) conn.getTable(table1);
     loadTable(table);
     table.close();
-    table2 = TableName.valueOf("test-" + tid + 1);
+    table2 = TableName.valueOf("ns2:test-" + tid + 1);
     desc = new HTableDescriptor(table2);
     desc.addFamily(fam);
     ha.createTable(desc);
     table = (HTable) conn.getTable(table2);
     loadTable(table);
     table.close();
-    table3 = TableName.valueOf("test-" + tid + 2);
+    table3 = TableName.valueOf("ns3:test-" + tid + 2);
     table = TEST_UTIL.createTable(table3, famName);
     table.close();
-    table4 = TableName.valueOf("test-" + tid + 3);
+    table4 = TableName.valueOf("ns4:test-" + tid + 3);
     table = TEST_UTIL.createTable(table4, famName);
     table.close();
     ha.close();