DFSAdmin extends FsShell { private int getDatanodeInfo(String[] argv, int i) throws IOException { ClientDatanodeProtocol dnProxy = getDataNodeProxy(argv[i]); try { DatanodeLocalInfo dnInfo = dnProxy.getDatanodeInfo(); System.out.println(dnInfo.getDatanodeLocalReport()); } catch (IOException ioe) { throw new IOException("Datanode unreachable. " + ioe, ioe); } return 0; } DFSAdmin();  DFSAdmin(Configuration conf); void report(String[] argv, int i); void setSafeMode(String[] argv, int idx); int triggerBlockReport(String[] argv); void allowSnapshot(String[] argv); void disallowSnapshot(String[] argv); void provisionSnapshotTrash(String[] argv); int saveNamespace(String[] argv); int rollEdits(); int restoreFailedStorage(String arg); int refreshNodes(); int listOpenFiles(String[] argv); int setBalancerBandwidth(String[] argv, int idx); int getBalancerBandwidth(String[] argv, int idx); int fetchImage(final String[] argv, final int idx); int finalizeUpgrade(); int getUpgradeStatus(); int upgrade(String arg); int metaSave(String[] argv, int idx); int printTopology(); int refreshServiceAcl(); int refreshUserToGroupsMappings(); int refreshSuperUserGroupsConfiguration(); int refreshCallQueue(); int reconfig(String[] argv, int i); int genericRefresh(String[] argv, int i); @Override int run(String[] argv); static void main(String[] argv);  }
@Test(timeout = 30000) public void testGetDatanodeInfo() throws Exception { redirectStream(); final DFSAdmin dfsAdmin = new DFSAdmin(conf); for (int i = 0; i < cluster.getDataNodes().size(); i++) { resetStream(); final DataNode dn = cluster.getDataNodes().get(i); final String addr = String.format( "%s:%d", dn.getXferAddress().getHostString(), dn.getIpcPort()); final int ret = ToolRunner.run(dfsAdmin, new String[]{"-getDatanodeInfo", addr}); assertEquals(0, ret); final List<String> outs = Lists.newArrayList(); scanIntoList(out, outs); assertEquals( "One line per DataNode like: Uptime: XXX, Software version: x.y.z," + " Config version: core-x.y.z,hdfs-x", 1, outs.size()); assertThat(outs.get(0), is(allOf(containsString("Uptime:"), containsString("Software version"), containsString("Config version")))); } }