AdyChechani commented on code in PR #10831:
URL: https://github.com/apache/ozone/pull/10831#discussion_r3668392551
##########
hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/scm/GetScmRatisRolesSubcommand.java:
##########
@@ -92,20 +87,12 @@ private Map<String, Map<String, String>> parseScmRoles(
Map<String, Map<String, String>> allRoles = new HashMap<>();
for (String role : peerRoles) {
Map<String, String> roleDetails = new HashMap<>();
- String[] roles = role.split(":");
- if (roles.length < 2) {
- err.println("Invalid response received for ScmRatisRoles.");
- return Collections.emptyMap();
- }
- // In case, there is no ratis, there is no ratis role.
- // This will just print the hostname with ratis port as the address
- roleDetails.put("address", roles[0].concat(":").concat(roles[1]));
- if (roles.length == 5) {
- roleDetails.put("raftPeerRole", roles[2]);
- roleDetails.put("ID", roles[3]);
- roleDetails.put("InetAddress", roles[4]);
- }
- allRoles.put(roles[0], roleDetails);
+ String[] fields = HddsUtils.parseRatisRoleString(role);
Review Comment:
The parser now validates and throws IllegalArgumentException on short
strings. The caller catches this and falls back to treating the raw string as a
plain address, preserving the old non-Ratis behavior.
--
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]