nandakumar131 commented on code in PR #6909:
URL: https://github.com/apache/ozone/pull/6909#discussion_r1671226613
##########
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java:
##########
@@ -316,6 +317,37 @@ public ContainerCommandResponseProto sendCommand(
return responseProtoHashMap;
}
+ /**
+ * @param request
+ * @param dn
+ * @param pipeline
+ * In case of getBlock for EC keys, it is required to set replicaIndex for
+ * every request with the replicaIndex for that DN for which the request is
+ * sent to. This method unpacks proto and reconstructs request after setting
+ * the replicaIndex field.
+ * @return new updated Request
+ */
+ private ContainerCommandRequestProto reconstructRequestIfNeeded(
+ ContainerCommandRequestProto request, DatanodeDetails dn) {
+ boolean isEcRequest = pipeline.getReplicationConfig()
+ .getReplicationType() == HddsProtos.ReplicationType.EC;
+ if (request.hasGetBlock() && isEcRequest) {
+ int replicaIdx = pipeline.getReplicaIndex(dn);
+ ContainerProtos.GetBlockRequestProto getBlockRequestProto =
+ request.getGetBlock();
+ DatanodeBlockID datanodeBlockID = getBlockRequestProto.getBlockID();
+ DatanodeBlockID newDatanodeBlockID =
+ DatanodeBlockID.newBuilder(datanodeBlockID)
+ .setReplicaIndex(replicaIdx).build();
+ ContainerProtos.GetBlockRequestProto newGetBlockRequestProto =
+ ContainerProtos.GetBlockRequestProto.newBuilder(getBlockRequestProto)
+ .setBlockID(newDatanodeBlockID).build();
+ request = ContainerCommandRequestProto.newBuilder(request)
+ .setGetBlock(newGetBlockRequestProto).build();
Review Comment:
```suggestion
ContainerProtos.GetBlockRequestProto gbr = request.getGetBlock();
request = request.toBuilder().setGetBlock(gbr.toBuilder().setBlockID(
gbr.getBlockID().toBuilder().setReplicaIndex(
pipeline.getReplicaIndex(dn)).build()).build()).build();
```
--
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]