HBASE-7480 Explicit message for not allowed snapshot on meta tables (Matteo Bertozzi)
git-svn-id: https://svn.apache.org/repos/asf/hbase/branches/hbase-7290@1445839 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
65d764e979
commit
0dd232a66b
|
@ -132,6 +132,10 @@ public class SnapshotDescriptionUtils {
|
||||||
public static void assertSnapshotRequestIsValid(SnapshotDescription snapshot)
|
public static void assertSnapshotRequestIsValid(SnapshotDescription snapshot)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
// FIXME these method names is really bad - trunk will probably change
|
// FIXME these method names is really bad - trunk will probably change
|
||||||
|
// .META. and -ROOT- snapshots are not allowed
|
||||||
|
if (HTableDescriptor.isMetaTable(Bytes.toBytes(snapshot.getTable()))) {
|
||||||
|
throw new IllegalArgumentException(".META. and -ROOT- snapshots are not allowed");
|
||||||
|
}
|
||||||
// make sure the snapshot name is valid
|
// make sure the snapshot name is valid
|
||||||
HTableDescriptor.isLegalTableName(Bytes.toBytes(snapshot.getName()));
|
HTableDescriptor.isLegalTableName(Bytes.toBytes(snapshot.getName()));
|
||||||
// make sure the table name is valid
|
// make sure the table name is valid
|
||||||
|
|
|
@ -113,6 +113,30 @@ public class TestSnapshotFromClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test snapshotting not allowed .META. and -ROOT-
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testMetaTablesSnapshot() throws Exception {
|
||||||
|
HBaseAdmin admin = UTIL.getHBaseAdmin();
|
||||||
|
byte[] snapshotName = Bytes.toBytes("metaSnapshot");
|
||||||
|
|
||||||
|
try {
|
||||||
|
admin.snapshot(snapshotName, HConstants.META_TABLE_NAME);
|
||||||
|
fail("taking a snapshot of .META. should not be allowed");
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
admin.snapshot(snapshotName, HConstants.ROOT_TABLE_NAME);
|
||||||
|
fail("taking a snapshot of -ROOT- should not be allowed");
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test snapshotting a table that is offline
|
* Test snapshotting a table that is offline
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
|
Loading…
Reference in New Issue