apache/hadoop · warning · IOException

Print network topology failed. {}

Error message

Print network topology failed. {}

What it means

RouterNetworkTopologyServlet serves the /topology endpoint on the router's HTTP (admin) server, printing the network topology of all datanodes. Any Throwable raised while streaming the topology (printTopology) is stringified, reported to the client as HTTP 410 Gone, and rethrown as an IOException from the servlet.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterNetworkTopologyServlet.java:76

      try {
        datanodeReport = syncReturn(DatanodeInfo[].class);
      } catch (Exception e) {
        throw new IOException(e);
      }
    } else {
      datanodeReport = router.getRpcServer().getDatanodeReport(
          HdfsConstants.DatanodeReportType.ALL);
    }
    List<Node> datanodeInfos = Arrays.asList(datanodeReport);

    try (PrintStream out = new PrintStream(
            response.getOutputStream(), false, "UTF-8")) {
      printTopology(out, datanodeInfos, format);
    } catch (Throwable t) {
      String errMsg = "Print network topology failed. "
              + StringUtils.stringifyException(t);
      response.sendError(HttpServletResponse.SC_GONE, errMsg);
      throw new IOException(errMsg);
    } finally {
      response.getOutputStream().close();
    }
  }
}

View on GitHub (pinned to 2add963021)

Solutions

  1. Read the stringified exception in the 410 response body - it contains the original stack trace
  2. Retry the request without the format parameter (or with a supported one) to rule out bad input
  3. Check the router log for the same stack and verify getDatanodeReport works via hdfs dfsadmin -fs router:// -report
  4. If the resolver layout is broken (NPE on node parent/rack), fix the resolver/state store configuration and restart the router
Defensive patterns

Strategy: try-catch

Validate before calling

// Health-check the report before scraping the servlet
DatanodeInfo[] report = routerRpcServer.getDatanodeReport(DatanodeReportType.ALL);
if (report == null) {  // defensive: servlet dereferences Arrays.asList(report) earlier
  LOG.warn("Datanode report unavailable; /topology may fail");
}

Try / catch

try {
  ResponseEntity<String> resp = restTemplate.getForEntity(routerTopologyUrl, String.class);
  if (resp.getStatusCode() == HttpStatus.GONE) {  // servlet sends 410 with stringified cause
    LOG.warn("Topology print failed: {}", resp.getBody());
    // retry later; inspect router log for the original stack
  }
} catch (RestClientException e) {
  // connection-level failure, distinct from the servlet's 410
}

Prevention

When it happens

Trigger: A GET request to the router's /topology endpoint (optionally with a format parameter) where printTopology fails: an unsupported format string, an exception while walking the datanode report (e.g. null/bad Node data), or an output-stream failure after the response started.

Common situations: Operators scraping the router UI/topology page for rack layout; a malformed format query parameter; router whose datanode report is in an unexpected state (e.g. resolver returned empty/None layout) causing a NPE inside topology printing.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/f1351f1d6360b5a0. Report an issue: GitHub.