LogWebService { protected AppInfo getApp(HttpServletRequest req, String appId, String clusterId) { UserGroupInformation callerUGI = LogWebServiceUtils.getUser(req); String cId = clusterId != null ? clusterId : defaultClusterid; MultivaluedMap<String, String> params = new MultivaluedMapImpl(); params.add("fields", "INFO"); String path = JOINER.join("clusters/", cId, "/apps/", appId); TimelineEntity appEntity = null; try { if (callerUGI == null) { appEntity = getEntity(path, params); } else { setUserName(params, callerUGI.getShortUserName()); appEntity = callerUGI.doAs(new PrivilegedExceptionAction<TimelineEntity>() { @Override public TimelineEntity run() throws Exception { return getEntity(path, params); } }); } } catch (Exception e) { LogWebServiceUtils.rewrapAndThrowException(e); } if (appEntity == null) { return null; } String appOwner = (String) appEntity.getInfo() .get(ApplicationMetricsConstants.USER_ENTITY_INFO); String state = (String) appEntity.getInfo() .get(ApplicationMetricsConstants.STATE_EVENT_INFO); YarnApplicationState appState = YarnApplicationState.valueOf(state); AppInfo info = new AppInfo(appState, appOwner); return info; }  @GET @Path("/containers/{containerid}/logs") @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) Response getContainerLogsInfo(@Context HttpServletRequest req,
      @Context HttpServletResponse res,
      @PathParam(YarnWebServiceParams.CONTAINER_ID) String containerIdStr,
      @QueryParam(YarnWebServiceParams.NM_ID) String nmId,
      @QueryParam(YarnWebServiceParams.REDIRECTED_FROM_NODE)
      @DefaultValue("false") boolean redirectedFromNode,
      @QueryParam(YarnWebServiceParams.CLUSTER_ID) String clusterId); @GET @Path("/containers/{containerid}/logs/{filename}") @Produces({ MediaType.TEXT_PLAIN }) @InterfaceAudience.Public @InterfaceStability.Unstable Response getContainerLogFile(
      @Context HttpServletRequest req, @Context HttpServletResponse res,
      @PathParam(YarnWebServiceParams.CONTAINER_ID) String containerIdStr,
      @PathParam(YarnWebServiceParams.CONTAINER_LOG_FILE_NAME) String filename,
      @QueryParam(YarnWebServiceParams.RESPONSE_CONTENT_FORMAT) String format,
      @QueryParam(YarnWebServiceParams.RESPONSE_CONTENT_SIZE) String size,
      @QueryParam(YarnWebServiceParams.NM_ID) String nmId,
      @QueryParam(YarnWebServiceParams.REDIRECTED_FROM_NODE)
          boolean redirectedFromNode,
      @QueryParam(YarnWebServiceParams.CLUSTER_ID) String clusterId); @GET @Path("/containerlogs/{containerid}/{filename}") @Produces({ MediaType.TEXT_PLAIN + "; " + JettyUtils.UTF_8 }) @InterfaceAudience.Public @InterfaceStability.Unstable Response getLogs(@Context HttpServletRequest req,
      @Context HttpServletResponse res,
      @PathParam(YarnWebServiceParams.CONTAINER_ID) String containerIdStr,
      @PathParam(YarnWebServiceParams.CONTAINER_LOG_FILE_NAME) String filename,
      @QueryParam(YarnWebServiceParams.RESPONSE_CONTENT_FORMAT) String format,
      @QueryParam(YarnWebServiceParams.RESPONSE_CONTENT_SIZE) String size,
      @QueryParam(YarnWebServiceParams.NM_ID) String nmId,
      @QueryParam(YarnWebServiceParams.REDIRECTED_FROM_NODE)
      @DefaultValue("false") boolean redirectedFromNode,
      @QueryParam(YarnWebServiceParams.CLUSTER_ID) String clusterId);  }
@Test public void testGetApp() { LogWebService.AppInfo app = logWebService.getApp(request, appId.toString(), null); Assert.assertEquals("RUNNING", app.getAppState().toString()); Assert.assertEquals(user, app.getUser()); }