You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2018/12/19 01:45:45 UTC
hbase git commit: HBASE-21492 CellCodec Written To WAL Before It's
Verified
Repository: hbase
Updated Branches:
refs/heads/branch-2 99de534cc -> fc7ca8a2e
HBASE-21492 CellCodec Written To WAL Before It's Verified
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/fc7ca8a2
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/fc7ca8a2
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/fc7ca8a2
Branch: refs/heads/branch-2
Commit: fc7ca8a2efbdfeb4615c2a10803e35baee96d38e
Parents: 99de534
Author: BELUGA BEHR <da...@gmail.com>
Authored: Tue Nov 27 08:57:06 2018 -0800
Committer: Andrew Purtell <ap...@apache.org>
Committed: Tue Dec 18 17:45:37 2018 -0800
----------------------------------------------------------------------
.../org/apache/hadoop/hbase/mapreduce/WALPlayer.java | 2 +-
.../regionserver/wal/AbstractProtobufLogWriter.java | 3 ++-
.../hadoop/hbase/regionserver/wal/WALCellCodec.java | 9 ++++-----
.../hbase/regionserver/wal/TestCustomWALCellCodec.java | 11 +++++++++++
4 files changed, 18 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/fc7ca8a2/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/WALPlayer.java
----------------------------------------------------------------------
diff --git a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/WALPlayer.java b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/WALPlayer.java
index 3c34942..5251887 100644
--- a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/WALPlayer.java
+++ b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/WALPlayer.java
@@ -364,7 +364,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.addDependencyJarsForClasses(job.getConfiguration(), Class.forName(codecCls));
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/hbase/blob/fc7ca8a2/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AbstractProtobufLogWriter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AbstractProtobufLogWriter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AbstractProtobufLogWriter.java
index ae084a4..ff2864d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AbstractProtobufLogWriter.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AbstractProtobufLogWriter.java
@@ -80,7 +80,8 @@ public abstract class AbstractProtobufLogWriter {
builder.setWriterClsName(getWriterClassName());
}
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/fc7ca8a2/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 34d83f7..5aa943f 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
@@ -24,7 +24,6 @@ import java.io.OutputStream;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.KeyValue;
@@ -82,8 +81,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);
}
/**
@@ -102,7 +101,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 });
@@ -121,7 +120,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/fc7ca8a2/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 9391a85..6add84f 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
@@ -64,4 +64,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);
+ }
}