HDFS-17934. RBF: Add router web address to router web UI#8540
HDFS-17934. RBF: Add router web address to router web UI#8540kokonguyen191 wants to merge 2 commits into
Conversation
|
💔 -1 overall
This message was automatically generated. |
| String host = adminAddress.split(":")[0]; | ||
| return "http://" + host + ":" + webPort; |
There was a problem hiding this comment.
how do u know it is http only, we have DFS_ROUTER_HTTPS_ADDRESS_KEY as well
There was a problem hiding this comment.
Fair point, updated with HTTPS
| return JSON.toString(info); | ||
| } | ||
|
|
||
| private static String guessRouterWebAddress(String adminAddress, int webPort) { |
There was a problem hiding this comment.
guess isn't a very nice word here & moreover we can't rely on guesswork either
There was a problem hiding this comment.
Updated methods to remove guess naming. If we want fully correct per router web address, router state store has to store those data (which currently it does not). I think for a simple web UI improvement and for most deployments with a consistent config for all routers in a cluster, this is a fair compromise to arrive at
|
💔 -1 overall
This message was automatically generated. |
There was a problem hiding this comment.
Pull request overview
Adds a clickable web URL for each Router entry in the RBF Router web UI by deriving the Router web address from the Router’s admin address plus locally configured HTTP/HTTPS port/scheme.
Changes:
- Render Router “Address” as a link when a derived
routerWebAddressis available. - Extend
RBFMetrics#getRouters()JSON output to include arouterWebAddressfield computed from config + router admin address.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/webapps/router/federationhealth.html | Conditionally wraps router address in an <a> pointing to routerWebAddress. |
| hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/metrics/RBFMetrics.java | Adds derivation of routerWebAddress and injects it into the Routers JSON payload. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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 ""; | ||
| } | ||
| } |
| long dateModified = record.getDateModified(); | ||
| long lastHeartbeat = getSecondsSince(dateModified); | ||
| innerInfo.put("lastHeartbeat", lastHeartbeat); | ||
| innerInfo.put("routerWebAddress", getRouterWebAddress(conf, record.getAdminAddress())); |
Description of PR
In router web interface, there are clickable URLs for namenodes and datanodes, but none for routers.
This patch uses a hacky method to guess the web URL from configuration and admin address, which works for cluster that runs the same port for all routers, instead of 100% accurately getting it using some other method that requires more intrusive changes to what's stored in the router state store. I think it's a fair compromise for a small improvement that works for most deployments.
How was this patch tested?
Local deployment and test deployment with a few nodes.
No unit tests since it's a minor front end change.