HBASE-20530 Composition of backup directory containing namespace when restoring is different from the actual hfile location
Signed-off-by: tedyu <yuzhihong@gmail.com>
This commit is contained in:
parent
f4006b5039
commit
acbc3a2253
@ -88,8 +88,8 @@ public class TestBackupBase {
|
|||||||
protected static TableName table3 = TableName.valueOf("table3");
|
protected static TableName table3 = TableName.valueOf("table3");
|
||||||
protected static TableName table4 = TableName.valueOf("table4");
|
protected static TableName table4 = TableName.valueOf("table4");
|
||||||
|
|
||||||
protected static TableName table1_restore = TableName.valueOf("ns1:table1_restore");
|
protected static TableName table1_restore = TableName.valueOf("default:table1");
|
||||||
protected static TableName table2_restore = TableName.valueOf("ns2:table2_restore");
|
protected static TableName table2_restore = TableName.valueOf("ns2:table2");
|
||||||
protected static TableName table3_restore = TableName.valueOf("ns3:table3_restore");
|
protected static TableName table3_restore = TableName.valueOf("ns3:table3_restore");
|
||||||
protected static TableName table4_restore = TableName.valueOf("ns4:table4_restore");
|
protected static TableName table4_restore = TableName.valueOf("ns4:table4_restore");
|
||||||
|
|
||||||
@ -404,7 +404,7 @@ public class TestBackupBase {
|
|||||||
|
|
||||||
protected static void createTables() throws Exception {
|
protected static void createTables() throws Exception {
|
||||||
long tid = System.currentTimeMillis();
|
long tid = System.currentTimeMillis();
|
||||||
table1 = TableName.valueOf("ns1:test-" + tid);
|
table1 = TableName.valueOf("test-" + tid);
|
||||||
HBaseAdmin ha = TEST_UTIL.getHBaseAdmin();
|
HBaseAdmin ha = TEST_UTIL.getHBaseAdmin();
|
||||||
|
|
||||||
// Create namespaces
|
// Create namespaces
|
||||||
|
@ -163,14 +163,14 @@ public class TestIncrementalBackup extends TestBackupBase {
|
|||||||
String backupIdIncMultiple2 = client.backupTables(request);
|
String backupIdIncMultiple2 = client.backupTables(request);
|
||||||
assertTrue(checkSucceeded(backupIdIncMultiple2));
|
assertTrue(checkSucceeded(backupIdIncMultiple2));
|
||||||
|
|
||||||
// #4 - restore full backup for all tables, without overwrite
|
// #4 - restore full backup for all tables
|
||||||
TableName[] tablesRestoreFull = new TableName[] { table1, table2 };
|
TableName[] tablesRestoreFull = new TableName[] { table1, table2 };
|
||||||
|
|
||||||
TableName[] tablesMapFull = new TableName[] { table1_restore, table2_restore };
|
TableName[] tablesMapFull = new TableName[] { table1_restore, table2_restore };
|
||||||
|
|
||||||
LOG.debug("Restoring full " + backupIdFull);
|
LOG.debug("Restoring full " + backupIdFull);
|
||||||
client.restore(BackupUtils.createRestoreRequest(BACKUP_ROOT_DIR, backupIdFull, false,
|
client.restore(BackupUtils.createRestoreRequest(BACKUP_ROOT_DIR, backupIdFull, false,
|
||||||
tablesRestoreFull, tablesMapFull, false));
|
tablesRestoreFull, tablesMapFull, true));
|
||||||
|
|
||||||
// #5.1 - check tables for full restore
|
// #5.1 - check tables for full restore
|
||||||
HBaseAdmin hAdmin = TEST_UTIL.getHBaseAdmin();
|
HBaseAdmin hAdmin = TEST_UTIL.getHBaseAdmin();
|
||||||
|
@ -27,6 +27,7 @@ import java.io.UnsupportedEncodingException;
|
|||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -251,6 +252,9 @@ public class HFileOutputFormat2
|
|||||||
byte[] tableNameBytes = null;
|
byte[] tableNameBytes = null;
|
||||||
if (writeMultipleTables) {
|
if (writeMultipleTables) {
|
||||||
tableNameBytes = MultiTableHFileOutputFormat.getTableName(row.get());
|
tableNameBytes = MultiTableHFileOutputFormat.getTableName(row.get());
|
||||||
|
tableNameBytes =
|
||||||
|
TableName.valueOf(tableNameBytes).getNameWithNamespaceInclAsString()
|
||||||
|
.getBytes(Charset.defaultCharset());
|
||||||
if (!allTableNames.contains(Bytes.toString(tableNameBytes))) {
|
if (!allTableNames.contains(Bytes.toString(tableNameBytes))) {
|
||||||
throw new IllegalArgumentException("TableName '" + Bytes.toString(tableNameBytes) +
|
throw new IllegalArgumentException("TableName '" + Bytes.toString(tableNameBytes) +
|
||||||
"' not" + " expected");
|
"' not" + " expected");
|
||||||
@ -639,7 +643,10 @@ public class HFileOutputFormat2
|
|||||||
for( TableInfo tableInfo : multiTableInfo )
|
for( TableInfo tableInfo : multiTableInfo )
|
||||||
{
|
{
|
||||||
regionLocators.add(tableInfo.getRegionLocator());
|
regionLocators.add(tableInfo.getRegionLocator());
|
||||||
allTableNames.add(tableInfo.getRegionLocator().getName().getNameAsString());
|
String tn = writeMultipleTables?
|
||||||
|
tableInfo.getRegionLocator().getName().getNameWithNamespaceInclAsString():
|
||||||
|
tableInfo.getRegionLocator().getName().getNameAsString();
|
||||||
|
allTableNames.add(tn);
|
||||||
tableDescriptors.add(tableInfo.getTableDescriptor());
|
tableDescriptors.add(tableInfo.getTableDescriptor());
|
||||||
}
|
}
|
||||||
// Record tablenames for creating writer by favored nodes, and decoding compression, block size and other attributes of columnfamily per table
|
// Record tablenames for creating writer by favored nodes, and decoding compression, block size and other attributes of columnfamily per table
|
||||||
|
@ -627,15 +627,19 @@ public class TestHFileOutputFormat2 {
|
|||||||
Path testDir = util.getDataTestDirOnTestFS("testLocalMRIncrementalLoad");
|
Path testDir = util.getDataTestDirOnTestFS("testLocalMRIncrementalLoad");
|
||||||
// Generate the bulk load files
|
// Generate the bulk load files
|
||||||
runIncrementalPELoad(conf, tableInfo, testDir, putSortReducer);
|
runIncrementalPELoad(conf, tableInfo, testDir, putSortReducer);
|
||||||
|
if (writeMultipleTables) {
|
||||||
|
testDir = new Path(testDir, "default");
|
||||||
|
}
|
||||||
|
|
||||||
for (Table tableSingle : allTables.values()) {
|
for (Table tableSingle : allTables.values()) {
|
||||||
// This doesn't write into the table, just makes files
|
// This doesn't write into the table, just makes files
|
||||||
assertEquals("HFOF should not touch actual table", 0, util.countRows(tableSingle));
|
assertEquals("HFOF should not touch actual table", 0, util.countRows(tableSingle));
|
||||||
}
|
}
|
||||||
int numTableDirs = 0;
|
int numTableDirs = 0;
|
||||||
for (FileStatus tf : testDir.getFileSystem(conf).listStatus(testDir)) {
|
FileStatus[] fss =
|
||||||
|
testDir.getFileSystem(conf).listStatus(testDir);
|
||||||
|
for (FileStatus tf: fss) {
|
||||||
Path tablePath = testDir;
|
Path tablePath = testDir;
|
||||||
|
|
||||||
if (writeMultipleTables) {
|
if (writeMultipleTables) {
|
||||||
if (allTables.containsKey(tf.getPath().getName())) {
|
if (allTables.containsKey(tf.getPath().getName())) {
|
||||||
++numTableDirs;
|
++numTableDirs;
|
||||||
@ -648,7 +652,8 @@ public class TestHFileOutputFormat2 {
|
|||||||
|
|
||||||
// Make sure that a directory was created for every CF
|
// Make sure that a directory was created for every CF
|
||||||
int dir = 0;
|
int dir = 0;
|
||||||
for (FileStatus f : tablePath.getFileSystem(conf).listStatus(tablePath)) {
|
fss = tablePath.getFileSystem(conf).listStatus(tablePath);
|
||||||
|
for (FileStatus f: fss) {
|
||||||
for (byte[] family : FAMILIES) {
|
for (byte[] family : FAMILIES) {
|
||||||
if (Bytes.toString(family).equals(f.getPath().getName())) {
|
if (Bytes.toString(family).equals(f.getPath().getName())) {
|
||||||
++dir;
|
++dir;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user