ritegarg commented on code in PR #2519:
URL: https://github.com/apache/phoenix/pull/2519#discussion_r3437338588
##########
phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/PhoenixHAAdminTool.java:
##########
@@ -807,9 +872,24 @@ private int executeGetClusterRoleRecord(String[] args)
throws Exception {
String haGroupName = getRequiredOption(cmdLine, HA_GROUP_OPT, "HA group
name");
HAGroupStoreManager manager = HAGroupStoreManager.getInstance(getConf());
- ClusterRoleRecord clusterRoleRecord =
manager.getClusterRoleRecord(haGroupName);
-
- printClusterRoleRecordAsText(clusterRoleRecord);
+ try {
+
printClusterRoleRecordAsText(manager.getClusterRoleRecord(haGroupName));
+ } catch (RuntimeException e) {
+ // ClusterRoleRecord normalization throws on a malformed stored
cluster URL; don't crash -
+ // show the raw URLs (offending one marked <invalid>) and how to
repair. Surface the cause
+ // so an unrelated failure is not silently mislabeled as a bad URL.
+ HAGroupStoreRecord raw =
manager.getHAGroupStoreRecord(haGroupName).orElse(null);
+ System.out.println("\nCluster Role Record for '" + haGroupName
+ + "' could not be built (likely a malformed stored URL): " +
e.getMessage());
+ if (raw != null) {
+ System.out.println(" Cluster URL: "
+ + describeUrl(raw.getClusterUrl(),
ClusterRoleRecord.RegistryType.RPC));
+ System.out.println(" Peer Cluster URL: "
+ + describeUrl(raw.getPeerClusterUrl(),
ClusterRoleRecord.RegistryType.RPC));
+ }
+ System.out.println(
+ " Repair with: update -g " + haGroupName + " -c <good-url> (or -pc)
-av [--force]");
Review Comment:
Good catch — moved the diagnostic to System.err to match handleCommandError
and the rest of the tool's error output. Done in 79e7b1e.
--
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]