swamirishi commented on code in PR #6779:
URL: https://github.com/apache/ozone/pull/6779#discussion_r1638678495
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/storage/ContainerProtocolCalls.java:
##########
@@ -183,53 +206,54 @@ static <T> T tryEachDatanode(Pipeline pipeline,
*
* @param xceiverClient client to perform call
* @param validators functions to validate the response
- * @param datanodeBlockID blockID to identify container
+ * @param blockID blockID to identify container
* @param token a token for this block (may be null)
* @return container protocol get block response
* @throws IOException if there is an I/O error while performing the call
*/
public static GetBlockResponseProto getBlock(XceiverClientSpi xceiverClient,
- List<Validator> validators,
- DatanodeBlockID datanodeBlockID,
- Token<? extends TokenIdentifier> token) throws IOException {
- GetBlockRequestProto.Builder readBlockRequest = GetBlockRequestProto
- .newBuilder()
- .setBlockID(datanodeBlockID);
- ContainerCommandRequestProto.Builder builder = ContainerCommandRequestProto
- .newBuilder()
+ List<Validator> validators, BlockID blockID, Token<? extends
TokenIdentifier> token,
+ Map<DatanodeDetails, Integer> replicaIndexes) throws IOException {
+ ContainerCommandRequestProto.Builder builder =
getContainerCommandRequestProtoBuilder()
.setCmdType(Type.GetBlock)
- .setContainerID(datanodeBlockID.getContainerID())
- .setGetBlock(readBlockRequest);
+ .setContainerID(blockID.getContainerID());
if (token != null) {
builder.setEncodedToken(token.encodeToUrlString());
}
return tryEachDatanode(xceiverClient.getPipeline(),
- d -> getBlock(xceiverClient, validators, builder, d),
- d -> toErrorMessage(datanodeBlockID, d));
+ d -> getBlock(xceiverClient, validators, builder, blockID, d,
replicaIndexes),
+ d -> toErrorMessage(blockID, d));
}
- static String toErrorMessage(DatanodeBlockID blockId, DatanodeDetails d) {
+ static String toErrorMessage(BlockID blockId, DatanodeDetails d) {
return String.format("Failed to get block #%s in container #%s from %s",
blockId.getLocalID(), blockId.getContainerID(), d);
}
public static GetBlockResponseProto getBlock(XceiverClientSpi xceiverClient,
- DatanodeBlockID datanodeBlockID,
- Token<? extends TokenIdentifier> token) throws IOException {
- return getBlock(xceiverClient, getValidatorList(), datanodeBlockID, token);
+ BlockID datanodeBlockID, Token<? extends TokenIdentifier> token,
+ Map<DatanodeDetails, Integer> replicaIndexes) throws IOException {
+ return getBlock(xceiverClient, getValidatorList(), datanodeBlockID, token,
replicaIndexes);
}
- private static GetBlockResponseProto getBlock(XceiverClientSpi xceiverClient,
- List<Validator> validators,
- ContainerCommandRequestProto.Builder builder,
- DatanodeDetails datanode) throws IOException {
+ private static GetBlockResponseProto getBlock(XceiverClientSpi
xceiverClient, List<Validator> validators,
+ ContainerCommandRequestProto.Builder builder, BlockID blockID,
DatanodeDetails datanode,
+ Map<DatanodeDetails, Integer> replicaIndexes) throws IOException {
String traceId = TracingUtil.exportCurrentSpan();
if (traceId != null) {
builder.setTraceID(traceId);
}
+ final DatanodeBlockID.Builder datanodeBlockID =
blockID.getDatanodeBlockIDProtobufBuilder();
+ int replicaIndex = replicaIndexes.getOrDefault(datanode, 0);
Review Comment:
No we cannot use this. My previous commit had the same thing. XceiverClient
maintains a cache for the pipeline. 2 pipelines are same if the list of nodes
are the same.
https://github.com/apache/ozone/blob/8db644ca4643bd4d22f6fe501c62141b8dd4acbc/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientManager.java#L237
##########
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockDataStreamOutput.java:
##########
@@ -204,7 +205,7 @@ private DataStreamOutput setupStream(Pipeline pipeline)
throws IOException {
// it or remove it completely if possible
String id = pipeline.getFirstNode().getUuidString();
ContainerProtos.ContainerCommandRequestProto.Builder builder =
- ContainerProtos.ContainerCommandRequestProto.newBuilder()
+ getContainerCommandRequestProtoBuilder()
Review Comment:
ok will raise a patch for this.
--
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]