[ https://issues.apache.org/jira/browse/HDFS-16048?focusedWorklogId=606738&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-606738 ]
ASF GitHub Bot logged work on HDFS-16048: ----------------------------------------- Author: ASF GitHub Bot Created on: 04/Jun/21 08:18 Start Date: 04/Jun/21 08:18 Worklog Time Spent: 10m Work Description: tomscut commented on a change in pull request #3062: URL: https://github.com/apache/hadoop/pull/3062#discussion_r644513026 ########## File path: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NetworkTopologyServlet.java ########## @@ -90,7 +90,7 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) * @param leaves leaves nodes under base scope * @param format the response format */ - public void printTopology(PrintStream stream, List<Node> leaves, + private void printTopology(PrintStream stream, List<Node> leaves, Review comment: > Why not just override? Because the arguments of the two methods are a little different, I'll fix it. Thank you for pointing that out. ########## File path: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NetworkTopologyServlet.java ########## @@ -171,7 +171,7 @@ private void printTextFormat(PrintStream stream, Map<String, } @VisibleForTesting - static String parseAcceptHeader(HttpServletRequest request) { + protected static String parseAcceptHeader(HttpServletRequest request) { Review comment: > Package visible is not enough for using it in the other one? This is calling the superclass method(org.apache.hadoop.hdfs.server.namenode.parseAcceptHeader()) directly, not on the instance of the superclass, so I make it protected. Do you think it is necessary to change it to public? ########## File path: hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterNetworkTopologyServlet.java ########## @@ -0,0 +1,116 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hdfs.server.federation.router; + +import org.apache.hadoop.hdfs.protocol.DatanodeInfo; +import org.apache.hadoop.hdfs.protocol.HdfsConstants; +import org.apache.hadoop.hdfs.server.namenode.NetworkTopologyServlet; +import org.apache.hadoop.net.Node; +import org.apache.hadoop.util.StringUtils; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.TreeSet; + +/** + * A servlet to print out the network topology from router. + */ +public class RouterNetworkTopologyServlet extends NetworkTopologyServlet { + + public static final String SERVLET_NAME = "topology"; + public static final String PATH_SPEC = "/topology"; + + protected static final String FORMAT_JSON = "json"; + protected static final String FORMAT_TEXT = "text"; + + @Override + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws IOException { + final ServletContext context = getServletContext(); + + String format = parseAcceptHeader(request); Review comment: Hi @goiri . This is calling the superclass method(org.apache.hadoop.hdfs.server.namenode.parseAcceptHeader()) directly, not on the instance of the superclass, so that's right for protected access rights on superclass. What do you think? ########## File path: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NetworkTopologyServlet.java ########## @@ -152,8 +153,8 @@ private void printJsonFormat(PrintStream stream, Map<String, } } - private void printTextFormat(PrintStream stream, Map<String, - TreeSet<String>> tree, ArrayList<String> racks) { + protected void printTextFormat(PrintStream stream, Map<String, + TreeSet<String>> tree, ArrayList<String> racks) { Review comment: Thanks @tasanuma for your review, I fixed it. -- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 606738) Time Spent: 3.5h (was: 3h 20m) > RBF: Print network topology on the router web > --------------------------------------------- > > Key: HDFS-16048 > URL: https://issues.apache.org/jira/browse/HDFS-16048 > Project: Hadoop HDFS > Issue Type: Wish > Reporter: tomscut > Assignee: tomscut > Priority: Minor > Labels: pull-request-available > Attachments: topology-json.jpg, topology-text.jpg > > Time Spent: 3.5h > Remaining Estimate: 0h > > In order to query the network topology information conveniently, we can print > it on the router web. It's related to HDFS-15970. -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org