Skip to content

Conversation

@sodonnel
Copy link
Contributor

@sodonnel sodonnel commented Dec 9, 2019

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.

  /**
   * Returns the node status of a specific node.
   *
   * @param datanodeDetails Datanode Details
   * @return NodeStatus for the node
   */
  @Override
  public NodeStatus getNodeStatus(DatanodeDetails datanodeDetails) {
    try {
      return nodeStateManager.getNodeStatus(datanodeDetails);
    } catch (NodeNotFoundException e) {
      // TODO: should we throw NodeNotFoundException?
      return 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.

@sodonnel sodonnel force-pushed the HDDS-2671-NodeStatus branch 2 times, most recently from d21629c to 53022eb Compare December 13, 2019 12:21
@sodonnel sodonnel requested a review from elek December 13, 2019 16:40
@sodonnel sodonnel force-pushed the HDDS-2671-NodeStatus branch from 53022eb to 929f2ba Compare December 13, 2019 20:26
Copy link
Contributor

@adoroszlai adoroszlai left a 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);
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Comment on lines +90 to +91
public NodeStatus getNodeStatus(DatanodeDetails datanodeDetails)
throws NodeNotFoundException {
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@adoroszlai adoroszlai left a 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.

@adoroszlai adoroszlai merged commit 692420f into apache:HDDS-1880-Decom Dec 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants