@Test public void shouldReturnActiveRMUrlWhenConnectingToStandby() throws Exception { Map<String, String> map = new HashMap<>(); map.put("yarn.resourcemanager.url", HTTP_RM_URL1 + ", " + HTTP_RM_URL2); ViewContext viewContext = getViewContext(map); AmbariApi ambariApi = createNiceMock(AmbariApi.class); URLStreamProvider urlStreamProvider = createNiceMock(URLStreamProvider.class); InputStream inputStream = IOUtils.toInputStream("{\"clusterInfo\": {\"haState\": \"STANDBY\"}}"); expect(ambariApi.isClusterAssociated()).andReturn(false); expect(viewContext.getURLStreamProvider()).andReturn(urlStreamProvider).anyTimes(); expect(urlStreamProvider.readFrom(eq(HTTP_RM_URL1 + RM_INFO_API_ENDPOINT), eq("GET"), anyString(), EasyMock.<Map<String, String>>anyObject())).andReturn(inputStream); InputStream inputStreamActive = IOUtils.toInputStream("{\"clusterInfo\": {\"haState\": \"ACTIVE\"}}"); expect(urlStreamProvider.readFrom(eq(HTTP_RM_URL2 + RM_INFO_API_ENDPOINT), eq("GET"), anyString(), EasyMock.<Map<String, String>>anyObject())).andReturn(inputStreamActive); replayAll(); Services services = new Services(ambariApi, viewContext); assertEquals(HTTP_RM_URL2, services.getRMUrl()); verify(urlStreamProvider); }
public String getRMUrl() { String url; if (context.getCluster() != null) { url = getRMUrlFromClusterConfig(); } else { url = getRmUrlFromCustomConfig(); } return removeTrailingSlash(url); }
Services { public String getRMUrl() { String url; if (context.getCluster() != null) { url = getRMUrlFromClusterConfig(); } else { url = getRmUrlFromCustomConfig(); } return removeTrailingSlash(url); } }
Services { public String getRMUrl() { String url; if (context.getCluster() != null) { url = getRMUrlFromClusterConfig(); } else { url = getRmUrlFromCustomConfig(); } return removeTrailingSlash(url); } Services(AmbariApi ambariApi, ViewContext context); }
Services { public String getRMUrl() { String url; if (context.getCluster() != null) { url = getRMUrlFromClusterConfig(); } else { url = getRmUrlFromCustomConfig(); } return removeTrailingSlash(url); } Services(AmbariApi ambariApi, ViewContext context); String getRMUrl(); String getWebHCatURL(); String getTimelineServerUrl(); String getYARNProtocol(); static String addProtocolIfMissing(String url, String protocol); static boolean hasProtocol(String[] urls); static boolean hasProtocol(String url); String getHadoopHttpWebAuthType(); String getTimelineServerAuthType(); }
Services { public String getRMUrl() { String url; if (context.getCluster() != null) { url = getRMUrlFromClusterConfig(); } else { url = getRmUrlFromCustomConfig(); } return removeTrailingSlash(url); } Services(AmbariApi ambariApi, ViewContext context); String getRMUrl(); String getWebHCatURL(); String getTimelineServerUrl(); String getYARNProtocol(); static String addProtocolIfMissing(String url, String protocol); static boolean hasProtocol(String[] urls); static boolean hasProtocol(String url); String getHadoopHttpWebAuthType(); String getTimelineServerAuthType(); static final String HTTPS_ONLY; static final String HTTP_ONLY; static final String YARN_SITE; static final String YARN_HTTP_POLICY; static final String YARN_RESOURCEMANAGER_HA_ENABLED; static final String RM_INFO_API_ENDPOINT; static final String TIMELINE_AUTH_TYPE_PROP_KEY; static final String HADOOP_HTTP_AUTH_TYPE_KEY; }