ChenSammi commented on code in PR #5978:
URL: https://github.com/apache/ozone/pull/5978#discussion_r1456853157
##########
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneClientAdapterImpl.java:
##########
@@ -748,6 +758,52 @@ public void recoverFile(OmKeyArgs keyArgs) throws
IOException {
ozoneClient.getProxy().getOzoneManagerClient().recoverKey(keyArgs, 0L);
}
+ @Override
+ public long finalizeBlock(OmKeyLocationInfo block) throws IOException {
+ incrementCounter(Statistic.INVOCATION_FINALIZE_BLOCK, 1);
+ RpcClient rpcClient = (RpcClient) ozoneClient.getProxy();
+ XceiverClientFactory xceiverClientFactory =
rpcClient.getXceiverClientManager();
+ Pipeline pipeline = block.getPipeline();
+ XceiverClientSpi client = null;
+ try {
+ // If pipeline is still open
+ if (pipeline.isOpen()) {
+ client = xceiverClientFactory.acquireClient(pipeline);
+ ContainerProtos.FinalizeBlockResponseProto finalizeBlockResponseProto =
+ ContainerProtocolCalls.finalizeBlock(client,
block.getBlockID().getDatanodeBlockIDProtobuf(),
+ block.getToken());
+ return
BlockData.getFromProtoBuf(finalizeBlockResponseProto.getBlockData()).getSize();
+ }
+ } catch (IOException e) {
+ LOG.warn("Failed to execute finalizeBlock command", e);
Review Comment:
Checking CLOSED state replica is my initial idea too. Then later I found
there is more concise way. We can leverage this getCommittedBlockLength call
regardless of the replica state given that ratis is used to update the replica
data.
The implementation of getCommittedBlockLength compares the bcsid of involved
block and replica's bcsid. If replica's bcsid is no less than block's bcsid,
then the block info in this replica is a consensus result of raft, it's
trustworthy.
--
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]