rich7420 commented on code in PR #11491:
URL: https://github.com/apache/ozone/pull/11491#discussion_r4255184352
##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/keyvalue/TestKeyValueHandler.java:
##########
@@ -1143,7 +1160,99 @@ private HandlerWithVolumeSet
createKeyValueHandlerWithVolumeSet(Path path) throw
conf.getObject(ContainerScannerConfiguration.class), controller);
containerSet.registerOnDemandScanner(onDemandScanner);
- return new HandlerWithVolumeSet(kvHandler, volumeSet, containerSet);
+ return new HandlerWithVolumeSet(kvHandler, volumeSet, containerSet,
containerMetrics);
+ }
+
+ private HddsDispatcher createGetBlockDispatcher(HandlerWithVolumeSet
handlerWithVolume) throws IOException {
+ DatanodeDetails datanodeDetails =
+
MockDatanodeDetails.createDatanodeDetails(DatanodeID.fromUuidString(DATANODE_UUID));
+ StateContext context = ContainerTestUtils.getMockContext(datanodeDetails,
conf);
+ HashMap<ContainerType, Handler> handlers = new HashMap<>();
+ handlers.put(ContainerType.KeyValueContainer,
handlerWithVolume.getHandler());
+ return new HddsDispatcher(conf, handlerWithVolume.getContainerSet(),
handlerWithVolume.getVolumeSet(), handlers,
+ context, handlerWithVolume.getContainerMetrics(), null);
+ }
+
+ private void writeTestBlockForGetBlock(
+ KeyValueHandler kvHandler, KeyValueContainer container, BlockID blockID)
throws IOException {
+ BlockData blockData = new BlockData(blockID);
+ ChunkInfo chunkInfo = new ChunkInfo("chunk1", 0, GET_BLOCK_TEST_CHUNK_LEN);
+ blockData.addChunk(chunkInfo.getProtoBufMessage());
+ kvHandler.getBlockManager().putBlock(container, blockData);
+ ChunkBuffer data =
ChunkBuffer.wrap(ByteBuffer.allocate(GET_BLOCK_TEST_CHUNK_LEN));
+ kvHandler.getChunkManager().writeChunk(container, blockID, chunkInfo, data,
+ DispatcherContext.getHandleWriteChunk());
+ }
+
+ private static ContainerCommandRequestProto newGetBlockRequest(
+ long containerID, BlockID blockID, boolean requestShortCircuitAccess) {
+ ContainerProtos.GetBlockRequestProto.Builder getBlock =
ContainerProtos.GetBlockRequestProto.newBuilder()
+ .setBlockID(blockID.getDatanodeBlockIDProtobuf());
+ if (requestShortCircuitAccess) {
+ getBlock.setRequestShortCircuitAccess(true);
+ }
+ return ContainerCommandRequestProto.newBuilder()
+ .setCmdType(ContainerProtos.Type.GetBlock)
+ .setContainerID(containerID)
+ .setDatanodeUuid(DATANODE_UUID)
+ .setGetBlock(getBlock)
+ .build();
+ }
+
+ private static void enableShortCircuitRead(KeyValueHandler handler) throws
Exception {
+ OzoneContainer ozoneContainer = mock(OzoneContainer.class);
+ XceiverServerSpi domainSocketServer = mock(XceiverServerSpi.class);
+
when(ozoneContainer.getReadDomainSocketChannel()).thenReturn(domainSocketServer);
+ when(domainSocketServer.isStarted()).thenReturn(true);
+ Field field = KeyValueHandler.class.getDeclaredField("ozoneContainer");
Review Comment:
nit: Could we pass `OzoneContainer` through the existing constructor to
avoid reflection?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]