-
Notifications
You must be signed in to change notification settings - Fork 619
HDDS-9648. Create API to fetch single datanode related information #5856
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
Changes from 4 commits
12e7bb2
9657605
67febed
ee30f58
3187525
76bbe0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,6 +109,7 @@ | |
| import java.util.TreeSet; | ||
| import java.util.stream.Collectors; | ||
| import java.util.stream.Stream; | ||
| import java.util.UUID; | ||
|
|
||
| import static org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.StorageContainerLocationProtocolService.newReflectiveBlockingService; | ||
| import static org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_HANDLER_COUNT_DEFAULT; | ||
|
|
@@ -612,6 +613,29 @@ public List<HddsProtos.Node> queryNode( | |
| return result; | ||
| } | ||
|
|
||
| @Override | ||
| public HddsProtos.Node queryNode(UUID uuid) | ||
| throws IOException { | ||
| HddsProtos.Node result = null; | ||
| for (DatanodeDetails node : scm.getScmNodeManager().getAllNodes()) { | ||
| try { | ||
| if (node.getUuid().equals(uuid)) { | ||
| NodeStatus ns = scm.getScmNodeManager().getNodeStatus(node); | ||
| result = HddsProtos.Node.newBuilder() | ||
| .setNodeID(node.getProtoBufMessage()) | ||
| .addNodeStates(ns.getHealth()) | ||
| .addNodeOperationalStates(ns.getOperationalState()) | ||
| .build(); | ||
| break; | ||
| } | ||
| } catch (NodeNotFoundException e) { | ||
| throw new IOException( | ||
| "An unexpected error occurred querying the NodeStatus", e); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "An unexpected error" is a rather particular error, not unexpected
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have used the same message used in queryNode() method earlier. I'm not sure what you are suggesting..
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess "NodeNotFound" should not happen, as we have just retrieved the node from NodeManager before querying its status, so the error really is unexpected. The message includes the stack trace, so it should be easy for a caller to figure out what was wrong. |
||
| } | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| @Override | ||
| public List<DatanodeAdminError> decommissionNodes(List<String> nodes) | ||
| throws IOException { | ||
|
|
||
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.
Node manager has an API to get a node by UUID directly:
So it would be better to use that than iterate all nodes.
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.
Thank you for the review! I have made the changes required to incorporate your suggestion and resolved the conflicts as well. Could you please review it and approve the workflows if the patch is good to go?