[
https://issues.apache.org/jira/browse/HDFS-17934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18089647#comment-18089647
]
ASF GitHub Bot commented on HDFS-17934:
---------------------------------------
Copilot commented on code in PR #8540:
URL: https://github.com/apache/hadoop/pull/8540#discussion_r3428021809
##########
hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/RBFMetrics.java:
##########
@@ -379,6 +385,37 @@ public String getRouters() {
return JSON.toString(info);
}
+ private static String getRouterWebAddress(Configuration conf, String
adminAddress) {
+ try {
+ if (isNullOrEmpty(adminAddress)) {
+ return "";
+ }
+ String scheme = DFSUtil.getHttpClientScheme(conf);
+ int webPort = getRouterWebAddressPort(conf, scheme);
+ InetSocketAddress adminSocketAddress =
NetUtils.createSocketAddr(adminAddress.trim());
+ return new URI(scheme, null, adminSocketAddress.getHostString(),
webPort, null, null,
+ null).toString();
+ } catch (Exception e) {
+ LOG.error("Cannot get router web address", e);
+ return "";
+ }
+ }
Review Comment:
`getRouterWebAddress` uses `isNullOrEmpty(adminAddress)` before trimming, so
whitespace-only values end up throwing and hitting the catch path. Also,
logging this best-effort derivation failure at ERROR (with stack trace) risks
noisy logs if JMX/UI polling is frequent or one router record is malformed;
this should be DEBUG (or at most WARN) and include the problematic address for
troubleshooting.
##########
hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/RBFMetrics.java:
##########
@@ -361,6 +366,7 @@ public String getRouters() {
long dateModified = record.getDateModified();
long lastHeartbeat = getSecondsSince(dateModified);
innerInfo.put("lastHeartbeat", lastHeartbeat);
+ innerInfo.put("routerWebAddress", getRouterWebAddress(conf,
record.getAdminAddress()));
Review Comment:
New `routerWebAddress` output is added to the Routers JSON, but existing
unit coverage for `getRouters()` (e.g.,
`TestRBFMetrics#testRouterStatsDataSource`) doesn't validate it. Adding a small
assertion would help prevent regressions in scheme/port formatting and ensure
the field is present/empty as expected.
> Add router web address to router web UI
> ---------------------------------------
>
> Key: HDFS-17934
> URL: https://issues.apache.org/jira/browse/HDFS-17934
> Project: Hadoop HDFS
> Issue Type: Improvement
> Components: hdfs, rbf
> Reporter: Felix N
> Assignee: Felix N
> Priority: Minor
> Labels: pull-request-available
>
> In router web interface, there are clickable URLs for namenodes and
> datanodes, but none for routers.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]