Search in sources :

Example 11 with SparkJobResponse

use of com.thinkbiganalytics.kylo.spark.rest.model.job.SparkJobResponse in project kylo by Teradata.

the class BatchJobSupplier method get.

@Nonnull
@Override
public SparkJobResponse get() {
    // Create the job
    SparkJobResponse response = restClient.createJob(process, request);
    // Wait for job to complete
    while (response.getStatus() == SparkJobResponse.Status.PENDING) {
        sleep(pollInterval);
        response = restClient.getJobResult(process, response.getId()).orElseThrow(NoSuchElementException::new);
    }
    return response;
}
Also used : SparkJobResponse(com.thinkbiganalytics.kylo.spark.rest.model.job.SparkJobResponse) Nonnull(javax.annotation.Nonnull)

Example 12 with SparkJobResponse

use of com.thinkbiganalytics.kylo.spark.rest.model.job.SparkJobResponse in project kylo by Teradata.

the class LivyRestModelTransformer method toJobResponse.

@Nonnull
public static SparkJobResponse toJobResponse(@Nonnull final String id, @Nonnull final Statement statement) {
    final SparkJobResponse response = new SparkJobResponse();
    response.setId(id);
    response.setStatus(StatementStateTranslator.translate(statement.getState()));
    if (response.getStatus() == TransformResponse.Status.SUCCESS) {
        final JsonNode data = statement.getOutput().getData();
        if (data != null) {
            final String json = data.get("application/json").asText();
            response.setResult(ObjectMapperSerializer.deserialize(json, SparkJobResult.class));
        }
    }
    return response;
}
Also used : SparkJobResponse(com.thinkbiganalytics.kylo.spark.rest.model.job.SparkJobResponse) SparkJobResult(com.thinkbiganalytics.kylo.spark.rest.model.job.SparkJobResult) JsonNode(com.fasterxml.jackson.databind.JsonNode) Nonnull(javax.annotation.Nonnull)

Aggregations

SparkJobResponse (com.thinkbiganalytics.kylo.spark.rest.model.job.SparkJobResponse)12 Nonnull (javax.annotation.Nonnull)6 SparkJobResult (com.thinkbiganalytics.kylo.spark.rest.model.job.SparkJobResult)4 Test (org.junit.Test)4 Statement (com.thinkbiganalytics.kylo.spark.model.Statement)2 JerseyRestClient (com.thinkbiganalytics.rest.JerseyRestClient)2 SparkJob (com.thinkbiganalytics.spark.metadata.SparkJob)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 SparkException (com.thinkbiganalytics.kylo.spark.SparkException)1 ChainableSupplier (com.thinkbiganalytics.kylo.spark.job.tasks.ChainableSupplier)1 JobStatusFunction (com.thinkbiganalytics.kylo.spark.job.tasks.JobStatusFunction)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 NoSuchElementException (java.util.NoSuchElementException)1 UUID (java.util.UUID)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ExecutorService (java.util.concurrent.ExecutorService)1 Future (java.util.concurrent.Future)1 Nullable (javax.annotation.Nullable)1 ScriptException (javax.script.ScriptException)1