@GET @Path("/apps/{appid}/state") @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public AppState getAppState(@Context HttpServletRequest hsr, @PathParam("appid") String appId) throws AuthorizationException { init(); UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true); String userName = ""; if (callerUGI != null) { userName = callerUGI.getUserName(); } RMApp app = null; try { app = getRMAppForAppId(appId); } catch (NotFoundException e) { RMAuditLogger.logFailure(userName, AuditConstants.KILL_APP_REQUEST, "UNKNOWN", "RMWebService", "Trying to get state of an absent application " + appId); throw e; } AppState ret = new AppState(); ret.setState(app.getState().toString()); return ret; }
@GET @Path(RMWSConsts.APPS_APPID_STATE) @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) @Override public AppState getAppState(@Context HttpServletRequest hsr, @PathParam(RMWSConsts.APPID) String appId) throws AuthorizationException { initForReadableEndpoints(); UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true); String userName = ""; if (callerUGI != null) { userName = callerUGI.getUserName(); } RMApp app = null; try { app = getRMAppForAppId(appId); } catch (NotFoundException e) { RMAuditLogger.logFailure(userName, AuditConstants.GET_APP_STATE, "UNKNOWN", "RMWebService", "Trying to get state of an absent application " + appId); throw e; } AppState ret = new AppState(); ret.setState(app.getState().toString()); return ret; }
@GET @Path("/apps/{appid}/state") @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public AppState getAppState(@Context HttpServletRequest hsr, @PathParam("appid") String appId) throws AuthorizationException { init(); UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true); String userName = ""; if (callerUGI != null) { userName = callerUGI.getUserName(); } RMApp app = null; try { app = getRMAppForAppId(appId); } catch (NotFoundException e) { RMAuditLogger.logFailure(userName, AuditConstants.KILL_APP_REQUEST, "UNKNOWN", "RMWebService", "Trying to get state of an absent application " + appId); throw e; } AppState ret = new AppState(); ret.setState(app.getState().toString()); return ret; }
ret.setState(app.getState().toString());
ret.setState(app.getState().toString());
ret.setState(app.getState().toString());
protected static void verifyAppStateXML(ClientResponse response, RMAppState... appStates) throws ParserConfigurationException, IOException, SAXException { assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType()); String xml = response.getEntity(String.class); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(xml)); Document dom = db.parse(is); NodeList nodes = dom.getElementsByTagName("appstate"); assertEquals("incorrect number of elements", 1, nodes.getLength()); Element element = (Element) nodes.item(0); String state = WebServicesTestUtils.getXmlString(element, "state"); boolean valid = false; for (RMAppState appState : appStates) { if (appState.toString().equals(state)) { valid = true; } } String msg = "app state incorrect, got " + state; assertTrue(msg, valid); }
protected static void verifyAppStateXML(ClientResponse response, RMAppState... appStates) throws ParserConfigurationException, IOException, SAXException { assertEquals(MediaType.APPLICATION_XML_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString()); String xml = response.getEntity(String.class); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(xml)); Document dom = db.parse(is); NodeList nodes = dom.getElementsByTagName("appstate"); assertEquals("incorrect number of elements", 1, nodes.getLength()); Element element = (Element) nodes.item(0); String state = WebServicesTestUtils.getXmlString(element, "state"); boolean valid = false; for (RMAppState appState : appStates) { if (appState.toString().equals(state)) { valid = true; } } String msg = "app state incorrect, got " + state; assertTrue(msg, valid); }
protected static void verifyAppStateJson(ClientResponse response, RMAppState... states) throws JSONException { assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); assertEquals("incorrect number of elements", 1, json.length()); String responseState = json.getString("state"); boolean valid = false; for (RMAppState state : states) { if (state.toString().equals(responseState)) { valid = true; } } String msg = "app state incorrect, got " + responseState; assertTrue(msg, valid); }
protected static void verifyAppStateJson(ClientResponse response, RMAppState... states) throws JSONException { assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); JSONObject json = response.getEntity(JSONObject.class); assertEquals("incorrect number of elements", 1, json.length()); String responseState = json.getString("state"); boolean valid = false; for (RMAppState state : states) { if (state.toString().equals(responseState)) { valid = true; } } String msg = "app state incorrect, got " + responseState; assertTrue(msg, valid); }
app.getApplicationType(), applicationType); WebServicesTestUtils.checkStringMatch("queue", app.getQueue(), queue); WebServicesTestUtils.checkStringMatch("state", app.getState().toString(), state); WebServicesTestUtils.checkStringMatch("finalStatus", app
WebServicesTestUtils.checkStringMatch("queue", app.getQueue(), queue); assertEquals("priority doesn't match", 0, prioirty); WebServicesTestUtils.checkStringMatch("state", app.getState().toString(), state); WebServicesTestUtils.checkStringMatch("finalStatus", app
getXmlString(info, "queue")); assertEquals("priority doesn't match", 0, getXmlInt(info, "priority")); checkStringMatch("state", app.getState().toString(), getXmlString(info, "state")); checkStringMatch("finalStatus", app
checkStringMatch("queue", app.getQueue(), info.getString("queue")); assertEquals("priority doesn't match", 0, info.getInt("priority")); checkStringMatch("state", app.getState().toString(), info.getString("state")); checkStringMatch("finalStatus", app.getFinalApplicationStatus().toString(),