ChenSammi commented on code in PR #5978:
URL: https://github.com/apache/ozone/pull/5978#discussion_r1453040588
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/storage/ContainerProtocolCalls.java:
##########
@@ -292,6 +293,36 @@ public static XceiverClientReply
putBlockAsync(XceiverClientSpi xceiverClient,
return xceiverClient.sendCommandAsync(request);
}
+ /**
+ * Calls the container protocol to finalize a container block.
+ *
+ * @param xceiverClient client to perform call
+ * @param blockID block ID to identify block
+ * @param token a token for this block (may be null)
+ * @return FinalizeBlockResponseProto
+ * @throws IOException if there is an I/O error while performing the call
+ */
+ public static ContainerProtos.FinalizeBlockResponseProto finalizeBlock(
+ XceiverClientSpi xceiverClient, DatanodeBlockID blockID,
+ Token<OzoneBlockTokenIdentifier> token)
+ throws IOException {
+ FinalizeBlockRequestProto.Builder finalizeBlockRequest =
+ FinalizeBlockRequestProto.newBuilder().setBlockID(blockID);
+ String id = xceiverClient.getPipeline().getFirstNode().getUuidString();
+ ContainerCommandRequestProto.Builder builder =
+
ContainerCommandRequestProto.newBuilder().setCmdType(Type.FinalizeBlock)
+ .setContainerID(blockID.getContainerID())
+ .setDatanodeUuid(id)
+ .setFinalizeBlock(finalizeBlockRequest);
+ if (token != null) {
+ builder.setEncodedToken(token.encodeToUrlString());
+ }
+ ContainerCommandRequestProto request = builder.build();
+ ContainerCommandResponseProto response =
Review Comment:
xceiverClient.sendCommand will handle the retry internally.
--
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]