-
Notifications
You must be signed in to change notification settings - Fork 590
HDDS-2671 Have NodeManager.getNodeStatus throw NodeNotFoundException #328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HDDS-2671 Have NodeManager.getNodeStatus throw NodeNotFoundException #328
Conversation
d21629c to
53022eb
Compare
…ather that returning null
53022eb to
929f2ba
Compare
adoroszlai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with minor suggestion for improvement inline.
| try { | ||
| return nodeManager.getNodeStatus(dn); | ||
| } catch (NodeNotFoundException e) { | ||
| throw new RuntimeException("Unable to find NodeStatus for "+dn, e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be more specific, eg. IllegalStateException seems to be a good candidate. If you agree, please remember to update the corresponding catch, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea that makes sense. This means that is a "real" runtime exception occurs, the catch will not stop it propagating up the stack and instead we only catch this more specific exception. I have made this change.
| public NodeStatus getNodeStatus(DatanodeDetails datanodeDetails) | ||
| throws NodeNotFoundException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this method really throw NodeNotFoundException if dni is not found, instead of returning a healthy status, to more closely reflect actual NodeManager behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea it would make more sense for this method do thow NodeNotFoundException, however, I cheated somewhat when using this class in an earlier patch within TestReplicationManager. Replication manager only calls the "getNodeStatus()" method of the NodeManager, and to avoid having to change too many existing tests I defaulted this to return "Healthy + Inservice" for any node not registered so the existing tests passed without modification.
I have an existing Jira HDDS-2673 to refactor and merge MockNodeManager and SimpleMockNodeManager into one, so perhaps we could improve this issue as part of that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps we could improve this issue as part of that?
Sure, that's fine, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a comment to HDDS-2673 to remind about this when I get to working on it.
adoroszlai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @sodonnel for updating the patch.
Requires HDDS-2593 to be committed before this one.
What changes were proposed in this pull request?
Currently, the SCM node manager method getNodeStatus catches any NodeNotFoundException and returns null.
This should throw the exception to ensure downstream code does not need to perform a null check each time it is called.
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-2671
How was this patch tested?
Tested by existing unit tests which make calls to this API.