From a22fe02fba66280a8e994282e9ead23d9e20669a Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Fri, 21 Apr 2017 11:35:30 -0700 Subject: [PATCH] HADOOP-14261. Some refactoring work for erasure coding raw coder. Contributed by Lin Zeng. --- .../apache/hadoop/io/erasurecode/CodecUtil.java | 4 ++-- ...ecoderLegacy.java => RSLegacyRawDecoder.java} | 4 ++-- ...ncoderLegacy.java => RSLegacyRawEncoder.java} | 4 ++-- ....java => RSLegacyRawErasureCoderFactory.java} | 6 +++--- .../src/main/resources/core-default.xml | 2 +- .../io/erasurecode/TestCodecRawCoderMapping.java | 12 ++++++------ .../rawcoder/RawErasureCoderBenchmark.java | 2 +- .../erasurecode/rawcoder/TestDummyRawCoder.java | 4 ++-- .../rawcoder/TestNativeRSRawCoder.java | 4 ++-- .../rawcoder/TestNativeXORRawCoder.java | 4 ++-- ...oderLegacy.java => TestRSLegacyRawCoder.java} | 6 +++--- .../io/erasurecode/rawcoder/TestRSRawCoder.java | 4 ++-- .../rawcoder/TestRSRawCoderInteroperable1.java | 4 ++-- .../rawcoder/TestRSRawCoderInteroperable2.java | 4 ++-- .../erasurecode/rawcoder/TestRawCoderBase.java | 16 ++++++---------- .../io/erasurecode/rawcoder/TestXORRawCoder.java | 4 ++-- .../rawcoder/TestXORRawCoderInteroperable1.java | 4 ++-- .../rawcoder/TestXORRawCoderInteroperable2.java | 4 ++-- 18 files changed, 44 insertions(+), 48 deletions(-) rename hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/{RSRawDecoderLegacy.java => RSLegacyRawDecoder.java} (98%) rename hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/{RSRawEncoderLegacy.java => RSLegacyRawEncoder.java} (97%) rename hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/{RSRawErasureCoderFactoryLegacy.java => RSLegacyRawErasureCoderFactory.java} (88%) rename hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/{TestRSRawCoderLegacy.java => TestRSLegacyRawCoder.java} (84%) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/CodecUtil.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/CodecUtil.java index 0c66df6939..c8b6a6839c 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/CodecUtil.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/CodecUtil.java @@ -33,7 +33,7 @@ import org.apache.hadoop.io.erasurecode.rawcoder.NativeRSRawErasureCoderFactory; import org.apache.hadoop.io.erasurecode.rawcoder.NativeXORRawErasureCoderFactory; import org.apache.hadoop.io.erasurecode.rawcoder.RSRawErasureCoderFactory; -import org.apache.hadoop.io.erasurecode.rawcoder.RSRawErasureCoderFactoryLegacy; +import org.apache.hadoop.io.erasurecode.rawcoder.RSLegacyRawErasureCoderFactory; import org.apache.hadoop.io.erasurecode.rawcoder.RawErasureCoderFactory; import org.apache.hadoop.io.erasurecode.rawcoder.RawErasureDecoder; import org.apache.hadoop.io.erasurecode.rawcoder.RawErasureEncoder; @@ -80,7 +80,7 @@ public final class CodecUtil { public static final String IO_ERASURECODE_CODEC_RS_LEGACY_RAWCODERS_KEY = IO_ERASURECODE_CODEC + "rs-legacy.rawcoders"; public static final String IO_ERASURECODE_CODEC_RS_LEGACY_RAWCODERS_DEFAULT = - RSRawErasureCoderFactoryLegacy.class.getCanonicalName(); + RSLegacyRawErasureCoderFactory.class.getCanonicalName(); public static final String IO_ERASURECODE_CODEC_RS_RAWCODERS_KEY = IO_ERASURECODE_CODEC + "rs.rawcoders"; public static final String IO_ERASURECODE_CODEC_RS_RAWCODERS_DEFAULT = diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/RSRawDecoderLegacy.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/RSLegacyRawDecoder.java similarity index 98% rename from hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/RSRawDecoderLegacy.java rename to hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/RSLegacyRawDecoder.java index c8deec90c6..cfd7d29eb8 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/RSRawDecoderLegacy.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/RSLegacyRawDecoder.java @@ -34,12 +34,12 @@ * addressed in HADOOP-11871. */ @InterfaceAudience.Private -public class RSRawDecoderLegacy extends RawErasureDecoder { +public class RSLegacyRawDecoder extends RawErasureDecoder { // To describe and calculate the needed Vandermonde matrix private int[] errSignature; private int[] primitivePower; - public RSRawDecoderLegacy(ErasureCoderOptions coderOptions) { + public RSLegacyRawDecoder(ErasureCoderOptions coderOptions) { super(coderOptions); if (getNumAllUnits() >= RSUtil.GF.getFieldSize()) { throw new HadoopIllegalArgumentException( diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/RSRawEncoderLegacy.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/RSLegacyRawEncoder.java similarity index 97% rename from hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/RSRawEncoderLegacy.java rename to hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/RSLegacyRawEncoder.java index ed1c83b428..7a526c9556 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/RSRawEncoderLegacy.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/RSLegacyRawEncoder.java @@ -30,10 +30,10 @@ * when possible. */ @InterfaceAudience.Private -public class RSRawEncoderLegacy extends RawErasureEncoder { +public class RSLegacyRawEncoder extends RawErasureEncoder { private int[] generatingPolynomial; - public RSRawEncoderLegacy(ErasureCoderOptions coderOptions) { + public RSLegacyRawEncoder(ErasureCoderOptions coderOptions) { super(coderOptions); assert (getNumDataUnits() + getNumParityUnits() < RSUtil.GF.getFieldSize()); diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/RSRawErasureCoderFactoryLegacy.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/RSLegacyRawErasureCoderFactory.java similarity index 88% rename from hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/RSRawErasureCoderFactoryLegacy.java rename to hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/RSLegacyRawErasureCoderFactory.java index f0ebb3b3b7..45bbf40f69 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/RSRawErasureCoderFactoryLegacy.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/rawcoder/RSLegacyRawErasureCoderFactory.java @@ -24,15 +24,15 @@ * A raw coder factory for the legacy raw Reed-Solomon coder in Java. */ @InterfaceAudience.Private -public class RSRawErasureCoderFactoryLegacy implements RawErasureCoderFactory { +public class RSLegacyRawErasureCoderFactory implements RawErasureCoderFactory { @Override public RawErasureEncoder createEncoder(ErasureCoderOptions coderOptions) { - return new RSRawEncoderLegacy(coderOptions); + return new RSLegacyRawEncoder(coderOptions); } @Override public RawErasureDecoder createDecoder(ErasureCoderOptions coderOptions) { - return new RSRawDecoderLegacy(coderOptions); + return new RSLegacyRawDecoder(coderOptions); } } diff --git a/hadoop-common-project/hadoop-common/src/main/resources/core-default.xml b/hadoop-common-project/hadoop-common/src/main/resources/core-default.xml index 954eb34416..6fa70fd0d4 100644 --- a/hadoop-common-project/hadoop-common/src/main/resources/core-default.xml +++ b/hadoop-common-project/hadoop-common/src/main/resources/core-default.xml @@ -677,7 +677,7 @@ io.erasurecode.codec.rs-legacy.rawcoders - org.apache.hadoop.io.erasurecode.rawcoder.RSRawErasureCoderFactoryLegacy + org.apache.hadoop.io.erasurecode.rawcoder.RSLegacyRawErasureCoderFactory Comma separated raw coder implementations for the rs-legacy codec. The earlier factory is prior to followings in case of failure of creating raw coders. diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/TestCodecRawCoderMapping.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/TestCodecRawCoderMapping.java index db31993a7e..b5cada65fa 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/TestCodecRawCoderMapping.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/TestCodecRawCoderMapping.java @@ -20,9 +20,9 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.erasurecode.rawcoder.NativeRSRawErasureCoderFactory; import org.apache.hadoop.io.erasurecode.rawcoder.RSRawDecoder; -import org.apache.hadoop.io.erasurecode.rawcoder.RSRawDecoderLegacy; +import org.apache.hadoop.io.erasurecode.rawcoder.RSLegacyRawDecoder; import org.apache.hadoop.io.erasurecode.rawcoder.RSRawEncoder; -import org.apache.hadoop.io.erasurecode.rawcoder.RSRawEncoderLegacy; +import org.apache.hadoop.io.erasurecode.rawcoder.RSLegacyRawEncoder; import org.apache.hadoop.io.erasurecode.rawcoder.RSRawErasureCoderFactory; import org.apache.hadoop.io.erasurecode.rawcoder.RawErasureDecoder; import org.apache.hadoop.io.erasurecode.rawcoder.RawErasureEncoder; @@ -62,10 +62,10 @@ public void testRSDefaultRawCoder() { // should return default raw coder of rs-legacy codec encoder = CodecUtil.createRawEncoder(conf, ErasureCodeConstants.RS_LEGACY_CODEC_NAME, coderOptions); - Assert.assertTrue(encoder instanceof RSRawEncoderLegacy); + Assert.assertTrue(encoder instanceof RSLegacyRawEncoder); decoder = CodecUtil.createRawDecoder(conf, ErasureCodeConstants.RS_LEGACY_CODEC_NAME, coderOptions); - Assert.assertTrue(decoder instanceof RSRawDecoderLegacy); + Assert.assertTrue(decoder instanceof RSLegacyRawDecoder); } @Test @@ -122,10 +122,10 @@ public void testLegacyCodecFallback() { // should return default raw coder of rs-legacy codec RawErasureEncoder encoder = CodecUtil.createRawEncoder( conf, ErasureCodeConstants.RS_LEGACY_CODEC_NAME, coderOptions); - Assert.assertTrue(encoder instanceof RSRawEncoderLegacy); + Assert.assertTrue(encoder instanceof RSLegacyRawEncoder); RawErasureDecoder decoder = CodecUtil.createRawDecoder( conf, ErasureCodeConstants.RS_LEGACY_CODEC_NAME, coderOptions); - Assert.assertTrue(decoder instanceof RSRawDecoderLegacy); + Assert.assertTrue(decoder instanceof RSLegacyRawDecoder); } @Test diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/RawErasureCoderBenchmark.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/RawErasureCoderBenchmark.java index 4492e2f035..bb4a1f0647 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/RawErasureCoderBenchmark.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/RawErasureCoderBenchmark.java @@ -60,7 +60,7 @@ private RawErasureCoderBenchmark() { private static final List CODER_MAKERS = Collections.unmodifiableList( Arrays.asList(new DummyRawErasureCoderFactory(), - new RSRawErasureCoderFactoryLegacy(), + new RSLegacyRawErasureCoderFactory(), new RSRawErasureCoderFactory(), new NativeRSRawErasureCoderFactory())); diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestDummyRawCoder.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestDummyRawCoder.java index 5be9b4e9fe..6f5871ccdf 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestDummyRawCoder.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestDummyRawCoder.java @@ -29,8 +29,8 @@ public class TestDummyRawCoder extends TestRawCoderBase { @Before public void setup() { - encoderClass = DummyRawEncoder.class; - decoderClass = DummyRawDecoder.class; + encoderFactoryClass = DummyRawErasureCoderFactory.class; + decoderFactoryClass = DummyRawErasureCoderFactory.class; setAllowDump(false); setChunkSize(baseChunkSize); } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestNativeRSRawCoder.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestNativeRSRawCoder.java index edbb9df4f9..e3536d8d0c 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestNativeRSRawCoder.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestNativeRSRawCoder.java @@ -30,8 +30,8 @@ public class TestNativeRSRawCoder extends TestRSRawCoderBase { @Before public void setup() { Assume.assumeTrue(ErasureCodeNative.isNativeCodeLoaded()); - this.encoderClass = NativeRSRawEncoder.class; - this.decoderClass = NativeRSRawDecoder.class; + this.encoderFactoryClass = NativeRSRawErasureCoderFactory.class; + this.decoderFactoryClass = NativeRSRawErasureCoderFactory.class; setAllowDump(true); } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestNativeXORRawCoder.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestNativeXORRawCoder.java index ba4b7b4c29..5adefbe6d5 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestNativeXORRawCoder.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestNativeXORRawCoder.java @@ -29,8 +29,8 @@ public class TestNativeXORRawCoder extends TestXORRawCoderBase { @Before public void setup() { Assume.assumeTrue(ErasureCodeNative.isNativeCodeLoaded()); - this.encoderClass = NativeXORRawEncoder.class; - this.decoderClass = NativeXORRawDecoder.class; + this.encoderFactoryClass = NativeXORRawErasureCoderFactory.class; + this.decoderFactoryClass = NativeXORRawErasureCoderFactory.class; setAllowDump(true); } } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRSRawCoderLegacy.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRSLegacyRawCoder.java similarity index 84% rename from hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRSRawCoderLegacy.java rename to hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRSLegacyRawCoder.java index ef58e43f8d..c01aed95ef 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRSRawCoderLegacy.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRSLegacyRawCoder.java @@ -22,12 +22,12 @@ /** * Test the legacy raw Reed-solomon coder implemented in Java. */ -public class TestRSRawCoderLegacy extends TestRSRawCoderBase { +public class TestRSLegacyRawCoder extends TestRSRawCoderBase { @Before public void setup() { - this.encoderClass = RSRawEncoderLegacy.class; - this.decoderClass = RSRawDecoderLegacy.class; + this.encoderFactoryClass = RSLegacyRawErasureCoderFactory.class; + this.decoderFactoryClass = RSLegacyRawErasureCoderFactory.class; setAllowDump(false); // Change to true to allow verbose dump for debugging } } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRSRawCoder.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRSRawCoder.java index 5216b9b37f..c613ee1d45 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRSRawCoder.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRSRawCoder.java @@ -26,8 +26,8 @@ public class TestRSRawCoder extends TestRSRawCoderBase { @Before public void setup() { - this.encoderClass = RSRawEncoder.class; - this.decoderClass = RSRawDecoder.class; + this.encoderFactoryClass = RSRawErasureCoderFactory.class; + this.decoderFactoryClass = RSRawErasureCoderFactory.class; setAllowDump(false); } } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRSRawCoderInteroperable1.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRSRawCoderInteroperable1.java index 9ce041c387..c39c4e0592 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRSRawCoderInteroperable1.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRSRawCoderInteroperable1.java @@ -30,8 +30,8 @@ public class TestRSRawCoderInteroperable1 extends TestRSRawCoderBase { public void setup() { Assume.assumeTrue(ErasureCodeNative.isNativeCodeLoaded()); - this.encoderClass = RSRawEncoder.class; - this.decoderClass = NativeRSRawDecoder.class; + this.encoderFactoryClass = RSRawErasureCoderFactory.class; + this.decoderFactoryClass = NativeRSRawErasureCoderFactory.class; setAllowDump(true); } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRSRawCoderInteroperable2.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRSRawCoderInteroperable2.java index 15531f3e6a..3c97521d1b 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRSRawCoderInteroperable2.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRSRawCoderInteroperable2.java @@ -30,8 +30,8 @@ public class TestRSRawCoderInteroperable2 extends TestRSRawCoderBase { public void setup() { Assume.assumeTrue(ErasureCodeNative.isNativeCodeLoaded()); - this.encoderClass = NativeRSRawEncoder.class; - this.decoderClass = RSRawDecoder.class; + this.encoderFactoryClass = NativeRSRawErasureCoderFactory.class; + this.decoderFactoryClass = RSRawErasureCoderFactory.class; setAllowDump(true); } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRawCoderBase.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRawCoderBase.java index 32f0e00c8d..01c743a240 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRawCoderBase.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRawCoderBase.java @@ -23,14 +23,12 @@ import org.junit.Assert; import org.junit.Test; -import java.lang.reflect.Constructor; - /** * Raw coder test base with utilities. */ public abstract class TestRawCoderBase extends TestCoderBase { - protected Class encoderClass; - protected Class decoderClass; + protected Class encoderFactoryClass; + protected Class decoderFactoryClass; protected RawErasureEncoder encoder; protected RawErasureDecoder decoder; @@ -234,9 +232,8 @@ protected RawErasureEncoder createEncoder() { new ErasureCoderOptions(numDataUnits, numParityUnits, allowChangeInputs, allowDump); try { - Constructor constructor = - encoderClass.getConstructor(ErasureCoderOptions.class); - return constructor.newInstance(coderConf); + RawErasureCoderFactory factory = encoderFactoryClass.newInstance(); + return factory.createEncoder(coderConf); } catch (Exception e) { throw new RuntimeException("Failed to create encoder", e); } @@ -251,9 +248,8 @@ protected RawErasureDecoder createDecoder() { new ErasureCoderOptions(numDataUnits, numParityUnits, allowChangeInputs, allowDump); try { - Constructor constructor = - decoderClass.getConstructor(ErasureCoderOptions.class); - return constructor.newInstance(coderConf); + RawErasureCoderFactory factory = encoderFactoryClass.newInstance(); + return factory.createDecoder(coderConf); } catch (Exception e) { throw new RuntimeException("Failed to create decoder", e); } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestXORRawCoder.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestXORRawCoder.java index aae3a048c8..b29cd4cb22 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestXORRawCoder.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestXORRawCoder.java @@ -26,7 +26,7 @@ public class TestXORRawCoder extends TestXORRawCoderBase { @Before public void setup() { - this.encoderClass = XORRawEncoder.class; - this.decoderClass = XORRawDecoder.class; + this.encoderFactoryClass = XORRawErasureCoderFactory.class; + this.decoderFactoryClass = XORRawErasureCoderFactory.class; } } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestXORRawCoderInteroperable1.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestXORRawCoderInteroperable1.java index c5a809c821..5238a8601e 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestXORRawCoderInteroperable1.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestXORRawCoderInteroperable1.java @@ -29,8 +29,8 @@ public class TestXORRawCoderInteroperable1 extends TestXORRawCoderBase { @Before public void setup() { Assume.assumeTrue(ErasureCodeNative.isNativeCodeLoaded()); - this.encoderClass = XORRawEncoder.class; - this.decoderClass = NativeXORRawDecoder.class; + this.encoderFactoryClass = XORRawErasureCoderFactory.class; + this.decoderFactoryClass = NativeXORRawErasureCoderFactory.class; setAllowDump(true); } } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestXORRawCoderInteroperable2.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestXORRawCoderInteroperable2.java index 5345eb69ae..b835107e84 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestXORRawCoderInteroperable2.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestXORRawCoderInteroperable2.java @@ -29,8 +29,8 @@ public class TestXORRawCoderInteroperable2 extends TestXORRawCoderBase { @Before public void setup() { Assume.assumeTrue(ErasureCodeNative.isNativeCodeLoaded()); - this.encoderClass = NativeXORRawEncoder.class; - this.decoderClass = XORRawDecoder.class; + this.encoderFactoryClass = NativeXORRawErasureCoderFactory.class; + this.decoderFactoryClass = XORRawErasureCoderFactory.class; setAllowDump(true); }