hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [2/2] git commit: HBASE-12388 Document behavior wrt coprocessors when wal gets empty waledits.
Date Fri, 31 Oct 2014 02:32:25 GMT
HBASE-12388 Document behavior wrt coprocessors when wal gets empty waledits.

Signed-off-by: stack <stack@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/646f1d5f
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/646f1d5f
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/646f1d5f

Branch: refs/heads/master
Commit: 646f1d5f8ff627dba31a995d7dd05fc705a44fb2
Parents: ff92346
Author: Sean Busbey <busbey@apache.org>
Authored: Thu Oct 30 16:25:17 2014 -0500
Committer: stack <stack@apache.org>
Committed: Thu Oct 30 19:32:12 2014 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/coprocessor/WALObserver.java   |  3 ++
 .../coprocessor/SampleRegionWALObserver.java    |  4 ++-
 .../hbase/coprocessor/TestWALObserver.java      | 30 ++++++++++++++++++++
 3 files changed, 36 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/646f1d5f/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/WALObserver.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/WALObserver.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/WALObserver.java
index 70c416a..49d84ed 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/WALObserver.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/WALObserver.java
@@ -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,
  *

http://git-wip-us.apache.org/repos/asf/hbase/blob/646f1d5f/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/SampleRegionWALObserver.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/SampleRegionWALObserver.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/SampleRegionWALObserver.java
index 599accf..3f983ed 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/SampleRegionWALObserver.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/SampleRegionWALObserver.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/hbase/blob/646f1d5f/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestWALObserver.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestWALObserver.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestWALObserver.java
index 75fe6d2..2bb56b5 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestWALObserver.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestWALObserver.java
@@ -230,6 +230,36 @@ public class TestWALObserver {
   }
 
   /**
+   * 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.
    */
   @Test


Mime
View raw message