HBASE-14578 URISyntaxException during snapshot restore for table with user defined namespace (Pankaj Kumar)
This commit is contained in:
parent
4969879df5
commit
f135912912
|
@ -682,9 +682,10 @@ public class RestoreSnapshotHelper {
|
|||
String hfileName = storeFile.getName();
|
||||
|
||||
// Extract the referred information (hfile name and parent region)
|
||||
Path refPath = StoreFileInfo.getReferredToFile(new Path(new Path(new Path(
|
||||
snapshotTable.getNameAsString(), regionInfo.getEncodedName()), familyDir.getName()),
|
||||
hfileName));
|
||||
Path refPath =
|
||||
StoreFileInfo.getReferredToFile(new Path(new Path(new Path(new Path(snapshotTable
|
||||
.getNamespaceAsString(), snapshotTable.getQualifierAsString()), regionInfo
|
||||
.getEncodedName()), familyDir.getName()), hfileName));
|
||||
String snapshotRegionName = refPath.getParent().getParent().getName();
|
||||
String fileName = refPath.getName();
|
||||
|
||||
|
|
|
@ -208,7 +208,7 @@ public class TestSnapshotFileCache {
|
|||
private SnapshotMock.SnapshotBuilder createAndTestSnapshotV1(final SnapshotFileCache cache,
|
||||
final String name, final boolean tmp, final boolean removeOnExit) throws IOException {
|
||||
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);
|
||||
return builder;
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ public class TestSnapshotFileCache {
|
|||
private void createAndTestSnapshotV2(final SnapshotFileCache cache, final String name,
|
||||
final boolean tmp, final boolean removeOnExit) throws IOException {
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -550,18 +550,19 @@ public class SnapshotTestingUtils {
|
|||
this.rootDir = rootDir;
|
||||
}
|
||||
|
||||
public SnapshotBuilder createSnapshotV1(final String snapshotName) throws IOException {
|
||||
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)
|
||||
public SnapshotBuilder createSnapshotV1(final String snapshotName, final String tableName)
|
||||
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);
|
||||
|
||||
SnapshotDescription desc = SnapshotDescription.newBuilder()
|
||||
|
|
|
@ -235,11 +235,12 @@ public class TestExportSnapshot {
|
|||
FileSystem fs = TEST_UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getFileSystem();
|
||||
|
||||
SnapshotMock snapshotMock = new SnapshotMock(TEST_UTIL.getConfiguration(), fs, rootDir);
|
||||
SnapshotMock.SnapshotBuilder builder = snapshotMock.createSnapshotV2("tableWithRefsV1");
|
||||
SnapshotMock.SnapshotBuilder builder = snapshotMock.createSnapshotV2("tableWithRefsV1",
|
||||
"tableWithRefsV1");
|
||||
testSnapshotWithRefsExportFileSystemState(builder);
|
||||
|
||||
snapshotMock = new SnapshotMock(TEST_UTIL.getConfiguration(), fs, rootDir);
|
||||
builder = snapshotMock.createSnapshotV2("tableWithRefsV2");
|
||||
builder = snapshotMock.createSnapshotV2("tableWithRefsV2", "tableWithRefsV2");
|
||||
testSnapshotWithRefsExportFileSystemState(builder);
|
||||
}
|
||||
|
||||
|
|
|
@ -85,10 +85,19 @@ public class TestRestoreSnapshotHelper {
|
|||
|
||||
@Test
|
||||
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.
|
||||
// half machines writing using v1 and the others using v2 format.
|
||||
SnapshotMock snapshotMock = createSnapshotMock();
|
||||
SnapshotMock.SnapshotBuilder builder = snapshotMock.createSnapshotV2("snapshot");
|
||||
SnapshotMock.SnapshotBuilder builder = snapshotMock.createSnapshotV2("snapshot", tableName);
|
||||
builder.addRegionV1();
|
||||
builder.addRegionV2();
|
||||
builder.addRegionV2();
|
||||
|
|
Loading…
Reference in New Issue