Search in sources :

Example 11 with Produces

use of javax.ws.rs.Produces in project hadoop by apache.

the class AMWebServices method getJob.

@GET
@Path("/jobs/{jobid}")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
public JobInfo getJob(@Context HttpServletRequest hsr, @PathParam("jobid") String jid) {
    init();
    Job job = getJobFromJobIdString(jid, appCtx);
    return new JobInfo(job, hasAccess(job, hsr));
}
Also used : JobInfo(org.apache.hadoop.mapreduce.v2.app.webapp.dao.JobInfo) Job(org.apache.hadoop.mapreduce.v2.app.job.Job) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 12 with Produces

use of javax.ws.rs.Produces in project hadoop by apache.

the class AMWebServices method getJobs.

@GET
@Path("/jobs")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
public JobsInfo getJobs(@Context HttpServletRequest hsr) {
    init();
    JobsInfo allJobs = new JobsInfo();
    for (Job job : appCtx.getAllJobs().values()) {
        // getAllJobs only gives you a partial we want a full
        Job fullJob = appCtx.getJob(job.getID());
        if (fullJob == null) {
            continue;
        }
        allJobs.add(new JobInfo(fullJob, hasAccess(fullJob, hsr)));
    }
    return allJobs;
}
Also used : JobInfo(org.apache.hadoop.mapreduce.v2.app.webapp.dao.JobInfo) JobsInfo(org.apache.hadoop.mapreduce.v2.app.webapp.dao.JobsInfo) Job(org.apache.hadoop.mapreduce.v2.app.job.Job) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 13 with Produces

use of javax.ws.rs.Produces in project hadoop by apache.

the class AMWebServices method updateJobTaskAttemptState.

@PUT
@Path("/jobs/{jobid}/tasks/{taskid}/attempts/{attemptid}/state")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response updateJobTaskAttemptState(JobTaskAttemptState targetState, @Context HttpServletRequest hsr, @PathParam("jobid") String jid, @PathParam("taskid") String tid, @PathParam("attemptid") String attId) throws IOException, InterruptedException {
    init();
    Job job = getJobFromJobIdString(jid, appCtx);
    checkAccess(job, hsr);
    String remoteUser = hsr.getRemoteUser();
    UserGroupInformation callerUGI = null;
    if (remoteUser != null) {
        callerUGI = UserGroupInformation.createRemoteUser(remoteUser);
    }
    Task task = getTaskFromTaskIdString(tid, job);
    TaskAttempt ta = getTaskAttemptFromTaskAttemptString(attId, task);
    if (!ta.getState().toString().equals(targetState.getState())) {
        // allow users to kill the job task attempt
        if (targetState.getState().equals(TaskAttemptState.KILLED.toString())) {
            return killJobTaskAttempt(ta, callerUGI, hsr);
        }
        throw new BadRequestException("Only '" + TaskAttemptState.KILLED.toString() + "' is allowed as a target state.");
    }
    JobTaskAttemptState ret = new JobTaskAttemptState();
    ret.setState(ta.getState().toString());
    return Response.status(Status.OK).entity(ret).build();
}
Also used : Task(org.apache.hadoop.mapreduce.v2.app.job.Task) JobTaskAttemptState(org.apache.hadoop.mapreduce.v2.app.webapp.dao.JobTaskAttemptState) BadRequestException(org.apache.hadoop.yarn.webapp.BadRequestException) TaskAttempt(org.apache.hadoop.mapreduce.v2.app.job.TaskAttempt) Job(org.apache.hadoop.mapreduce.v2.app.job.Job) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) PUT(javax.ws.rs.PUT)

Example 14 with Produces

use of javax.ws.rs.Produces in project hadoop by apache.

the class AMWebServices method getJobCounters.

@GET
@Path("/jobs/{jobid}/counters")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
public JobCounterInfo getJobCounters(@Context HttpServletRequest hsr, @PathParam("jobid") String jid) {
    init();
    Job job = getJobFromJobIdString(jid, appCtx);
    checkAccess(job, hsr);
    return new JobCounterInfo(this.appCtx, job);
}
Also used : JobCounterInfo(org.apache.hadoop.mapreduce.v2.app.webapp.dao.JobCounterInfo) Job(org.apache.hadoop.mapreduce.v2.app.job.Job) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 15 with Produces

use of javax.ws.rs.Produces in project hadoop by apache.

the class AMWebServices method getJobTaskAttemptState.

@GET
@Path("/jobs/{jobid}/tasks/{taskid}/attempts/{attemptid}/state")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
public JobTaskAttemptState getJobTaskAttemptState(@Context HttpServletRequest hsr, @PathParam("jobid") String jid, @PathParam("taskid") String tid, @PathParam("attemptid") String attId) throws IOException, InterruptedException {
    init();
    Job job = getJobFromJobIdString(jid, appCtx);
    checkAccess(job, hsr);
    Task task = getTaskFromTaskIdString(tid, job);
    TaskAttempt ta = getTaskAttemptFromTaskAttemptString(attId, task);
    return new JobTaskAttemptState(ta.getState().toString());
}
Also used : Task(org.apache.hadoop.mapreduce.v2.app.job.Task) JobTaskAttemptState(org.apache.hadoop.mapreduce.v2.app.webapp.dao.JobTaskAttemptState) TaskAttempt(org.apache.hadoop.mapreduce.v2.app.job.TaskAttempt) Job(org.apache.hadoop.mapreduce.v2.app.job.Job) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

Produces (javax.ws.rs.Produces)937 Path (javax.ws.rs.Path)686 GET (javax.ws.rs.GET)600 ApiOperation (io.swagger.annotations.ApiOperation)271 Consumes (javax.ws.rs.Consumes)241 POST (javax.ws.rs.POST)233 ApiResponses (io.swagger.annotations.ApiResponses)216 Response (javax.ws.rs.core.Response)110 TimedResource (org.killbill.commons.metrics.TimedResource)109 IOException (java.io.IOException)105 WebApplicationException (javax.ws.rs.WebApplicationException)95 Timed (com.codahale.metrics.annotation.Timed)92 URI (java.net.URI)88 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)81 PUT (javax.ws.rs.PUT)79 ArrayList (java.util.ArrayList)71 UUID (java.util.UUID)62 Map (java.util.Map)58 TenantContext (org.killbill.billing.util.callcontext.TenantContext)58 DELETE (javax.ws.rs.DELETE)56