use of org.apache.hadoop.ozone.container.common.helpers.ChunkInfo in project ozone by apache.
the class CommonChunkManagerTestCases method testWriteChunkIncorrectLength.
@Test
public void testWriteChunkIncorrectLength() {
// GIVEN
ChunkManager chunkManager = createTestSubject();
try {
long randomLength = 200L;
BlockID blockID = getBlockID();
ChunkInfo chunkInfo = new ChunkInfo(String.format("%d.data.%d", blockID.getLocalID(), 0), 0, randomLength);
chunkManager.writeChunk(getKeyValueContainer(), blockID, chunkInfo, getData(), getDispatcherContext());
// THEN
fail("testWriteChunkIncorrectLength failed");
} catch (StorageContainerException ex) {
// As we got an exception, writeBytes should be 0.
checkWriteIOStats(0, 0);
GenericTestUtils.assertExceptionContains("Unexpected buffer size", ex);
assertEquals(ContainerProtos.Result.INVALID_WRITE_SIZE, ex.getResult());
}
}
use of org.apache.hadoop.ozone.container.common.helpers.ChunkInfo in project ozone by apache.
the class CommonChunkManagerTestCases method testDeletePartialChunkUnsupportedRequest.
@Test
public void testDeletePartialChunkUnsupportedRequest() {
// GIVEN
ChunkManager chunkManager = createTestSubject();
try {
chunkManager.writeChunk(getKeyValueContainer(), getBlockID(), getChunkInfo(), getData(), getDispatcherContext());
long randomLength = 200L;
ChunkInfo chunkInfo = new ChunkInfo(String.format("%d.data.%d", getBlockID().getLocalID(), 0), 0, randomLength);
// WHEN
chunkManager.deleteChunk(getKeyValueContainer(), getBlockID(), chunkInfo);
// THEN
fail("testDeleteChunkUnsupportedRequest");
} catch (StorageContainerException ex) {
assertEquals(ContainerProtos.Result.UNSUPPORTED_REQUEST, ex.getResult());
}
}
use of org.apache.hadoop.ozone.container.common.helpers.ChunkInfo in project ozone by apache.
the class TestContainerPersistence method testPutBlock.
/**
* Tests a put block and read block.
*
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void testPutBlock() throws IOException, NoSuchAlgorithmException {
long testContainerID = getTestContainerID();
Container container = addContainer(containerSet, testContainerID);
BlockID blockID = ContainerTestHelper.getTestBlockID(testContainerID);
ChunkInfo info = writeChunkHelper(blockID);
BlockData blockData = new BlockData(blockID);
List<ContainerProtos.ChunkInfo> chunkList = new LinkedList<>();
chunkList.add(info.getProtoBufMessage());
blockData.setChunks(chunkList);
blockManager.putBlock(container, blockData);
BlockData readBlockData = blockManager.getBlock(container, blockData.getBlockID());
ChunkInfo readChunk = ChunkInfo.getFromProtoBuf(readBlockData.getChunks().get(0));
Assert.assertEquals(info.getChecksumData(), readChunk.getChecksumData());
}
use of org.apache.hadoop.ozone.container.common.helpers.ChunkInfo in project ozone by apache.
the class TestContainerPersistence method writeBlockHelper.
private BlockData writeBlockHelper(BlockID blockID, int i) throws IOException, NoSuchAlgorithmException {
ChunkInfo info = writeChunkHelper(blockID);
BlockData blockData = new BlockData(blockID);
blockData.setBlockCommitSequenceId((long) i);
List<ContainerProtos.ChunkInfo> chunkList = new LinkedList<>();
chunkList.add(info.getProtoBufMessage());
blockData.setChunks(chunkList);
return blockData;
}
use of org.apache.hadoop.ozone.container.common.helpers.ChunkInfo in project ozone by apache.
the class TestContainerPersistence method testDeleteChunk.
/**
* Writes a chunk and deletes it, re-reads to make sure it is gone.
*
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void testDeleteChunk() throws IOException, NoSuchAlgorithmException {
final int datalen = 1024;
long testContainerID = getTestContainerID();
Container container = addContainer(containerSet, testContainerID);
BlockID blockID = ContainerTestHelper.getTestBlockID(testContainerID);
ChunkInfo info = getChunk(blockID.getLocalID(), 1, 0, datalen);
ChunkBuffer data = getData(datalen);
setDataChecksum(info, data);
chunkManager.writeChunk(container, blockID, info, data, getDispatcherContext());
chunkManager.deleteChunk(container, blockID, info);
exception.expect(StorageContainerException.class);
chunkManager.readChunk(container, blockID, info, getDispatcherContext());
}
Aggregations