adoroszlai commented on code in PR #5908:
URL: https://github.com/apache/ozone/pull/5908#discussion_r1440402354


##########
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockOutputStream.java:
##########
@@ -166,6 +167,8 @@ public BlockOutputStream(
     this.xceiverClient = xceiverClientManager.acquireClient(pipeline);
     this.bufferPool = bufferPool;
     this.token = token;
+    this.tokenString = (this.token == null) ? null :
+        this.token.encodeToUrlString();

Review Comment:
   The same improvement can be done in `BlockDataStreamOutput`:
   
   
https://github.com/apache/ozone/blob/9f475809d24598cd2b99fa62af93e638ab31860b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockDataStreamOutput.java#L210-L211
   
   
https://github.com/apache/ozone/blob/9f475809d24598cd2b99fa62af93e638ab31860b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockDataStreamOutput.java#L422-L423
   
   
https://github.com/apache/ozone/blob/9f475809d24598cd2b99fa62af93e638ab31860b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockDataStreamOutput.java#L439-L440



##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/storage/ContainerProtocolCalls.java:
##########
@@ -292,6 +292,34 @@ public static XceiverClientReply 
putBlockAsync(XceiverClientSpi xceiverClient,
     return xceiverClient.sendCommandAsync(request);
   }
 
+  static XceiverClientReply putBlockAsync(XceiverClientSpi xceiverClient,
+                                                 BlockData containerBlockData, 
boolean eof,
+                                                 String tokenString)
+      throws IOException, InterruptedException, ExecutionException {
+    final ContainerCommandRequestProto request = getPutBlockRequest(
+        xceiverClient.getPipeline(), containerBlockData, eof, tokenString);
+    return xceiverClient.sendCommandAsync(request);
+  }
+
+  public static ContainerCommandRequestProto getPutBlockRequest(
+      Pipeline pipeline, BlockData containerBlockData, boolean eof,
+      String tokenString) throws IOException {
+    PutBlockRequestProto.Builder createBlockRequest =
+        PutBlockRequestProto.newBuilder()
+            .setBlockData(containerBlockData)
+            .setEof(eof);
+    final String id = pipeline.getFirstNode().getUuidString();
+    ContainerCommandRequestProto.Builder builder =
+        ContainerCommandRequestProto.newBuilder().setCmdType(Type.PutBlock)
+            .setContainerID(containerBlockData.getBlockID().getContainerID())
+            .setDatanodeUuid(id)
+            .setPutBlock(createBlockRequest);

Review Comment:
   Duplicating this part can be avoided by calling the new method from the 
existing one:
   
   ```java
     public static ContainerCommandRequestProto getPutBlockRequest(
         Pipeline pipeline, BlockData containerBlockData, boolean eof,
         Token<? extends TokenIdentifier> token) throws IOException {
       final String tokenString = token != null ? token.encodeToUrlString() : 
null;
       return getPutBlockRequest(pipeline, containerBlockData, eof, 
tokenString);
     }
   ```



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

Reply via email to