*/
@Test
public void testScanner() throws IOException {
try {
r = TEST_UTIL.createLocalHRegion(TESTTABLEDESC, null, null);
region = new HRegionIncommon(r);
// Write information to the meta table
Put put = new Put(ROW_KEY, System.currentTimeMillis());
put.add(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER,
REGION_INFO.toByteArray());
region.put(put);
// What we just committed is in the memstore. Verify that we can get
// it back both with scanning and get
scan(false, null);
getRegionInfo();
// Close and re-open
r.close();
r = HRegion.openHRegion(r, null);
region = new HRegionIncommon(r);
// Verify we can get the data back now that it is on disk.
scan(false, null);
getRegionInfo();
// Store some new information
String address = HConstants.LOCALHOST_IP + ":" + HBaseTestingUtility.randomFreePort();
put = new Put(ROW_KEY, System.currentTimeMillis());
put.add(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER,
Bytes.toBytes(address));
// put.add(HConstants.COL_STARTCODE, Bytes.toBytes(START_CODE));
region.put(put);
// Validate that we can still get the HRegionInfo, even though it is in
// an older row on disk and there is a newer row in the memstore
scan(true, address.toString());
getRegionInfo();
// flush cache
region.flushcache();
// Validate again
scan(true, address.toString());
getRegionInfo();
// Close and reopen
r.close();
r = HRegion.openHRegion(r,null);
region = new HRegionIncommon(r);
// Validate again
scan(true, address.toString());
getRegionInfo();
// Now update the information again
address = "bar.foo.com:4321";
put = new Put(ROW_KEY, System.currentTimeMillis());
put.add(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER,
Bytes.toBytes(address));
region.put(put);
// Validate again
scan(true, address.toString());
getRegionInfo();
// flush cache
region.flushcache();
// Validate again
scan(true, address.toString());
getRegionInfo();
// Close and reopen
r.close();
r = HRegion.openHRegion(r,null);
region = new HRegionIncommon(r);
// Validate again
scan(true, address.toString());
getRegionInfo();