region = createNewHRegion(desc, null, null);
HRegionIncommon r = new HRegionIncommon(region);
// Write information to the table
BatchUpdate batchUpdate = null;
batchUpdate = new BatchUpdate(ROW_KEY, System.currentTimeMillis());
batchUpdate.put(CONTENTS, CONTENTS);
batchUpdate.put(HConstants.COL_REGIONINFO,
Writables.getBytes(HRegionInfo.ROOT_REGIONINFO));
r.commit(batchUpdate);
batchUpdate = new BatchUpdate(ROW_KEY, System.currentTimeMillis());
batchUpdate.put(HConstants.COL_SERVER,
Bytes.toBytes(new HServerAddress(SERVER_ADDRESS).toString()));
batchUpdate.put(HConstants.COL_STARTCODE, Bytes.toBytes(12345));
batchUpdate.put(Bytes.toString(HConstants.COLUMN_FAMILY) +
"region", Bytes.toBytes("region"));
r.commit(batchUpdate);
// Verify that get works the same from memcache as when reading from disk
// NOTE dumpRegion won't work here because it only reads from disk.
verifyGet(r, SERVER_ADDRESS);
// Close and re-open region, forcing updates to disk
region.close();
region = openClosedRegion(region);
r = new HRegionIncommon(region);
// Read it back
verifyGet(r, SERVER_ADDRESS);
// Update one family member and add a new one
batchUpdate = new BatchUpdate(ROW_KEY, System.currentTimeMillis());
batchUpdate.put(Bytes.toString(HConstants.COLUMN_FAMILY) + "region",
"region2".getBytes(HConstants.UTF8_ENCODING));
String otherServerName = "bar.foo.com:4321";
batchUpdate.put(HConstants.COL_SERVER,
Bytes.toBytes(new HServerAddress(otherServerName).toString()));
batchUpdate.put(Bytes.toString(HConstants.COLUMN_FAMILY) + "junk",
"junk".getBytes(HConstants.UTF8_ENCODING));
r.commit(batchUpdate);
verifyGet(r, otherServerName);