HBASE-12388 Document behavior wrt coprocessors when wal gets empty waledits.

Signed-off-by: stack <stack@apache.org>
This commit is contained in:
Sean Busbey 2014-10-30 16:25:17 -05:00 committed by stack
parent ff92346f5e
commit 646f1d5f8f
3 changed files with 36 additions and 1 deletions

View File

@ -33,6 +33,9 @@ import java.io.IOException;
* It's provided to have a way for coprocessors to observe, rewrite,
* or skip WALEdits as they are being written to the WAL.
*
* Note that implementers of WALObserver will not see WALEdits that report themselves
* as empty via {@link WALEdit#isEmpty()}.
*
* {@link org.apache.hadoop.hbase.coprocessor.RegionObserver} provides
* hooks for adding logic for WALEdits in the region context during reconstruction,
*

View File

@ -112,7 +112,9 @@ implements WALObserver {
cell.getValueArray()[cell.getValueOffset()] += 1;
}
}
cells.add(new KeyValue(row, addedFamily, addedQualifier));
if (null != row) {
cells.add(new KeyValue(row, addedFamily, addedQualifier));
}
if (deletedCell != null) {
LOG.debug("About to delete a KeyValue from WALEdit.");
cells.remove(deletedCell);

View File

@ -229,6 +229,36 @@ public class TestWALObserver {
assertTrue(cp.isPostWALWriteCalled());
}
/**
* Coprocessors shouldn't get notice of empty waledits.
*/
@Test
public void testEmptyWALEditAreNotSeen() throws Exception {
final HRegionInfo hri = createBasic3FamilyHRegionInfo(Bytes.toString(TEST_TABLE));
final HTableDescriptor htd = createBasic3FamilyHTD(Bytes.toString(TEST_TABLE));
final AtomicLong sequenceId = new AtomicLong(0);
HLog log = HLogFactory.createHLog(this.fs, hbaseRootDir,
TestWALObserver.class.getName(), this.conf);
try {
SampleRegionWALObserver cp = getCoprocessor(log);
cp.setTestValues(TEST_TABLE, null, null, null, null, null, null, null);
assertFalse(cp.isPreWALWriteCalled());
assertFalse(cp.isPostWALWriteCalled());
final long now = EnvironmentEdgeManager.currentTime();
log.append(hri, hri.getTable(), new WALEdit(), now, htd, sequenceId);
log.sync();
assertFalse("Empty WALEdit should skip coprocessor evaluation.", cp.isPreWALWriteCalled());
assertFalse("Empty WALEdit should skip coprocessor evaluation.", cp.isPostWALWriteCalled());
} finally {
log.closeAndDelete();
}
}
/**
* Test WAL replay behavior with WALObserver.
*/