HBASE-10762 clone_snapshot doesn't check for missing namespace (Matteo Bertozzi)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1577956 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7be181e455
commit
26f20dca6a
|
@ -3034,6 +3034,14 @@ MasterServices, Server {
|
||||||
throw new ServiceException(e);
|
throw new ServiceException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ensure namespace exists
|
||||||
|
try {
|
||||||
|
TableName dstTable = TableName.valueOf(request.getSnapshot().getTable());
|
||||||
|
getNamespaceDescriptor(dstTable.getNamespaceAsString());
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
throw new ServiceException(ioe);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SnapshotDescription reqSnapshot = request.getSnapshot();
|
SnapshotDescription reqSnapshot = request.getSnapshot();
|
||||||
snapshotManager.restoreSnapshot(reqSnapshot);
|
snapshotManager.restoreSnapshot(reqSnapshot);
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.hadoop.hbase.HConstants;
|
||||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||||
import org.apache.hadoop.hbase.LargeTests;
|
import org.apache.hadoop.hbase.LargeTests;
|
||||||
import org.apache.hadoop.hbase.NamespaceDescriptor;
|
import org.apache.hadoop.hbase.NamespaceDescriptor;
|
||||||
|
import org.apache.hadoop.hbase.NamespaceNotFoundException;
|
||||||
import org.apache.hadoop.hbase.TableName;
|
import org.apache.hadoop.hbase.TableName;
|
||||||
import org.apache.hadoop.hbase.master.MasterFileSystem;
|
import org.apache.hadoop.hbase.master.MasterFileSystem;
|
||||||
import org.apache.hadoop.hbase.master.snapshot.SnapshotManager;
|
import org.apache.hadoop.hbase.master.snapshot.SnapshotManager;
|
||||||
|
@ -147,6 +148,12 @@ public class TestCloneSnapshotFromClient {
|
||||||
admin.cloneSnapshot(snapshotName, tableName);
|
admin.cloneSnapshot(snapshotName, tableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected = NamespaceNotFoundException.class)
|
||||||
|
public void testCloneOnMissingNamespace() throws IOException, InterruptedException {
|
||||||
|
TableName clonedTableName = TableName.valueOf("unknownNS:clonetb");
|
||||||
|
admin.cloneSnapshot(snapshotName1, clonedTableName);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCloneSnapshot() throws IOException, InterruptedException {
|
public void testCloneSnapshot() throws IOException, InterruptedException {
|
||||||
TableName clonedTableName = TableName.valueOf("clonedtb-" + System.currentTimeMillis());
|
TableName clonedTableName = TableName.valueOf("clonedtb-" + System.currentTimeMillis());
|
||||||
|
|
Loading…
Reference in New Issue