hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdcry...@apache.org
Subject svn commit: r1508254 - in /hbase/branches/0.95/hbase-server/src: main/java/org/apache/hadoop/hbase/replication/regionserver/Replication.java test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java
Date Tue, 30 Jul 2013 00:10:02 GMT
Author: jdcryans
Date: Tue Jul 30 00:10:01 2013
New Revision: 1508254

URL: http://svn.apache.org/r1508254
Log:
HBASE-9038  Compaction WALEdit gives NPEs with Replication enabled

Modified:
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/Replication.java
    hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/Replication.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/Replication.java?rev=1508254&r1=1508253&r2=1508254&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/Replication.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/Replication.java
Tue Jul 30 00:10:01 2013
@@ -222,11 +222,25 @@ public class Replication implements WALA
   @Override
   public void visitLogEntryBeforeWrite(HTableDescriptor htd, HLogKey logKey,
                                        WALEdit logEdit) {
+    scopeWALEdits(htd, logKey, logEdit);
+  }
+
+  /**
+   * Utility method used to set the correct scopes on each log key. Doesn't set a scope on
keys
+   * from compaction WAL edits and if the scope is local.
+   * @param htd Descriptor used to find the scope to use
+   * @param logKey Key that may get scoped according to its edits
+   * @param logEdit Edits used to lookup the scopes
+   */
+  public static void scopeWALEdits(HTableDescriptor htd, HLogKey logKey,
+                                   WALEdit logEdit) {
     NavigableMap<byte[], Integer> scopes =
         new TreeMap<byte[], Integer>(Bytes.BYTES_COMPARATOR);
     byte[] family;
     for (KeyValue kv : logEdit.getKeyValues()) {
       family = kv.getFamily();
+      if (kv.matchingFamily(WALEdit.METAFAMILY)) continue;
+
       int scope = htd.getFamily(family).getScope();
       if (scope != REPLICATION_SCOPE_LOCAL &&
           !scopes.containsKey(family)) {

Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java?rev=1508254&r1=1508253&r2=1508254&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java
(original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java
Tue Jul 30 00:10:01 2013
@@ -24,6 +24,10 @@ import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.LargeTests;
 import org.apache.hadoop.hbase.client.*;
 import org.apache.hadoop.hbase.mapreduce.replication.VerifyReplication;
+import org.apache.hadoop.hbase.protobuf.generated.WALProtos;
+import org.apache.hadoop.hbase.regionserver.wal.HLogKey;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.replication.regionserver.Replication;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 import org.apache.hadoop.hbase.util.JVMClusterUtil;
@@ -461,4 +465,17 @@ public class TestReplicationSmallTests e
         findCounter(VerifyReplication.Verifier.Counters.BADROWS).getValue());
   }
 
+  /**
+   * Test for HBASE-9038, Replication.scopeWALEdits would NPE if it wasn't filtering out
+   * the compaction WALEdit
+   * @throws Exception
+   */
+  @Test(timeout=300000)
+  public void testCompactionWALEdits() throws Exception {
+    WALProtos.CompactionDescriptor compactionDescriptor =
+        WALProtos.CompactionDescriptor.getDefaultInstance();
+    WALEdit edit = WALEdit.createCompaction(compactionDescriptor);
+    Replication.scopeWALEdits(htable1.getTableDescriptor(), new HLogKey(), edit);
+  }
+
 }



Mime
View raw message