Search in sources :

Example 1 with SparkJobContext

use of com.thinkbiganalytics.kylo.spark.job.SparkJobContext in project kylo by Teradata.

the class SparkShellProxyController method getJobResult.

@GET
@Path("/job/{job}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Fetches the status of a job")
@ApiResponses({ @ApiResponse(code = 200, message = "Returns the status of the job.", response = SparkJobResponse.class), @ApiResponse(code = 404, message = "The job does not exist.", response = RestResponseStatus.class), @ApiResponse(code = 500, message = "There was a problem accessing the data.", response = SparkJobResponse.class) })
public void getJobResult(@Nonnull @PathParam("job") final String jobId, @Suspended final AsyncResponse response) {
    final SparkJobContext context = sparkJobService.findById(jobId).orElseThrow(NotFoundException::new);
    context.subscribe(jobSubscriber(context, response));
}
Also used : SparkJobContext(com.thinkbiganalytics.kylo.spark.job.SparkJobContext) NotFoundException(javax.ws.rs.NotFoundException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 2 with SparkJobContext

use of com.thinkbiganalytics.kylo.spark.job.SparkJobContext in project kylo by Teradata.

the class SparkShellProxyController method createJob.

@POST
@Path("/job")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Submits a Spark job to be executed.")
@ApiResponses({ @ApiResponse(code = 200, message = "Returns the status of the job.", response = SparkJobResponse.class), @ApiResponse(code = 400, message = "The requested job does not exist.", response = RestResponseStatus.class), @ApiResponse(code = 500, message = "There was a problem processing the job.", response = SparkJobResponse.class) })
public void createJob(final SparkJobRequest request, @Suspended final AsyncResponse response) {
    // Validate request
    if (request == null || request.getScript() == null) {
        throw transformError(Response.Status.BAD_REQUEST, "job.missing-script", null);
    }
    // Execute request
    final SparkJobContext context = sparkJobService.create(request);
    context.subscribe(jobSubscriber(context, response));
}
Also used : SparkJobContext(com.thinkbiganalytics.kylo.spark.job.SparkJobContext) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

SparkJobContext (com.thinkbiganalytics.kylo.spark.job.SparkJobContext)2 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 NotFoundException (javax.ws.rs.NotFoundException)1 POST (javax.ws.rs.POST)1