jojochuang commented on a change in pull request #2919:
URL: https://github.com/apache/ozone/pull/2919#discussion_r779264201



##########
File path: 
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/client/HddsClientUtils.java
##########
@@ -301,4 +320,46 @@ public static RetryPolicy createRetryPolicy(int 
maxRetryCount,
   public static List<Class<? extends Exception>> getExceptionList() {
     return EXCEPTION_LIST;
   }
+
+  /**
+   * Send RPC call to get the block info from the container.
+   * @return List of chunks in this block.
+   */
+  public static List<ContainerProtos.ChunkInfo> getChunkInfos(Pipeline 
pipeline,
+      BlockID blockID, Token<OzoneBlockTokenIdentifier> token,
+      XceiverClientFactory xceiverClientFactory, XceiverClientSpi xceiverClient
+  ) throws IOException {
+    // irrespective of the container state, we will always read via Standalone
+    // protocol.
+    if (pipeline.getType() != HddsProtos.ReplicationType.STAND_ALONE) {
+      pipeline = Pipeline.newBuilder(pipeline)
+          .setReplicationConfig(new StandaloneReplicationConfig(
+              ReplicationConfig
+                  .getLegacyFactor(pipeline.getReplicationConfig())))
+          .build();
+    }
+    xceiverClient = xceiverClientFactory.acquireClientForReadData(pipeline);
+    boolean success = false;
+    List<ContainerProtos.ChunkInfo> chunks;
+    try {
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Sending request to get key to access {}",
+            blockID.getContainerID());
+      }
+
+      ContainerProtos.DatanodeBlockID datanodeBlockID = blockID
+          .getDatanodeBlockIDProtobuf();
+      ContainerProtos.GetBlockResponseProto response = ContainerProtocolCalls
+          .getBlock(xceiverClient, datanodeBlockID, token);
+
+      chunks = response.getBlockData().getChunksList();
+      success = true;
+    } finally {
+      if (!success) {

Review comment:
       for BlockInputStream, this is not a problem because it checks and 
xceiverClient is released when the input stream is closed. File checksum 
computer will want to release it properly though.




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