TopCLI extends YarnCLI { @VisibleForTesting public URL getHAClusterUrl(Configuration conf, String rmhid) throws MalformedURLException { return new URL(WebAppUtils.getHttpSchemePrefix(conf) + WebAppUtils.getResolvedRemoteRMWebAppURLWithoutScheme(conf, YarnConfiguration.useHttps(conf) ? Policy.HTTPS_ONLY : Policy.HTTP_ONLY, rmhid) + CLUSTER_INFO_URL); } TopCLI(); static void main(String[] args); @Override int run(String[] args); @VisibleForTesting URL getHAClusterUrl(Configuration conf, String rmhid); static final Comparator<ApplicationInformation> AppIDComparator; static final Comparator<ApplicationInformation> UserComparator; static final Comparator<ApplicationInformation> AppTypeComparator; static final Comparator<ApplicationInformation> QueueNameComparator; static final Comparator<ApplicationInformation> UsedContainersComparator; static final Comparator<ApplicationInformation> ReservedContainersComparator; static final Comparator<ApplicationInformation> UsedMemoryComparator; static final Comparator<ApplicationInformation> ReservedMemoryComparator; static final Comparator<ApplicationInformation> UsedVCoresComparator; static final Comparator<ApplicationInformation> ReservedVCoresComparator; static final Comparator<ApplicationInformation> VCoreSecondsComparator; static final Comparator<ApplicationInformation> MemorySecondsComparator; static final Comparator<ApplicationInformation> ProgressComparator; static final Comparator<ApplicationInformation> RunningTimeComparator; static final Comparator<ApplicationInformation> AppNameComparator; static final Comparator<ApplicationInformation> AppPriorityComparator; }
@Test public void testHAClusterInfoURL() throws IOException, InterruptedException { TopCLI topcli = new TopCLI(); String rm1Address = "host2:8088"; String rm2Address = "host3:8088"; Configuration conf = topcli.getConf(); conf.set(YarnConfiguration.RM_WEBAPP_ADDRESS + "." + RM1_NODE_ID, rm1Address); topcli.getConf().set( YarnConfiguration.RM_WEBAPP_ADDRESS + "." + RM2_NODE_ID, rm2Address); topcli.getConf().setBoolean(YarnConfiguration.RM_HA_ENABLED, true); topcli.getConf().set(YarnConfiguration.RM_HA_IDS, RM1_NODE_ID + "," + RM2_NODE_ID); URL clusterUrl = topcli.getHAClusterUrl(conf, RM1_NODE_ID); Assert.assertEquals("http", clusterUrl.getProtocol()); Assert.assertEquals(rm1Address, clusterUrl.getAuthority()); clusterUrl = topcli.getHAClusterUrl(conf, RM2_NODE_ID); Assert.assertEquals("http", clusterUrl.getProtocol()); Assert.assertEquals(rm2Address, clusterUrl.getAuthority()); rm1Address = "host2:9088"; rm2Address = "host3:9088"; conf = topcli.getConf(); conf.set(YarnConfiguration.RM_WEBAPP_HTTPS_ADDRESS + "." + RM1_NODE_ID, rm1Address); conf.set(YarnConfiguration.RM_WEBAPP_HTTPS_ADDRESS + "." + RM2_NODE_ID, rm2Address); conf.setBoolean(YarnConfiguration.RM_HA_ENABLED, true); conf.set(YarnConfiguration.RM_HA_IDS, RM1_NODE_ID + "," + RM2_NODE_ID); conf.set(YarnConfiguration.YARN_HTTP_POLICY_KEY, "HTTPS_ONLY"); clusterUrl = topcli.getHAClusterUrl(conf, RM1_NODE_ID); Assert.assertEquals("https", clusterUrl.getProtocol()); Assert.assertEquals(rm1Address, clusterUrl.getAuthority()); }