sodonnel commented on code in PR #3867:
URL: https://github.com/apache/ozone/pull/3867#discussion_r1006168779
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/DatanodeInfo.java:
##########
@@ -286,11 +286,20 @@ public void setNodeStatus(NodeStatus newNodeStatus) {
* Set the current command counts for this datanode, as reported in the last
* heartbeat.
* @param cmds Proto message containing a list of command count pairs.
+ * @param commandsToBeSent Summary of commands which will be sent to the DN
+ * as the heartbeat is processed and should be added
+ * to the command count.
*/
- public void setCommandCounts(CommandQueueReportProto cmds) {
+ public void setCommandCounts(CommandQueueReportProto cmds,
+ Map<SCMCommandProto.Type, Integer> commandsToBeSent) {
try {
int count = cmds.getCommandCount();
+ Map<SCMCommandProto.Type, Integer> mutableCmds
+ = new HashMap<>(commandsToBeSent);
lock.writeLock().lock();
+ // Purge the existing counts, as each report should completely replace
+ // the existing counts.
+ commandCounts.clear();
Review Comment:
I'm not sure I follow your question.
There are two counts. The ones reported from the DN on its heartbeart -
these are queued on the DN.
Then there are commands queued in SCM ready to be sent to the DN as part of
processing the heartbeat.
After the heartbeat, the real queue on the DN is the sum of the two (queued
on DN + queued on SCM).
Before this change, we only stored the "queued on the DN count". This count
is not yet used anywhere, but I missed adding the commands the heartbeat will
add to the queue, so the old count is not correct.
The line `commandCounts.put(command, cmdCount)` should do all the updates as
per the comment in the code. The line `commandCounts.putAll(mutableCmds)` is a
"catch all" incase the DN is not reporting counts for a command that is queued
on SCM - it shouldn't happen in practice. I have also removed the entry from
mutableCommands after adding it to the cmdCount, so in practice mutableCommands
should be empty by the time it gets to the putAll() call.
--
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]