Search in sources :

Example 1 with AppsInfo

use of org.apache.hadoop.yarn.server.nodemanager.webapp.dao.AppsInfo in project hadoop by apache.

the class NMWebServices method getNodeApps.

@GET
@Path("/apps")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
public AppsInfo getNodeApps(@QueryParam("state") String stateQuery, @QueryParam("user") String userQuery) {
    init();
    AppsInfo allApps = new AppsInfo();
    for (Entry<ApplicationId, Application> entry : this.nmContext.getApplications().entrySet()) {
        AppInfo appInfo = new AppInfo(entry.getValue());
        if (stateQuery != null && !stateQuery.isEmpty()) {
            ApplicationState.valueOf(stateQuery);
            if (!appInfo.getState().equalsIgnoreCase(stateQuery)) {
                continue;
            }
        }
        if (userQuery != null) {
            if (userQuery.isEmpty()) {
                String msg = "Error: You must specify a non-empty string for the user";
                throw new BadRequestException(msg);
            }
            if (!appInfo.getUser().equals(userQuery)) {
                continue;
            }
        }
        allApps.add(appInfo);
    }
    return allApps;
}
Also used : BadRequestException(org.apache.hadoop.yarn.webapp.BadRequestException) AppsInfo(org.apache.hadoop.yarn.server.nodemanager.webapp.dao.AppsInfo) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) Application(org.apache.hadoop.yarn.server.nodemanager.containermanager.application.Application) AppInfo(org.apache.hadoop.yarn.server.nodemanager.webapp.dao.AppInfo) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)1 Application (org.apache.hadoop.yarn.server.nodemanager.containermanager.application.Application)1 AppInfo (org.apache.hadoop.yarn.server.nodemanager.webapp.dao.AppInfo)1 AppsInfo (org.apache.hadoop.yarn.server.nodemanager.webapp.dao.AppsInfo)1 BadRequestException (org.apache.hadoop.yarn.webapp.BadRequestException)1