HBASE-14578 URISyntaxException during snapshot restore for table with user defined namespace (Pankaj Kumar)

This commit is contained in:
tedyu 2015-10-10 01:50:56 -07:00
parent 4969879df5
commit f135912912
5 changed files with 30 additions and 18 deletions

View File

@ -682,9 +682,10 @@ public class RestoreSnapshotHelper {
String hfileName = storeFile.getName(); String hfileName = storeFile.getName();
// Extract the referred information (hfile name and parent region) // Extract the referred information (hfile name and parent region)
Path refPath = StoreFileInfo.getReferredToFile(new Path(new Path(new Path( Path refPath =
snapshotTable.getNameAsString(), regionInfo.getEncodedName()), familyDir.getName()), StoreFileInfo.getReferredToFile(new Path(new Path(new Path(new Path(snapshotTable
hfileName)); .getNamespaceAsString(), snapshotTable.getQualifierAsString()), regionInfo
.getEncodedName()), familyDir.getName()), hfileName));
String snapshotRegionName = refPath.getParent().getParent().getName(); String snapshotRegionName = refPath.getParent().getParent().getName();
String fileName = refPath.getName(); String fileName = refPath.getName();

View File

@ -208,7 +208,7 @@ public class TestSnapshotFileCache {
private SnapshotMock.SnapshotBuilder createAndTestSnapshotV1(final SnapshotFileCache cache, private SnapshotMock.SnapshotBuilder createAndTestSnapshotV1(final SnapshotFileCache cache,
final String name, final boolean tmp, final boolean removeOnExit) throws IOException { final String name, final boolean tmp, final boolean removeOnExit) throws IOException {
SnapshotMock snapshotMock = new SnapshotMock(UTIL.getConfiguration(), fs, rootDir); SnapshotMock snapshotMock = new SnapshotMock(UTIL.getConfiguration(), fs, rootDir);
SnapshotMock.SnapshotBuilder builder = snapshotMock.createSnapshotV1(name); SnapshotMock.SnapshotBuilder builder = snapshotMock.createSnapshotV1(name, name);
createAndTestSnapshot(cache, builder, tmp, removeOnExit); createAndTestSnapshot(cache, builder, tmp, removeOnExit);
return builder; return builder;
} }
@ -216,7 +216,7 @@ public class TestSnapshotFileCache {
private void createAndTestSnapshotV2(final SnapshotFileCache cache, final String name, private void createAndTestSnapshotV2(final SnapshotFileCache cache, final String name,
final boolean tmp, final boolean removeOnExit) throws IOException { final boolean tmp, final boolean removeOnExit) throws IOException {
SnapshotMock snapshotMock = new SnapshotMock(UTIL.getConfiguration(), fs, rootDir); SnapshotMock snapshotMock = new SnapshotMock(UTIL.getConfiguration(), fs, rootDir);
SnapshotMock.SnapshotBuilder builder = snapshotMock.createSnapshotV2(name); SnapshotMock.SnapshotBuilder builder = snapshotMock.createSnapshotV2(name, name);
createAndTestSnapshot(cache, builder, tmp, removeOnExit); createAndTestSnapshot(cache, builder, tmp, removeOnExit);
} }

View File

@ -550,18 +550,19 @@ public class SnapshotTestingUtils {
this.rootDir = rootDir; this.rootDir = rootDir;
} }
public SnapshotBuilder createSnapshotV1(final String snapshotName) throws IOException { public SnapshotBuilder createSnapshotV1(final String snapshotName, final String tableName)
return createSnapshot(snapshotName, SnapshotManifestV1.DESCRIPTOR_VERSION);
}
public SnapshotBuilder createSnapshotV2(final String snapshotName) throws IOException {
return createSnapshot(snapshotName, SnapshotManifestV2.DESCRIPTOR_VERSION);
}
private SnapshotBuilder createSnapshot(final String snapshotName, final int version)
throws IOException { throws IOException {
HTableDescriptor htd = createHtd(snapshotName); return createSnapshot(snapshotName, tableName, SnapshotManifestV1.DESCRIPTOR_VERSION);
}
public SnapshotBuilder createSnapshotV2(final String snapshotName, final String tableName)
throws IOException {
return createSnapshot(snapshotName, tableName, SnapshotManifestV2.DESCRIPTOR_VERSION);
}
private SnapshotBuilder createSnapshot(final String snapshotName, final String tableName,
final int version) throws IOException {
HTableDescriptor htd = createHtd(tableName);
RegionData[] regions = createTable(htd, TEST_NUM_REGIONS); RegionData[] regions = createTable(htd, TEST_NUM_REGIONS);
SnapshotDescription desc = SnapshotDescription.newBuilder() SnapshotDescription desc = SnapshotDescription.newBuilder()

View File

@ -235,11 +235,12 @@ public class TestExportSnapshot {
FileSystem fs = TEST_UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getFileSystem(); FileSystem fs = TEST_UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getFileSystem();
SnapshotMock snapshotMock = new SnapshotMock(TEST_UTIL.getConfiguration(), fs, rootDir); SnapshotMock snapshotMock = new SnapshotMock(TEST_UTIL.getConfiguration(), fs, rootDir);
SnapshotMock.SnapshotBuilder builder = snapshotMock.createSnapshotV2("tableWithRefsV1"); SnapshotMock.SnapshotBuilder builder = snapshotMock.createSnapshotV2("tableWithRefsV1",
"tableWithRefsV1");
testSnapshotWithRefsExportFileSystemState(builder); testSnapshotWithRefsExportFileSystemState(builder);
snapshotMock = new SnapshotMock(TEST_UTIL.getConfiguration(), fs, rootDir); snapshotMock = new SnapshotMock(TEST_UTIL.getConfiguration(), fs, rootDir);
builder = snapshotMock.createSnapshotV2("tableWithRefsV2"); builder = snapshotMock.createSnapshotV2("tableWithRefsV2", "tableWithRefsV2");
testSnapshotWithRefsExportFileSystemState(builder); testSnapshotWithRefsExportFileSystemState(builder);
} }

View File

@ -85,10 +85,19 @@ public class TestRestoreSnapshotHelper {
@Test @Test
public void testRestore() throws IOException { public void testRestore() throws IOException {
restoreAndVerify("snapshot", "testRestore");
}
@Test
public void testRestoreWithNamespace() throws IOException {
restoreAndVerify("snapshot", "namespace1:testRestoreWithNamespace");
}
private void restoreAndVerify(final String snapshotName, final String tableName) throws IOException {
// Test Rolling-Upgrade like Snapshot. // Test Rolling-Upgrade like Snapshot.
// half machines writing using v1 and the others using v2 format. // half machines writing using v1 and the others using v2 format.
SnapshotMock snapshotMock = createSnapshotMock(); SnapshotMock snapshotMock = createSnapshotMock();
SnapshotMock.SnapshotBuilder builder = snapshotMock.createSnapshotV2("snapshot"); SnapshotMock.SnapshotBuilder builder = snapshotMock.createSnapshotV2("snapshot", tableName);
builder.addRegionV1(); builder.addRegionV1();
builder.addRegionV2(); builder.addRegionV2();
builder.addRegionV2(); builder.addRegionV2();