StringUtils.getHostNameOfIP() should be a part of NetUtil rather than StringUtil.
Done. I had originally placed it in StringUtil because getHostName(), a similar method, was in StringUtil, but that method should also be in NetUtil. I've moved getHostName() to NetUtil, and updated the references to it.
See org.apache.hadoop.net.NetUtils.normalizeHostName(String), which is similar to your method.
Actually, normalizeHostName(String) does the opposite of my method. It goes (hostname|IP) -> IP, mine goes IP -> hostname.
In DFSAdmin.printTopology() use ArrayList instead of Vector. Vector is synchronized, which is not necessary here.
Correct. The next item resolves this.
Instead of explicitly sorting the data-nodes within the rack you could just insert them into the list in the right order, using Collections.binarySearch() and then List.add(int index, E element)
I've replaced the ArrayList with a TreeSet, which resolves the issue and is more efficient than an ArrayList and cleaner than a binarySearch method.
In DFSAdmin.printHelp() you should add printing printTopology in case cmd is not equal to any known command. In the very last else case.
DatanodeInfo.getNetworkLocation() could you please remove last * in the JavaDoc comment. Should be /** rack name */