Master { public static String getMasterAddress(Configuration conf) { String masterAddress = conf.get(MRConfig.MASTER_ADDRESS, "localhost:8012"); return NetUtils.createSocketAddr(masterAddress, 8012, MRConfig.MASTER_ADDRESS).getHostName(); }  static String getMasterAddress(Configuration conf); static String getMasterPrincipal(Configuration conf);  }
@Test public void testGetMasterAddress() { YarnConfiguration conf = new YarnConfiguration(); conf.set(MRConfig.FRAMEWORK_NAME, MRConfig.CLASSIC_FRAMEWORK_NAME); conf.set(MRConfig.MASTER_ADDRESS, "local:invalid"); try { Master.getMasterAddress(conf); fail("Should not reach here as there is a bad master address"); } catch (Exception e) { } conf.set(MRConfig.MASTER_ADDRESS, "bar.com:8042"); String masterHostname = Master.getMasterAddress(conf); assertThat(masterHostname).isEqualTo("bar.com"); }