Search in sources :

Example 26 with TaskType

use of org.apache.hadoop.mapreduce.v2.api.records.TaskType in project hadoop by apache.

the class HsWebServices method getJobTasks.

@GET
@Path("/mapreduce/jobs/{jobid}/tasks")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
public TasksInfo getJobTasks(@Context HttpServletRequest hsr, @PathParam("jobid") String jid, @QueryParam("type") String type) {
    init();
    Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
    checkAccess(job, hsr);
    TasksInfo allTasks = new TasksInfo();
    for (Task task : job.getTasks().values()) {
        TaskType ttype = null;
        if (type != null && !type.isEmpty()) {
            try {
                ttype = MRApps.taskType(type);
            } catch (YarnRuntimeException e) {
                throw new BadRequestException("tasktype must be either m or r");
            }
        }
        if (ttype != null && task.getType() != ttype) {
            continue;
        }
        allTasks.add(new TaskInfo(task));
    }
    return allTasks;
}
Also used : YarnRuntimeException(org.apache.hadoop.yarn.exceptions.YarnRuntimeException) TaskInfo(org.apache.hadoop.mapreduce.v2.app.webapp.dao.TaskInfo) Task(org.apache.hadoop.mapreduce.v2.app.job.Task) TaskType(org.apache.hadoop.mapreduce.v2.api.records.TaskType) BadRequestException(org.apache.hadoop.yarn.webapp.BadRequestException) Job(org.apache.hadoop.mapreduce.v2.app.job.Job) TasksInfo(org.apache.hadoop.mapreduce.v2.app.webapp.dao.TasksInfo) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

TaskType (org.apache.hadoop.mapreduce.v2.api.records.TaskType)15 JobId (org.apache.hadoop.mapreduce.v2.api.records.JobId)8 TaskId (org.apache.hadoop.mapreduce.v2.api.records.TaskId)8 Task (org.apache.hadoop.mapreduce.v2.app.job.Task)8 Job (org.apache.hadoop.mapreduce.v2.app.job.Job)7 TaskAttemptId (org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptId)5 Test (org.junit.Test)5 HashMap (java.util.HashMap)4 TaskInfo (org.apache.hadoop.mapreduce.v2.app.webapp.dao.TaskInfo)4 Map (java.util.Map)3 Counters (org.apache.hadoop.mapreduce.Counters)3 ClientResponse (com.sun.jersey.api.client.ClientResponse)2 UniformInterfaceException (com.sun.jersey.api.client.UniformInterfaceException)2 WebResource (com.sun.jersey.api.client.WebResource)2 ArrayList (java.util.ArrayList)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 Path (org.apache.hadoop.fs.Path)2