sodonnel commented on a change in pull request #2341:
URL: https://github.com/apache/ozone/pull/2341#discussion_r656993110



##########
File path: 
hadoop-ozone/client/src/test/java/org/apache/hadoop/ozone/client/MockOmTransport.java
##########
@@ -116,13 +117,24 @@ public OMResponse submitRequest(OMRequest payload) throws 
IOException {
       return response(payload,
           r -> r.setServiceListResponse(
               serviceList(payload.getServiceListRequest())));
+    case AllocateBlock:
+      return response(payload, r -> r.setAllocateBlockResponse(
+          allocateBlock(payload.getAllocateBlockRequest())));
     default:
       throw new IllegalArgumentException(
           "Mock version of om call " + payload.getCmdType()
               + " is not yet implemented");
     }
   }
 
+  private OzoneManagerProtocolProtos.AllocateBlockResponse allocateBlock(
+      OzoneManagerProtocolProtos.AllocateBlockRequest allocateBlockRequest) {
+    return OzoneManagerProtocolProtos.AllocateBlockResponse.newBuilder()
+        .setKeyLocation(
+            blockAllocator.allocateBlock(allocateBlockRequest.getKeyArgs())
+                .iterator().next()).build();

Review comment:
       Looking at SinglePipelineBlockAllocator, I am not sure it can return 
multiple results, or that you can request multiple blocks in one go from the 
AllocateBlockRequest. However it does return an Iterable<>, so you have to call 
next on it as you have done.
   
   The response AllocateBlockResponse object just contains a single 
"KeyLocation", which contains a single "BlockID" and "Pipeline". Therefore I 
*think* your code is correct and it does not need a loop here.




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to