ChenSammi commented on code in PR #5978:
URL: https://github.com/apache/ozone/pull/5978#discussion_r1453043357
##########
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java:
##########
@@ -1421,6 +1431,53 @@ 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);
+ } finally {
+ if (client != null) {
+ xceiverClientFactory.releaseClient(client, false);
+ }
+ }
+
+ // Try fetch block committed length from DN
+ ReplicationConfig replicationConfig = pipeline.getReplicationConfig();
+ if (!(replicationConfig instanceof ReplicatedReplicationConfig)) {
+ throw new IOException("ReplicationConfig type " +
replicationConfig.getClass().getSimpleName() +
+ " is not supported in finalizeBlock");
+ }
+ StandaloneReplicationConfig newConfig =
StandaloneReplicationConfig.getInstance(
+ ((ReplicatedReplicationConfig)
replicationConfig).getReplicationFactor());
+ Pipeline.Builder builder =
Pipeline.newBuilder().setReplicationConfig(newConfig).setId(PipelineID.randomId())
+
.setNodes(block.getPipeline().getNodes()).setState(Pipeline.PipelineState.OPEN);
+ try {
+ client = xceiverClientFactory.acquireClient(builder.build());
Review Comment:
Right, acquireClientForReadData is better.
--
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]