You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by bu...@apache.org on 2019/01/07 19:08:53 UTC

[2/2] hbase git commit: HBASE-21492 CellCodec Written To WAL Before It's Verified

HBASE-21492 CellCodec Written To WAL Before It's Verified

Conflicts:
	hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AbstractProtobufLogWriter.java

(cherry picked from commit f7470a8b5734ab2ff05e4fc639f8b8fb8d9d8217)


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

Branch: refs/heads/branch-1.2
Commit: 322c076a0ba9ce1715b89c6017ba167c272a2c3b
Parents: c153f6f
Author: BELUGA BEHR <da...@gmail.com>
Authored: Tue Nov 27 08:57:06 2018 -0800
Committer: Sean Busbey <bu...@apache.org>
Committed: Mon Jan 7 12:52:53 2019 -0600

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/mapreduce/WALPlayer.java     |  2 +-
 .../hadoop/hbase/regionserver/wal/ProtobufLogWriter.java |  2 +-
 .../hadoop/hbase/regionserver/wal/WALCellCodec.java      |  8 ++++----
 .../hbase/regionserver/wal/TestCustomWALCellCodec.java   | 11 +++++++++++
 4 files changed, 17 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/322c076a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/WALPlayer.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/WALPlayer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/WALPlayer.java
index f16aecb..5785b45 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/WALPlayer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/WALPlayer.java
@@ -295,7 +295,7 @@ public class WALPlayer extends Configured implements Tool {
       // No reducers.
       job.setNumReduceTasks(0);
     }
-    String codecCls = WALCellCodec.getWALCellCodecClass(conf);
+    String codecCls = WALCellCodec.getWALCellCodecClass(conf).getName();
     try {
       TableMapReduceUtil.addDependencyJars(conf, Class.forName(codecCls));
     } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/322c076a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/ProtobufLogWriter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/ProtobufLogWriter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/ProtobufLogWriter.java
index 42abeae..436df87 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/ProtobufLogWriter.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/ProtobufLogWriter.java
@@ -69,7 +69,7 @@ public class ProtobufLogWriter extends WriterBase {
       builder.setWriterClsName(ProtobufLogWriter.class.getSimpleName());
     }
     if (!builder.hasCellCodecClsName()) {
-      builder.setCellCodecClsName(WALCellCodec.getWALCellCodecClass(conf));
+      builder.setCellCodecClsName(WALCellCodec.getWALCellCodecClass(conf).getName());
     }
     return builder.build();
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/322c076a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALCellCodec.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALCellCodec.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALCellCodec.java
index 5c62ef2..11b6120 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALCellCodec.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALCellCodec.java
@@ -79,8 +79,8 @@ public class WALCellCodec implements Codec {
     this.compression = compression;
   }
 
-  public static String getWALCellCodecClass(Configuration conf) {
-    return conf.get(WAL_CELL_CODEC_CLASS_KEY, WALCellCodec.class.getName());
+  public static Class<?> getWALCellCodecClass(Configuration conf) {
+    return conf.getClass(WAL_CELL_CODEC_CLASS_KEY, WALCellCodec.class);
   }
 
   /**
@@ -98,7 +98,7 @@ public class WALCellCodec implements Codec {
   public static WALCellCodec create(Configuration conf, String cellCodecClsName,
       CompressionContext compression) throws UnsupportedOperationException {
     if (cellCodecClsName == null) {
-      cellCodecClsName = getWALCellCodecClass(conf);
+      cellCodecClsName = getWALCellCodecClass(conf).getName();
     }
     return ReflectionUtils.instantiateWithCustomCtor(cellCodecClsName, new Class[]
         { Configuration.class, CompressionContext.class }, new Object[] { conf, compression });
@@ -117,7 +117,7 @@ public class WALCellCodec implements Codec {
    */
   public static WALCellCodec create(Configuration conf,
       CompressionContext compression) throws UnsupportedOperationException {
-    String cellCodecClsName = getWALCellCodecClass(conf);
+    String cellCodecClsName = getWALCellCodecClass(conf).getName();
     return ReflectionUtils.instantiateWithCustomCtor(cellCodecClsName, new Class[]
         { Configuration.class, CompressionContext.class }, new Object[] { conf, compression });
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/322c076a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestCustomWALCellCodec.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestCustomWALCellCodec.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestCustomWALCellCodec.java
index 7f48f9b..c5200b4 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestCustomWALCellCodec.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestCustomWALCellCodec.java
@@ -58,4 +58,15 @@ public class TestCustomWALCellCodec {
     assertEquals("Custom codec didn't get initialized with the right compression context!", null,
       codec.context);
   }
+
+  /**
+   * Test that a custom {@link WALCellCodec} will fail if provided an invalid
+   * code class.
+   */
+  @Test(expected = RuntimeException.class)
+  public void testCreatePreparesCodecInvalidClass() throws Exception {
+    Configuration conf = new Configuration(false);
+    conf.setStrings(WALCellCodec.WAL_CELL_CODEC_CLASS_KEY, "org.apache.hbase.wal.NoSuchClass");
+    WALCellCodec.create(conf, null, null);
+  }
 }