@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; }
if (!app.getState().toString().equals(targetState.getState())) { if (targetState.getState() .equals(YarnApplicationState.KILLED.toString())) { return killApp(app, callerUGI, hsr, targetState.getDiagnostics()); AppState ret = new AppState(); ret.setState(app.getState().toString());
@Test public void testSingleAppKillInvalidId() throws Exception { rm.start(); MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048); amNodeManager.nodeHeartbeat(true); String[] testAppIds = { "application_1391705042196_0001", "random_string" }; for (String testAppId : testAppIds) { AppState info = new AppState("KILLED"); ClientResponse response = this.constructWebResource("apps", testAppId, "state") .accept(MediaType.APPLICATION_XML) .entity(info, MediaType.APPLICATION_XML).put(ClientResponse.class); if (!isAuthenticationEnabled()) { assertEquals(Status.UNAUTHORIZED, response.getClientResponseStatus()); continue; } assertEquals(Status.NOT_FOUND, response.getClientResponseStatus()); } rm.stop(); }
"state").accept(mediaType).get(ClientResponse.class); AppState info = response.getEntity(AppState.class); info.setState(YarnApplicationState.KILLED.toString());
new AppState(YarnApplicationState.KILLED.toString()); targetState.setDiagnostics(diagnostic);
@Test public void testSingleAppKillInvalidId() throws Exception { rm.start(); MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048); amNodeManager.nodeHeartbeat(true); String[] testAppIds = { "application_1391705042196_0001", "random_string" }; for (int i = 0; i < testAppIds.length; i++) { AppState info = new AppState("KILLED"); ClientResponse response = this.constructWebResource("apps", testAppIds[i], "state") .accept(MediaType.APPLICATION_XML) .entity(info, MediaType.APPLICATION_XML).put(ClientResponse.class); if (!isAuthenticationEnabled()) { assertResponseStatusCode(Status.UNAUTHORIZED, response.getStatusInfo()); continue; } if (i == 0) { assertResponseStatusCode(Status.NOT_FOUND, response.getStatusInfo()); } else { assertResponseStatusCode(Status.BAD_REQUEST, response.getStatusInfo()); } } rm.stop(); }
"state").accept(mediaType).get(ClientResponse.class); AppState info = response.getEntity(AppState.class); info.setState(YarnApplicationState.KILLED.toString());
@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; }
new AppState(YarnApplicationState.KILLED.toString());
@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; }
amNodeManager.nodeHeartbeat(true); ClientResponse response; AppState targetState = new AppState(targetStateString); Object entity; if (contentType.equals(MediaType.APPLICATION_JSON_TYPE)) {
amNodeManager.nodeHeartbeat(true); ClientResponse response; AppState targetState = new AppState(targetStateString); Object entity; if (contentType.equals(MediaType.APPLICATION_JSON_TYPE)) {