presto-main/src/main/java/io/prestosql/execution/scheduler/FileBasedNetworkTopology.java/FileBasedNetworkTopology/loadTopologyFile
class FileBasedNetworkTopology:    private static Map<String, NetworkLocation> loadTopologyFile(File topologyFile)
    {
        ImmutableMap.Builder<String, NetworkLocation> topology = ImmutableMap.builder();
        List<String> lines;
        try {
            lines = Files.asCharSource(topologyFile, UTF_8).readLines();
        }
        catch (IOException e) {
            throw new UncheckedIOException("Could not read topology file", e);
        }
        for (int lineNumber = 1; lineNumber <= lines.size(); lineNumber++) {
            String line = lines.get(lineNumber - 1).trim();
            if (line.isEmpty()) {
                continue;
            }
            List<String> parts = SPLIT_HOST_AND_LOCATION.splitToList(line);
            if (parts.size() != 2) {
                throw invalidFile(lineNumber, "expected two parts for host and location");
            }

            String location = parts.get(1);
            if (!location.startsWith("/")) {
                throw invalidFile(lineNumber, "location must start with a leading slash");
            }
            List<String> segments = SPLIT_SEGMENTS.splitToList(location.substring(1));
            if (segments.isEmpty()) {
                throw invalidFile(lineNumber, "location must contain at least one segment");
            }
            if (segments.stream().anyMatch(String::isEmpty)) {
                throw invalidFile(lineNumber, "location must not contain an empty segment");
            }
            // NOTE: segment can not contain whitespace because the host and location splitter would
            // have created multiple parts in that case

            topology.put(parts.get(0), new NetworkLocation(segments));
        }
        return topology.build();
    }