ChenSammi commented on code in PR #11239:
URL: https://github.com/apache/ozone/pull/11239#discussion_r4410712435
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientSpi.java:
##########
@@ -159,6 +162,45 @@ public ContainerCommandResponseProto sendCommand(
}
}
+ /**
+ * Sends a given command to the given datanode only, without failing over
+ * to the other datanodes in the pipeline.
+ * Implementations which cannot target a specific datanode fall back to
+ * {@link #sendCommand(ContainerCommandRequestProto, List)}.
+ * @param request Request
+ * @param validators functions to validate the response
+ * @param datanode the datanode to send the command to
+ * @return Response to the command
+ */
+ public ContainerCommandResponseProto sendCommand(
+ ContainerCommandRequestProto request,
+ List<Validator> validators,
+ DatanodeDetails datanode)
+ throws IOException {
+ return sendCommand(request, validators);
+ }
+
+ /**
+ * Returns the datanodes of the pipeline in the order they should be tried
+ * for a command on the given block.
+ * @param blockID the block the command operates on
+ * @param cmdType type of the command
+ * @return datanodes of the pipeline, in the order to try
+ */
+ public List<DatanodeDetails> getDatanodesInOrder(
+ ContainerProtos.DatanodeBlockID blockID, ContainerProtos.Type cmdType)
+ throws IOException {
+ final Pipeline pipeline = getPipeline();
+ final List<DatanodeDetails> datanodes = new ArrayList<>(pipeline.size());
+ final Set<DatanodeDetails> excluded = new HashSet<>();
+ while (excluded.size() < pipeline.size()) {
+ final DatanodeDetails d = pipeline.getClosestNode(excluded);
+ datanodes.add(d);
+ excluded.add(d);
+ }
+ return datanodes;
Review Comment:
Thanks @symious , overall looks good to me.
I think for this function, we can just return
getPipeline().getNodesInOrder().
--
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]