[
https://issues.apache.org/jira/browse/HDFS-16048?focusedWorklogId=607705&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-607705
]
ASF GitHub Bot logged work on HDFS-16048:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 07/Jun/21 08:19
Start Date: 07/Jun/21 08:19
Worklog Time Spent: 10m
Work Description: tomscut commented on a change in pull request #3062:
URL: https://github.com/apache/hadoop/pull/3062#discussion_r646369832
##########
File path:
hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterNetworkTopologyServlet.java
##########
@@ -0,0 +1,210 @@
+/**
+ * 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 com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hdfs.server.federation.RouterConfigBuilder;
+import org.apache.hadoop.hdfs.server.federation.StateStoreDFSCluster;
+import
org.apache.hadoop.hdfs.server.federation.resolver.MultipleDestinationMountTableResolver;
+import org.apache.hadoop.io.IOUtils;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.ByteArrayOutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Map;
+
+import static
org.apache.hadoop.hdfs.server.federation.router.RBFConfigKeys.DFS_ROUTER_HTTP_ENABLE;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class TestRouterNetworkTopologyServlet {
+
+ private static StateStoreDFSCluster clusterWithDatanodes;
+ private static StateStoreDFSCluster clusterNoDatanodes;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ // Builder configuration
+ Configuration routerConf =
+ new RouterConfigBuilder().stateStore().admin().quota().rpc().build();
+ routerConf.set(DFS_ROUTER_HTTP_ENABLE, "true");
+ Configuration hdfsConf = new Configuration(false);
+
+ // Build and start a federated cluster
+ clusterWithDatanodes = new StateStoreDFSCluster(false, 2,
+ MultipleDestinationMountTableResolver.class);
+ clusterWithDatanodes.addNamenodeOverrides(hdfsConf);
+ clusterWithDatanodes.addRouterOverrides(routerConf);
+ clusterWithDatanodes.setNumDatanodesPerNameservice(9);
+ clusterWithDatanodes.setIndependentDNs();
+ clusterWithDatanodes.setRacks(
+ new String[] {"/rack1", "/rack1", "/rack1", "/rack2", "/rack2",
+ "/rack2", "/rack3", "/rack3", "/rack3", "/rack4", "/rack4",
+ "/rack4", "/rack5", "/rack5", "/rack5", "/rack6", "/rack6",
+ "/rack6"});
+ clusterWithDatanodes.startCluster();
+ clusterWithDatanodes.startRouters();
+ clusterWithDatanodes.waitClusterUp();
+ clusterWithDatanodes.waitActiveNamespaces();
+
+ // Build and start a federated cluster
+ clusterNoDatanodes = new StateStoreDFSCluster(false, 2,
+ MultipleDestinationMountTableResolver.class);
+ clusterNoDatanodes.addNamenodeOverrides(hdfsConf);
+ clusterNoDatanodes.addRouterOverrides(routerConf);
+ clusterNoDatanodes.setNumDatanodesPerNameservice(0);
+ clusterNoDatanodes.setIndependentDNs();
+ clusterNoDatanodes.startCluster();
+ clusterNoDatanodes.startRouters();
+ clusterNoDatanodes.waitClusterUp();
+ clusterNoDatanodes.waitActiveNamespaces();
+ }
+
+ @Test
+ public void testPrintTopologyTextFormat() throws Exception {
+ // get http Address
+ String httpAddress = clusterWithDatanodes.getRandomRouter().getRouter()
+ .getHttpServerAddress().toString();
+
+ // send http request
+ URL url = new URL("http:/" + httpAddress + "/topology");
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ conn.setReadTimeout(20000);
+ conn.setConnectTimeout(20000);
+ conn.connect();
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ IOUtils.copyBytes(conn.getInputStream(), out, 4096, true);
+ StringBuilder sb =
+ new StringBuilder("-- Network Topology -- \n");
+ sb.append(out);
+ sb.append("\n-- Network Topology -- ");
+ String topology = sb.toString();
+
+ // assert rack info
+ assertTrue(topology.contains("/ns0/rack1"));
+ assertTrue(topology.contains("/ns0/rack2"));
+ assertTrue(topology.contains("/ns0/rack3"));
+ assertTrue(topology.contains("/ns1/rack4"));
+ assertTrue(topology.contains("/ns1/rack5"));
+ assertTrue(topology.contains("/ns1/rack6"));
+
+ // assert node number
+ assertEquals(topology.split("127.0.0.1").length - 1,
+ 18);
Review comment:
Hi @aajisaka , I fixed this problem, please take a look.
--
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:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 607705)
Time Spent: 5h (was: 4h 50m)
> 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: 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: [email protected]
For additional commands, e-mail: [email protected]