use of com.thinkbiganalytics.spark.metadata.SparkJob in project kylo by Teradata.
the class TransformService method submitSparkJob.
/**
* Submits the specified job to be executed.
*/
@Nonnull
public SparkJobResponse submitSparkJob(@Nonnull final Supplier<SparkJobResult> task) {
log.entry(task);
// Execute script
final String id = newTableName();
final SparkJob job = new SparkJob(id, task, engine.getSparkContext());
tracker.submitJob(job);
// Build response
final SparkJobResponse response = new SparkJobResponse();
response.setId(id);
response.setStatus(SparkJobResponse.Status.PENDING);
return log.exit(response);
}
use of com.thinkbiganalytics.spark.metadata.SparkJob in project kylo by Teradata.
the class SparkJobController method getJobResult.
@GET
@Path("/{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 Response getJobResult(@PathParam("job") final String id) {
try {
final SparkJob job = transformService.getSparkJob(id);
final SparkJobResponse response = new SparkJobResponse();
response.setId(job.getGroupId());
if (job.isDone()) {
final SparkJobResult result = job.get();
response.setResult(result);
response.setStatus(SparkJobResponse.Status.SUCCESS);
} else {
response.setStatus(SparkJobResponse.Status.PENDING);
}
return Response.ok(response).build();
} catch (final IllegalArgumentException e) {
throw new NotFoundException(getMessage("job.not-found"));
} catch (final Exception e) {
throw new InternalServerErrorException(e);
}
}
Aggregations