HBASE-7307 MetaReader.tableExists should not return false if the specified table regions has been split (Rajesh)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1419998 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
315b38becc
commit
bd5a2f972f
|
@ -322,7 +322,6 @@ public class MetaReader {
|
|||
return true;
|
||||
}
|
||||
if (!isInsideTable(this.current, tableNameBytes)) return false;
|
||||
if (this.current.isSplitParent()) return true;
|
||||
// Else call super and add this Result to the collection.
|
||||
super.visit(r);
|
||||
// Stop collecting regions from table after we get one.
|
||||
|
|
|
@ -46,6 +46,7 @@ import org.apache.hadoop.hbase.Server;
|
|||
import org.apache.hadoop.hbase.ServerName;
|
||||
import org.apache.hadoop.hbase.UnknownRegionException;
|
||||
import org.apache.hadoop.hbase.ZooKeeperConnectionException;
|
||||
import org.apache.hadoop.hbase.catalog.MetaReader;
|
||||
import org.apache.hadoop.hbase.client.Delete;
|
||||
import org.apache.hadoop.hbase.client.HBaseAdmin;
|
||||
import org.apache.hadoop.hbase.client.HTable;
|
||||
|
@ -627,6 +628,47 @@ public class TestSplitTransactionOnCluster {
|
|||
}
|
||||
}
|
||||
|
||||
@Test(timeout = 20000)
|
||||
public void testTableExistsIfTheSpecifiedTableRegionIsSplitParent() throws Exception {
|
||||
final byte[] tableName =
|
||||
Bytes.toBytes("testTableExistsIfTheSpecifiedTableRegionIsSplitParent");
|
||||
HRegionServer regionServer = null;
|
||||
List<HRegion> regions = null;
|
||||
HBaseAdmin admin = new HBaseAdmin(TESTING_UTIL.getConfiguration());
|
||||
try {
|
||||
// Create table then get the single region for our new table.
|
||||
HTableDescriptor htd = new HTableDescriptor(tableName);
|
||||
htd.addFamily(new HColumnDescriptor("cf"));
|
||||
admin.createTable(htd);
|
||||
HTable t = new HTable(cluster.getConfiguration(), tableName);
|
||||
regions = cluster.getRegions(tableName);
|
||||
int regionServerIndex = cluster.getServerWith(regions.get(0).getRegionName());
|
||||
regionServer = cluster.getRegionServer(regionServerIndex);
|
||||
insertData(tableName, admin, t);
|
||||
// Turn off balancer so it doesn't cut in and mess up our placements.
|
||||
admin.setBalancerRunning(false, false);
|
||||
// Turn off the meta scanner so it don't remove parent on us.
|
||||
cluster.getMaster().setCatalogJanitorEnabled(false);
|
||||
boolean tableExists = MetaReader.tableExists(regionServer.getCatalogTracker(),
|
||||
Bytes.toString(tableName));
|
||||
assertEquals("The specified table should present.", true, tableExists);
|
||||
SplitTransaction st = new SplitTransaction(regions.get(0), Bytes.toBytes("row2"));
|
||||
try {
|
||||
st.prepare();
|
||||
st.createDaughters(regionServer, regionServer);
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
tableExists = MetaReader.tableExists(regionServer.getCatalogTracker(),
|
||||
Bytes.toString(tableName));
|
||||
assertEquals("The specified table should present.", true, tableExists);
|
||||
} finally {
|
||||
admin.setBalancerRunning(true, false);
|
||||
cluster.getMaster().setCatalogJanitorEnabled(true);
|
||||
admin.close();
|
||||
}
|
||||
}
|
||||
|
||||
private void insertData(final byte[] tableName, HBaseAdmin admin, HTable t) throws IOException,
|
||||
InterruptedException {
|
||||
Put p = new Put(Bytes.toBytes("row1"));
|
||||
|
|
Loading…
Reference in New Issue