|
@@ -68,9 +68,9 @@ public abstract class TestRawCoderBase extends TestCoderBase {
|
|
* The following runs will use 3 different chunkSize for inputs and outputs,
|
|
* The following runs will use 3 different chunkSize for inputs and outputs,
|
|
* to verify the same encoder/decoder can process variable width of data.
|
|
* to verify the same encoder/decoder can process variable width of data.
|
|
*/
|
|
*/
|
|
- performTestCoding(baseChunkSize, true, false, false);
|
|
|
|
- performTestCoding(baseChunkSize - 17, false, false, false);
|
|
|
|
- performTestCoding(baseChunkSize + 16, true, false, false);
|
|
|
|
|
|
+ performTestCoding(baseChunkSize, true, false, false, false);
|
|
|
|
+ performTestCoding(baseChunkSize - 17, false, false, false, true);
|
|
|
|
+ performTestCoding(baseChunkSize + 16, true, false, false, false);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -82,7 +82,7 @@ public abstract class TestRawCoderBase extends TestCoderBase {
|
|
prepareCoders();
|
|
prepareCoders();
|
|
|
|
|
|
try {
|
|
try {
|
|
- performTestCoding(baseChunkSize, false, true, false);
|
|
|
|
|
|
+ performTestCoding(baseChunkSize, false, true, false, true);
|
|
Assert.fail("Encoding test with bad input should fail");
|
|
Assert.fail("Encoding test with bad input should fail");
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
// Expected
|
|
// Expected
|
|
@@ -98,7 +98,7 @@ public abstract class TestRawCoderBase extends TestCoderBase {
|
|
prepareCoders();
|
|
prepareCoders();
|
|
|
|
|
|
try {
|
|
try {
|
|
- performTestCoding(baseChunkSize, false, false, true);
|
|
|
|
|
|
+ performTestCoding(baseChunkSize, false, false, true, true);
|
|
Assert.fail("Decoding test with bad output should fail");
|
|
Assert.fail("Decoding test with bad output should fail");
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
// Expected
|
|
// Expected
|
|
@@ -123,9 +123,11 @@ public abstract class TestRawCoderBase extends TestCoderBase {
|
|
}
|
|
}
|
|
|
|
|
|
private void performTestCoding(int chunkSize, boolean usingSlicedBuffer,
|
|
private void performTestCoding(int chunkSize, boolean usingSlicedBuffer,
|
|
- boolean useBadInput, boolean useBadOutput) {
|
|
|
|
|
|
+ boolean useBadInput, boolean useBadOutput,
|
|
|
|
+ boolean allowChangeInputs) {
|
|
setChunkSize(chunkSize);
|
|
setChunkSize(chunkSize);
|
|
prepareBufferAllocator(usingSlicedBuffer);
|
|
prepareBufferAllocator(usingSlicedBuffer);
|
|
|
|
+ setAllowChangeInputs(allowChangeInputs);
|
|
|
|
|
|
dumpSetting();
|
|
dumpSetting();
|
|
|
|
|
|
@@ -141,10 +143,16 @@ public abstract class TestRawCoderBase extends TestCoderBase {
|
|
// Backup all the source chunks for later recovering because some coders
|
|
// Backup all the source chunks for later recovering because some coders
|
|
// may affect the source data.
|
|
// may affect the source data.
|
|
ECChunk[] clonedDataChunks = cloneChunksWithData(dataChunks);
|
|
ECChunk[] clonedDataChunks = cloneChunksWithData(dataChunks);
|
|
|
|
+ markChunks(dataChunks);
|
|
|
|
|
|
encoder.encode(dataChunks, parityChunks);
|
|
encoder.encode(dataChunks, parityChunks);
|
|
dumpChunks("Encoded parity chunks", parityChunks);
|
|
dumpChunks("Encoded parity chunks", parityChunks);
|
|
|
|
|
|
|
|
+ if (!allowChangeInputs) {
|
|
|
|
+ restoreChunksFromMark(dataChunks);
|
|
|
|
+ compareAndVerify(clonedDataChunks, dataChunks);
|
|
|
|
+ }
|
|
|
|
+
|
|
// Backup and erase some chunks
|
|
// Backup and erase some chunks
|
|
ECChunk[] backupChunks = backupAndEraseChunks(clonedDataChunks, parityChunks);
|
|
ECChunk[] backupChunks = backupAndEraseChunks(clonedDataChunks, parityChunks);
|
|
|
|
|
|
@@ -160,14 +168,31 @@ public abstract class TestRawCoderBase extends TestCoderBase {
|
|
corruptSomeChunk(recoveredChunks);
|
|
corruptSomeChunk(recoveredChunks);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ ECChunk[] clonedInputChunks = null;
|
|
|
|
+ if (!allowChangeInputs) {
|
|
|
|
+ markChunks(inputChunks);
|
|
|
|
+ clonedInputChunks = cloneChunksWithData(inputChunks);
|
|
|
|
+ }
|
|
|
|
+
|
|
dumpChunks("Decoding input chunks", inputChunks);
|
|
dumpChunks("Decoding input chunks", inputChunks);
|
|
decoder.decode(inputChunks, getErasedIndexesForDecoding(), recoveredChunks);
|
|
decoder.decode(inputChunks, getErasedIndexesForDecoding(), recoveredChunks);
|
|
dumpChunks("Decoded/recovered chunks", recoveredChunks);
|
|
dumpChunks("Decoded/recovered chunks", recoveredChunks);
|
|
|
|
|
|
|
|
+ if (!allowChangeInputs) {
|
|
|
|
+ restoreChunksFromMark(inputChunks);
|
|
|
|
+ compareAndVerify(clonedInputChunks, inputChunks);
|
|
|
|
+ }
|
|
|
|
+
|
|
// Compare
|
|
// Compare
|
|
compareAndVerify(backupChunks, recoveredChunks);
|
|
compareAndVerify(backupChunks, recoveredChunks);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void setAllowChangeInputs(boolean allowChangeInputs) {
|
|
|
|
+ this.allowChangeInputs = allowChangeInputs;
|
|
|
|
+ encoder.setCoderOption(CoderOption.ALLOW_CHANGE_INPUTS, allowChangeInputs);
|
|
|
|
+ decoder.setCoderOption(CoderOption.ALLOW_CHANGE_INPUTS, allowChangeInputs);
|
|
|
|
+ }
|
|
|
|
+
|
|
private void prepareCoders() {
|
|
private void prepareCoders() {
|
|
if (encoder == null) {
|
|
if (encoder == null) {
|
|
encoder = createEncoder();
|
|
encoder = createEncoder();
|