|
@@ -66,19 +66,19 @@ public class TestDFSStripedInputStream {
|
|
|
private Path filePath = new Path(dirPath, "file");
|
|
|
private final ErasureCodingPolicy ecPolicy =
|
|
|
ErasureCodingPolicyManager.getSystemDefaultPolicy();
|
|
|
- private final short DATA_BLK_NUM = StripedFileTestUtil.NUM_DATA_BLOCKS;
|
|
|
- private final short PARITY_BLK_NUM = StripedFileTestUtil.NUM_PARITY_BLOCKS;
|
|
|
- private final int CELLSIZE = StripedFileTestUtil.BLOCK_STRIPED_CELL_SIZE;
|
|
|
- private final int NUM_STRIPE_PER_BLOCK = 2;
|
|
|
- private final int INTERNAL_BLOCK_SIZE = NUM_STRIPE_PER_BLOCK * CELLSIZE;
|
|
|
- private final int BLOCK_GROUP_SIZE = DATA_BLK_NUM * INTERNAL_BLOCK_SIZE;
|
|
|
+ private final short dataBlocks = (short) ecPolicy.getNumDataUnits();
|
|
|
+ private final short parityBlocks = (short) ecPolicy.getNumParityUnits();
|
|
|
+ private final int cellSize = ecPolicy.getCellSize();
|
|
|
+ private final int stripesPerBlock = 2;
|
|
|
+ private final int blockSize = stripesPerBlock * cellSize;
|
|
|
+ private final int blockGroupSize = dataBlocks * blockSize;
|
|
|
|
|
|
@Rule
|
|
|
public Timeout globalTimeout = new Timeout(300000);
|
|
|
|
|
|
@Before
|
|
|
public void setup() throws IOException {
|
|
|
- conf.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, INTERNAL_BLOCK_SIZE);
|
|
|
+ conf.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, blockSize);
|
|
|
conf.setInt(DFSConfigKeys.DFS_NAMENODE_REPLICATION_MAX_STREAMS_KEY, 0);
|
|
|
if (ErasureCodeNative.isNativeCodeLoaded()) {
|
|
|
conf.set(
|
|
@@ -87,7 +87,7 @@ public class TestDFSStripedInputStream {
|
|
|
}
|
|
|
SimulatedFSDataset.setFactory(conf);
|
|
|
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(
|
|
|
- DATA_BLK_NUM + PARITY_BLK_NUM).build();
|
|
|
+ dataBlocks + parityBlocks).build();
|
|
|
cluster.waitActive();
|
|
|
for (DataNode dn : cluster.getDataNodes()) {
|
|
|
DataNodeTestUtils.setHeartbeatsDisabledForTests(dn, true);
|
|
@@ -112,9 +112,9 @@ public class TestDFSStripedInputStream {
|
|
|
public void testRefreshBlock() throws Exception {
|
|
|
final int numBlocks = 4;
|
|
|
DFSTestUtil.createStripedFile(cluster, filePath, null, numBlocks,
|
|
|
- NUM_STRIPE_PER_BLOCK, false);
|
|
|
+ stripesPerBlock, false);
|
|
|
LocatedBlocks lbs = fs.getClient().namenode.getBlockLocations(
|
|
|
- filePath.toString(), 0, BLOCK_GROUP_SIZE * numBlocks);
|
|
|
+ filePath.toString(), 0, blockGroupSize * numBlocks);
|
|
|
final DFSStripedInputStream in = new DFSStripedInputStream(fs.getClient(),
|
|
|
filePath.toString(), false, ecPolicy, null);
|
|
|
|
|
@@ -122,8 +122,8 @@ public class TestDFSStripedInputStream {
|
|
|
for (LocatedBlock aLbList : lbList) {
|
|
|
LocatedStripedBlock lsb = (LocatedStripedBlock) aLbList;
|
|
|
LocatedBlock[] blks = StripedBlockUtil.parseStripedBlockGroup(lsb,
|
|
|
- CELLSIZE, DATA_BLK_NUM, PARITY_BLK_NUM);
|
|
|
- for (int j = 0; j < DATA_BLK_NUM; j++) {
|
|
|
+ cellSize, dataBlocks, parityBlocks);
|
|
|
+ for (int j = 0; j < dataBlocks; j++) {
|
|
|
LocatedBlock refreshed = in.refreshLocatedBlock(blks[j]);
|
|
|
assertEquals(blks[j].getBlock(), refreshed.getBlock());
|
|
|
assertEquals(blks[j].getStartOffset(), refreshed.getStartOffset());
|
|
@@ -136,18 +136,18 @@ public class TestDFSStripedInputStream {
|
|
|
public void testPread() throws Exception {
|
|
|
final int numBlocks = 2;
|
|
|
DFSTestUtil.createStripedFile(cluster, filePath, null, numBlocks,
|
|
|
- NUM_STRIPE_PER_BLOCK, false);
|
|
|
+ stripesPerBlock, false);
|
|
|
LocatedBlocks lbs = fs.getClient().namenode.getBlockLocations(
|
|
|
- filePath.toString(), 0, BLOCK_GROUP_SIZE * numBlocks);
|
|
|
- int fileLen = BLOCK_GROUP_SIZE * numBlocks;
|
|
|
+ filePath.toString(), 0, blockGroupSize * numBlocks);
|
|
|
+ int fileLen = blockGroupSize * numBlocks;
|
|
|
|
|
|
byte[] expected = new byte[fileLen];
|
|
|
assertEquals(numBlocks, lbs.getLocatedBlocks().size());
|
|
|
for (int bgIdx = 0; bgIdx < numBlocks; bgIdx++) {
|
|
|
LocatedStripedBlock bg = (LocatedStripedBlock) (lbs.get(bgIdx));
|
|
|
- for (int i = 0; i < DATA_BLK_NUM; i++) {
|
|
|
+ for (int i = 0; i < dataBlocks; i++) {
|
|
|
Block blk = new Block(bg.getBlock().getBlockId() + i,
|
|
|
- NUM_STRIPE_PER_BLOCK * CELLSIZE,
|
|
|
+ stripesPerBlock * cellSize,
|
|
|
bg.getBlock().getGenerationStamp());
|
|
|
blk.setGenerationStamp(bg.getBlock().getGenerationStamp());
|
|
|
cluster.injectBlocks(i, Arrays.asList(blk),
|
|
@@ -155,12 +155,12 @@ public class TestDFSStripedInputStream {
|
|
|
}
|
|
|
|
|
|
/** A variation of {@link DFSTestUtil#fillExpectedBuf} for striped blocks */
|
|
|
- for (int i = 0; i < NUM_STRIPE_PER_BLOCK; i++) {
|
|
|
- for (int j = 0; j < DATA_BLK_NUM; j++) {
|
|
|
- for (int k = 0; k < CELLSIZE; k++) {
|
|
|
- int posInBlk = i * CELLSIZE + k;
|
|
|
- int posInFile = i * CELLSIZE * DATA_BLK_NUM + j * CELLSIZE + k;
|
|
|
- expected[bgIdx*BLOCK_GROUP_SIZE + posInFile] =
|
|
|
+ for (int i = 0; i < stripesPerBlock; i++) {
|
|
|
+ for (int j = 0; j < dataBlocks; j++) {
|
|
|
+ for (int k = 0; k < cellSize; k++) {
|
|
|
+ int posInBlk = i * cellSize + k;
|
|
|
+ int posInFile = i * cellSize * dataBlocks + j * cellSize + k;
|
|
|
+ expected[bgIdx * blockGroupSize + posInFile] =
|
|
|
SimulatedFSDataset.simulatedByte(
|
|
|
new Block(bg.getBlock().getBlockId() + j), posInBlk);
|
|
|
}
|
|
@@ -170,9 +170,9 @@ public class TestDFSStripedInputStream {
|
|
|
DFSStripedInputStream in = new DFSStripedInputStream(fs.getClient(),
|
|
|
filePath.toString(), false, ecPolicy, null);
|
|
|
|
|
|
- int[] startOffsets = {0, 1, CELLSIZE - 102, CELLSIZE, CELLSIZE + 102,
|
|
|
- CELLSIZE*DATA_BLK_NUM, CELLSIZE*DATA_BLK_NUM + 102,
|
|
|
- BLOCK_GROUP_SIZE - 102, BLOCK_GROUP_SIZE, BLOCK_GROUP_SIZE + 102,
|
|
|
+ int[] startOffsets = {0, 1, cellSize - 102, cellSize, cellSize + 102,
|
|
|
+ cellSize * dataBlocks, cellSize * dataBlocks + 102,
|
|
|
+ blockGroupSize - 102, blockGroupSize, blockGroupSize + 102,
|
|
|
fileLen - 1};
|
|
|
for (int startOffset : startOffsets) {
|
|
|
startOffset = Math.max(0, Math.min(startOffset, fileLen - 1));
|
|
@@ -192,17 +192,17 @@ public class TestDFSStripedInputStream {
|
|
|
@Test
|
|
|
public void testPreadWithDNFailure() throws Exception {
|
|
|
final int numBlocks = 4;
|
|
|
- final int failedDNIdx = DATA_BLK_NUM - 1;
|
|
|
+ final int failedDNIdx = dataBlocks - 1;
|
|
|
DFSTestUtil.createStripedFile(cluster, filePath, null, numBlocks,
|
|
|
- NUM_STRIPE_PER_BLOCK, false);
|
|
|
+ stripesPerBlock, false);
|
|
|
LocatedBlocks lbs = fs.getClient().namenode.getBlockLocations(
|
|
|
- filePath.toString(), 0, BLOCK_GROUP_SIZE);
|
|
|
+ filePath.toString(), 0, blockGroupSize);
|
|
|
|
|
|
assert lbs.get(0) instanceof LocatedStripedBlock;
|
|
|
LocatedStripedBlock bg = (LocatedStripedBlock)(lbs.get(0));
|
|
|
- for (int i = 0; i < DATA_BLK_NUM + PARITY_BLK_NUM; i++) {
|
|
|
+ for (int i = 0; i < dataBlocks + parityBlocks; i++) {
|
|
|
Block blk = new Block(bg.getBlock().getBlockId() + i,
|
|
|
- NUM_STRIPE_PER_BLOCK * CELLSIZE,
|
|
|
+ stripesPerBlock * cellSize,
|
|
|
bg.getBlock().getGenerationStamp());
|
|
|
blk.setGenerationStamp(bg.getBlock().getGenerationStamp());
|
|
|
cluster.injectBlocks(i, Arrays.asList(blk),
|
|
@@ -211,15 +211,15 @@ public class TestDFSStripedInputStream {
|
|
|
DFSStripedInputStream in =
|
|
|
new DFSStripedInputStream(fs.getClient(), filePath.toString(), false,
|
|
|
ecPolicy, null);
|
|
|
- int readSize = BLOCK_GROUP_SIZE;
|
|
|
+ int readSize = blockGroupSize;
|
|
|
byte[] readBuffer = new byte[readSize];
|
|
|
byte[] expected = new byte[readSize];
|
|
|
/** A variation of {@link DFSTestUtil#fillExpectedBuf} for striped blocks */
|
|
|
- for (int i = 0; i < NUM_STRIPE_PER_BLOCK; i++) {
|
|
|
- for (int j = 0; j < DATA_BLK_NUM; j++) {
|
|
|
- for (int k = 0; k < CELLSIZE; k++) {
|
|
|
- int posInBlk = i * CELLSIZE + k;
|
|
|
- int posInFile = i * CELLSIZE * DATA_BLK_NUM + j * CELLSIZE + k;
|
|
|
+ for (int i = 0; i < stripesPerBlock; i++) {
|
|
|
+ for (int j = 0; j < dataBlocks; j++) {
|
|
|
+ for (int k = 0; k < cellSize; k++) {
|
|
|
+ int posInBlk = i * cellSize + k;
|
|
|
+ int posInFile = i * cellSize * dataBlocks + j * cellSize + k;
|
|
|
expected[posInFile] = SimulatedFSDataset.simulatedByte(
|
|
|
new Block(bg.getBlock().getBlockId() + j), posInBlk);
|
|
|
}
|
|
@@ -227,32 +227,32 @@ public class TestDFSStripedInputStream {
|
|
|
}
|
|
|
|
|
|
ErasureCoderOptions coderOptions = new ErasureCoderOptions(
|
|
|
- DATA_BLK_NUM, PARITY_BLK_NUM);
|
|
|
+ dataBlocks, parityBlocks);
|
|
|
RawErasureDecoder rawDecoder = CodecUtil.createRawDecoder(conf,
|
|
|
ecPolicy.getCodecName(), coderOptions);
|
|
|
|
|
|
// Update the expected content for decoded data
|
|
|
- int[] missingBlkIdx = new int[PARITY_BLK_NUM];
|
|
|
+ int[] missingBlkIdx = new int[parityBlocks];
|
|
|
for (int i = 0; i < missingBlkIdx.length; i++) {
|
|
|
if (i == 0) {
|
|
|
missingBlkIdx[i] = failedDNIdx;
|
|
|
} else {
|
|
|
- missingBlkIdx[i] = DATA_BLK_NUM + i;
|
|
|
+ missingBlkIdx[i] = dataBlocks + i;
|
|
|
}
|
|
|
}
|
|
|
cluster.stopDataNode(failedDNIdx);
|
|
|
- for (int i = 0; i < NUM_STRIPE_PER_BLOCK; i++) {
|
|
|
- byte[][] decodeInputs = new byte[DATA_BLK_NUM + PARITY_BLK_NUM][CELLSIZE];
|
|
|
- byte[][] decodeOutputs = new byte[missingBlkIdx.length][CELLSIZE];
|
|
|
- for (int j = 0; j < DATA_BLK_NUM; j++) {
|
|
|
- int posInBuf = i * CELLSIZE * DATA_BLK_NUM + j * CELLSIZE;
|
|
|
+ for (int i = 0; i < stripesPerBlock; i++) {
|
|
|
+ byte[][] decodeInputs = new byte[dataBlocks + parityBlocks][cellSize];
|
|
|
+ byte[][] decodeOutputs = new byte[missingBlkIdx.length][cellSize];
|
|
|
+ for (int j = 0; j < dataBlocks; j++) {
|
|
|
+ int posInBuf = i * cellSize * dataBlocks + j * cellSize;
|
|
|
if (j != failedDNIdx) {
|
|
|
- System.arraycopy(expected, posInBuf, decodeInputs[j], 0, CELLSIZE);
|
|
|
+ System.arraycopy(expected, posInBuf, decodeInputs[j], 0, cellSize);
|
|
|
}
|
|
|
}
|
|
|
- for (int j = DATA_BLK_NUM; j < DATA_BLK_NUM + PARITY_BLK_NUM; j++) {
|
|
|
- for (int k = 0; k < CELLSIZE; k++) {
|
|
|
- int posInBlk = i * CELLSIZE + k;
|
|
|
+ for (int j = dataBlocks; j < dataBlocks + parityBlocks; j++) {
|
|
|
+ for (int k = 0; k < cellSize; k++) {
|
|
|
+ int posInBlk = i * cellSize + k;
|
|
|
decodeInputs[j][k] = SimulatedFSDataset.simulatedByte(
|
|
|
new Block(bg.getBlock().getBlockId() + j), posInBlk);
|
|
|
}
|
|
@@ -261,8 +261,8 @@ public class TestDFSStripedInputStream {
|
|
|
decodeInputs[m] = null;
|
|
|
}
|
|
|
rawDecoder.decode(decodeInputs, missingBlkIdx, decodeOutputs);
|
|
|
- int posInBuf = i * CELLSIZE * DATA_BLK_NUM + failedDNIdx * CELLSIZE;
|
|
|
- System.arraycopy(decodeOutputs[0], 0, expected, posInBuf, CELLSIZE);
|
|
|
+ int posInBuf = i * cellSize * dataBlocks + failedDNIdx * cellSize;
|
|
|
+ System.arraycopy(decodeOutputs[0], 0, expected, posInBuf, cellSize);
|
|
|
}
|
|
|
|
|
|
int delta = 10;
|
|
@@ -278,8 +278,8 @@ public class TestDFSStripedInputStream {
|
|
|
// |c_0 |c_1 |c_2 |c_3 |c_4 |c_5 |
|
|
|
// |256K - 10|missing|256K|256K|256K - 10|not in range|
|
|
|
done += in.read(delta, readBuffer, delta,
|
|
|
- CELLSIZE * (DATA_BLK_NUM - 1) - 2 * delta);
|
|
|
- assertEquals(CELLSIZE * (DATA_BLK_NUM - 1) - delta, done);
|
|
|
+ cellSize * (dataBlocks - 1) - 2 * delta);
|
|
|
+ assertEquals(cellSize * (dataBlocks - 1) - delta, done);
|
|
|
assertArrayEquals(Arrays.copyOf(expected, done),
|
|
|
Arrays.copyOf(readBuffer, done));
|
|
|
// read the rest
|
|
@@ -298,14 +298,14 @@ public class TestDFSStripedInputStream {
|
|
|
private void testStatefulRead(boolean useByteBuffer,
|
|
|
boolean cellMisalignPacket) throws Exception {
|
|
|
final int numBlocks = 2;
|
|
|
- final int fileSize = numBlocks * BLOCK_GROUP_SIZE;
|
|
|
+ final int fileSize = numBlocks * blockGroupSize;
|
|
|
if (cellMisalignPacket) {
|
|
|
conf.setInt(IO_FILE_BUFFER_SIZE_KEY, IO_FILE_BUFFER_SIZE_DEFAULT + 1);
|
|
|
tearDown();
|
|
|
setup();
|
|
|
}
|
|
|
DFSTestUtil.createStripedFile(cluster, filePath, null, numBlocks,
|
|
|
- NUM_STRIPE_PER_BLOCK, false);
|
|
|
+ stripesPerBlock, false);
|
|
|
LocatedBlocks lbs = fs.getClient().namenode.
|
|
|
getBlockLocations(filePath.toString(), 0, fileSize);
|
|
|
|
|
@@ -313,9 +313,9 @@ public class TestDFSStripedInputStream {
|
|
|
for (LocatedBlock lb : lbs.getLocatedBlocks()) {
|
|
|
assert lb instanceof LocatedStripedBlock;
|
|
|
LocatedStripedBlock bg = (LocatedStripedBlock)(lb);
|
|
|
- for (int i = 0; i < DATA_BLK_NUM; i++) {
|
|
|
+ for (int i = 0; i < dataBlocks; i++) {
|
|
|
Block blk = new Block(bg.getBlock().getBlockId() + i,
|
|
|
- NUM_STRIPE_PER_BLOCK * CELLSIZE,
|
|
|
+ stripesPerBlock * cellSize,
|
|
|
bg.getBlock().getGenerationStamp());
|
|
|
blk.setGenerationStamp(bg.getBlock().getGenerationStamp());
|
|
|
cluster.injectBlocks(i, Arrays.asList(blk),
|
|
@@ -331,12 +331,12 @@ public class TestDFSStripedInputStream {
|
|
|
|
|
|
for (LocatedBlock bg : lbs.getLocatedBlocks()) {
|
|
|
/** A variation of {@link DFSTestUtil#fillExpectedBuf} for striped blocks */
|
|
|
- for (int i = 0; i < NUM_STRIPE_PER_BLOCK; i++) {
|
|
|
- for (int j = 0; j < DATA_BLK_NUM; j++) {
|
|
|
- for (int k = 0; k < CELLSIZE; k++) {
|
|
|
- int posInBlk = i * CELLSIZE + k;
|
|
|
+ for (int i = 0; i < stripesPerBlock; i++) {
|
|
|
+ for (int j = 0; j < dataBlocks; j++) {
|
|
|
+ for (int k = 0; k < cellSize; k++) {
|
|
|
+ int posInBlk = i * cellSize + k;
|
|
|
int posInFile = (int) bg.getStartOffset() +
|
|
|
- i * CELLSIZE * DATA_BLK_NUM + j * CELLSIZE + k;
|
|
|
+ i * cellSize * dataBlocks + j * cellSize + k;
|
|
|
expected[posInFile] = SimulatedFSDataset.simulatedByte(
|
|
|
new Block(bg.getBlock().getBlockId() + j), posInBlk);
|
|
|
}
|
|
@@ -369,17 +369,17 @@ public class TestDFSStripedInputStream {
|
|
|
@Test
|
|
|
public void testStatefulReadWithDNFailure() throws Exception {
|
|
|
final int numBlocks = 4;
|
|
|
- final int failedDNIdx = DATA_BLK_NUM - 1;
|
|
|
+ final int failedDNIdx = dataBlocks - 1;
|
|
|
DFSTestUtil.createStripedFile(cluster, filePath, null, numBlocks,
|
|
|
- NUM_STRIPE_PER_BLOCK, false);
|
|
|
+ stripesPerBlock, false);
|
|
|
LocatedBlocks lbs = fs.getClient().namenode.getBlockLocations(
|
|
|
- filePath.toString(), 0, BLOCK_GROUP_SIZE);
|
|
|
+ filePath.toString(), 0, blockGroupSize);
|
|
|
|
|
|
assert lbs.get(0) instanceof LocatedStripedBlock;
|
|
|
LocatedStripedBlock bg = (LocatedStripedBlock) (lbs.get(0));
|
|
|
- for (int i = 0; i < DATA_BLK_NUM + PARITY_BLK_NUM; i++) {
|
|
|
+ for (int i = 0; i < dataBlocks + parityBlocks; i++) {
|
|
|
Block blk = new Block(bg.getBlock().getBlockId() + i,
|
|
|
- NUM_STRIPE_PER_BLOCK * CELLSIZE,
|
|
|
+ stripesPerBlock * cellSize,
|
|
|
bg.getBlock().getGenerationStamp());
|
|
|
blk.setGenerationStamp(bg.getBlock().getGenerationStamp());
|
|
|
cluster.injectBlocks(i, Arrays.asList(blk),
|
|
@@ -388,15 +388,15 @@ public class TestDFSStripedInputStream {
|
|
|
DFSStripedInputStream in =
|
|
|
new DFSStripedInputStream(fs.getClient(), filePath.toString(), false,
|
|
|
ecPolicy, null);
|
|
|
- int readSize = BLOCK_GROUP_SIZE;
|
|
|
+ int readSize = blockGroupSize;
|
|
|
byte[] readBuffer = new byte[readSize];
|
|
|
byte[] expected = new byte[readSize];
|
|
|
/** A variation of {@link DFSTestUtil#fillExpectedBuf} for striped blocks */
|
|
|
- for (int i = 0; i < NUM_STRIPE_PER_BLOCK; i++) {
|
|
|
- for (int j = 0; j < DATA_BLK_NUM; j++) {
|
|
|
- for (int k = 0; k < CELLSIZE; k++) {
|
|
|
- int posInBlk = i * CELLSIZE + k;
|
|
|
- int posInFile = i * CELLSIZE * DATA_BLK_NUM + j * CELLSIZE + k;
|
|
|
+ for (int i = 0; i < stripesPerBlock; i++) {
|
|
|
+ for (int j = 0; j < dataBlocks; j++) {
|
|
|
+ for (int k = 0; k < cellSize; k++) {
|
|
|
+ int posInBlk = i * cellSize + k;
|
|
|
+ int posInFile = i * cellSize * dataBlocks + j * cellSize + k;
|
|
|
expected[posInFile] = SimulatedFSDataset.simulatedByte(
|
|
|
new Block(bg.getBlock().getBlockId() + j), posInBlk);
|
|
|
}
|
|
@@ -404,32 +404,32 @@ public class TestDFSStripedInputStream {
|
|
|
}
|
|
|
|
|
|
ErasureCoderOptions coderOptions = new ErasureCoderOptions(
|
|
|
- DATA_BLK_NUM, PARITY_BLK_NUM);
|
|
|
+ dataBlocks, parityBlocks);
|
|
|
RawErasureDecoder rawDecoder = CodecUtil.createRawDecoder(conf,
|
|
|
ecPolicy.getCodecName(), coderOptions);
|
|
|
|
|
|
// Update the expected content for decoded data
|
|
|
- int[] missingBlkIdx = new int[PARITY_BLK_NUM];
|
|
|
+ int[] missingBlkIdx = new int[parityBlocks];
|
|
|
for (int i = 0; i < missingBlkIdx.length; i++) {
|
|
|
if (i == 0) {
|
|
|
missingBlkIdx[i] = failedDNIdx;
|
|
|
} else {
|
|
|
- missingBlkIdx[i] = DATA_BLK_NUM + i;
|
|
|
+ missingBlkIdx[i] = dataBlocks + i;
|
|
|
}
|
|
|
}
|
|
|
cluster.stopDataNode(failedDNIdx);
|
|
|
- for (int i = 0; i < NUM_STRIPE_PER_BLOCK; i++) {
|
|
|
- byte[][] decodeInputs = new byte[DATA_BLK_NUM + PARITY_BLK_NUM][CELLSIZE];
|
|
|
- byte[][] decodeOutputs = new byte[missingBlkIdx.length][CELLSIZE];
|
|
|
- for (int j = 0; j < DATA_BLK_NUM; j++) {
|
|
|
- int posInBuf = i * CELLSIZE * DATA_BLK_NUM + j * CELLSIZE;
|
|
|
+ for (int i = 0; i < stripesPerBlock; i++) {
|
|
|
+ byte[][] decodeInputs = new byte[dataBlocks + parityBlocks][cellSize];
|
|
|
+ byte[][] decodeOutputs = new byte[missingBlkIdx.length][cellSize];
|
|
|
+ for (int j = 0; j < dataBlocks; j++) {
|
|
|
+ int posInBuf = i * cellSize * dataBlocks + j * cellSize;
|
|
|
if (j != failedDNIdx) {
|
|
|
- System.arraycopy(expected, posInBuf, decodeInputs[j], 0, CELLSIZE);
|
|
|
+ System.arraycopy(expected, posInBuf, decodeInputs[j], 0, cellSize);
|
|
|
}
|
|
|
}
|
|
|
- for (int j = DATA_BLK_NUM; j < DATA_BLK_NUM + PARITY_BLK_NUM; j++) {
|
|
|
- for (int k = 0; k < CELLSIZE; k++) {
|
|
|
- int posInBlk = i * CELLSIZE + k;
|
|
|
+ for (int j = dataBlocks; j < dataBlocks + parityBlocks; j++) {
|
|
|
+ for (int k = 0; k < cellSize; k++) {
|
|
|
+ int posInBlk = i * cellSize + k;
|
|
|
decodeInputs[j][k] = SimulatedFSDataset.simulatedByte(
|
|
|
new Block(bg.getBlock().getBlockId() + j), posInBlk);
|
|
|
}
|
|
@@ -438,8 +438,8 @@ public class TestDFSStripedInputStream {
|
|
|
decodeInputs[m] = null;
|
|
|
}
|
|
|
rawDecoder.decode(decodeInputs, missingBlkIdx, decodeOutputs);
|
|
|
- int posInBuf = i * CELLSIZE * DATA_BLK_NUM + failedDNIdx * CELLSIZE;
|
|
|
- System.arraycopy(decodeOutputs[0], 0, expected, posInBuf, CELLSIZE);
|
|
|
+ int posInBuf = i * cellSize * dataBlocks + failedDNIdx * cellSize;
|
|
|
+ System.arraycopy(decodeOutputs[0], 0, expected, posInBuf, cellSize);
|
|
|
}
|
|
|
|
|
|
int delta = 10;
|
|
@@ -452,13 +452,13 @@ public class TestDFSStripedInputStream {
|
|
|
// both head and trail cells are partial
|
|
|
// |c_0 |c_1 |c_2 |c_3 |c_4 |c_5 |
|
|
|
// |256K - 10|missing|256K|256K|256K - 10|not in range|
|
|
|
- while (done < (CELLSIZE * (DATA_BLK_NUM - 1) - 2 * delta)) {
|
|
|
+ while (done < (cellSize * (dataBlocks - 1) - 2 * delta)) {
|
|
|
int ret = in.read(readBuffer, delta,
|
|
|
- CELLSIZE * (DATA_BLK_NUM - 1) - 2 * delta);
|
|
|
+ cellSize * (dataBlocks - 1) - 2 * delta);
|
|
|
assertTrue(ret > 0);
|
|
|
done += ret;
|
|
|
}
|
|
|
- assertEquals(CELLSIZE * (DATA_BLK_NUM - 1) - delta, done);
|
|
|
+ assertEquals(cellSize * (dataBlocks - 1) - delta, done);
|
|
|
// read the rest
|
|
|
|
|
|
int restSize;
|