ashishkumar50 commented on code in PR #5978:
URL: https://github.com/apache/ozone/pull/5978#discussion_r1452938691
##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java:
##########
@@ -2458,8 +2458,11 @@ public List<OmKeyInfo> recoverLease(String volumeName,
String bucketName, String
RecoverLeaseResponse recoverLeaseResponse =
handleError(submitRequest(omRequest)).getRecoverLeaseResponse();
ArrayList<OmKeyInfo> list = new ArrayList();
- list.add(OmKeyInfo.getFromProtobuf(recoverLeaseResponse.getKeyInfo()));
- list.add(OmKeyInfo.getFromProtobuf(recoverLeaseResponse.getOpenKeyInfo()));
+ if (recoverLeaseResponse.hasKeyInfo()) {
+ list.add(OmKeyInfo.getFromProtobuf(recoverLeaseResponse.getKeyInfo()));
+ } else if (recoverLeaseResponse.hasOpenKeyInfo()) {
+
list.add(OmKeyInfo.getFromProtobuf(recoverLeaseResponse.getOpenKeyInfo()));
Review Comment:
Instead of list we can just use OmkeyInfo, as in caller we are using get(0).
Also in caller we may not able to distinguish whether returned keyInfo is
from openKey or Key table. Instead of list can we add a class containing
openkey/key info. So that this ambiguity will not arise in future.
##########
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:
Required to use `acquireClientForReadData` instead of `acquireClient` ?
--
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]