HBASE-20930 MetaScanner.metaScan should respect meta table name (Vishal Khandelwal)

This commit is contained in:
Josh Elser 2018-07-30 16:35:34 -04:00
parent 9b5a839b99
commit ab3ec9477a
2 changed files with 11 additions and 1 deletions

View File

@ -147,7 +147,7 @@ public class MetaScanner {
// managed connections getting tables. Leaving this as it is for now. Will // managed connections getting tables. Leaving this as it is for now. Will
// revisit when inclined to change all tests. User code probaby makes use of // revisit when inclined to change all tests. User code probaby makes use of
// managed connections too so don't change it till post hbase 1.0. // managed connections too so don't change it till post hbase 1.0.
try (Table metaTable = new HTable(TableName.META_TABLE_NAME, connection, null)) { try (Table metaTable = new HTable(metaTableName, connection, null)) {
if (row != null) { if (row != null) {
// Scan starting at a particular row in a particular table // Scan starting at a particular row in a particular table
Result startRowResult = getClosestRowOrBefore(metaTable, tableName, row, Result startRowResult = getClosestRowOrBefore(metaTable, tableName, row,

View File

@ -38,6 +38,7 @@ import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.MetaTableAccessor; import org.apache.hadoop.hbase.MetaTableAccessor;
import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.TableNotFoundException;
import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.StoppableImplementation; import org.apache.hadoop.hbase.util.StoppableImplementation;
@ -107,6 +108,15 @@ public class TestMetaScanner {
doReturn(true).when(visitor).processRow((Result) anyObject()); doReturn(true).when(visitor).processRow((Result) anyObject());
MetaScanner.metaScan(connection, visitor, TABLENAME, Bytes.toBytes("region_ac"), 1); MetaScanner.metaScan(connection, visitor, TABLENAME, Bytes.toBytes("region_ac"), 1);
verify(visitor, times(1)).processRow((Result) anyObject()); verify(visitor, times(1)).processRow((Result) anyObject());
// Verifying whether passed meta is honored by call or not
try {
MetaScanner.metaScan(connection, visitor, TABLENAME, Bytes.toBytes("region_ac"), 1,
TableName.valueOf("invalidMeta"));
Assert.fail("Passed invalid meta table name but it is not honored");
} catch (TableNotFoundException e) {
}
table.close(); table.close();
} }