Search in sources :

Example 1 with ServerStatusResponse

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

the class SparkShellProxyController method getServerStatus.

@GET
@Path(SERVER_STATUS)
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Fetches the status of a transformation.")
@ApiResponses({ @ApiResponse(code = 200, message = "Returns the status of the spark server and session for current user if applicable.", response = ServerStatusResponse.class), @ApiResponse(code = 500, message = "There was a problem checking the spark server.", response = RestResponseStatus.class) })
@Nonnull
public Response getServerStatus() {
    try {
        final SparkShellProcess process = getSparkShellProcess();
        final ServerStatusResponse serverStatusResponse = restClient.serverStatus(process);
        return Response.ok(serverStatusResponse).build();
    } catch (Exception e) {
        throw new WebApplicationException("Unhandled exception attempting to get server status", e);
    }
}
Also used : SparkShellProcess(com.thinkbiganalytics.spark.shell.SparkShellProcess) WebApplicationException(javax.ws.rs.WebApplicationException) ServerStatusResponse(com.thinkbiganalytics.spark.rest.model.ServerStatusResponse) SparkException(com.thinkbiganalytics.kylo.spark.SparkException) WebApplicationException(javax.ws.rs.WebApplicationException) NoSuchMessageException(org.springframework.context.NoSuchMessageException) TimeoutException(java.util.concurrent.TimeoutException) BadRequestException(javax.ws.rs.BadRequestException) NotFoundException(javax.ws.rs.NotFoundException) SparkShellSaveException(com.thinkbiganalytics.spark.shell.SparkShellSaveException) SparkShellTransformException(com.thinkbiganalytics.spark.shell.SparkShellTransformException) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) Nonnull(javax.annotation.Nonnull) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 2 with ServerStatusResponse

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

the class LivyRestModelTransformer method toServerStatusResponse.

public static ServerStatusResponse toServerStatusResponse(LivyServer livyServer, Integer sessionId) {
    LivyServerStatus livyServerStatus = livyServer.getLivyServerStatus();
    LivySessionStatus livySessionStatus = null;
    SessionState sessionState = livyServer.getLivySessionState(sessionId);
    if (sessionState == null) {
        // don't know about session, could compare id to high water to see if dropped
        if (sessionId <= livyServer.getSessionIdHighWaterMark()) {
            livySessionStatus = LivySessionStatus.completed;
        } else {
            throw new WebApplicationException("No session with that id was created on the server", 404);
        }
    } else if (SessionState.FINAL_STATES.contains(sessionState)) {
        livySessionStatus = LivySessionStatus.completed;
    } else if (SessionState.READY_STATES.contains(sessionState)) {
        livySessionStatus = LivySessionStatus.ready;
    } else if (livyServerStatus == LivyServerStatus.http_error) {
        livySessionStatus = LivySessionStatus.http_error;
    }
    ServerStatusResponse.ServerStatus serverStatus = ServerStatusResponse.ServerStatus.valueOf(livyServerStatus.toString());
    ServerStatusResponse.SessionStatus sessionStatus = ServerStatusResponse.SessionStatus.valueOf(livySessionStatus.toString());
    return ServerStatusResponse.newInstance(serverStatus, sessionId.toString(), sessionStatus);
}
Also used : LivySessionStatus(com.thinkbiganalytics.kylo.spark.client.model.enums.LivySessionStatus) SessionState(com.thinkbiganalytics.kylo.spark.model.enums.SessionState) LivyServerStatus(com.thinkbiganalytics.kylo.spark.client.model.enums.LivyServerStatus) WebApplicationException(javax.ws.rs.WebApplicationException) ServerStatusResponse(com.thinkbiganalytics.spark.rest.model.ServerStatusResponse)

Aggregations

ServerStatusResponse (com.thinkbiganalytics.spark.rest.model.ServerStatusResponse)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 SparkException (com.thinkbiganalytics.kylo.spark.SparkException)1 LivyServerStatus (com.thinkbiganalytics.kylo.spark.client.model.enums.LivyServerStatus)1 LivySessionStatus (com.thinkbiganalytics.kylo.spark.client.model.enums.LivySessionStatus)1 SessionState (com.thinkbiganalytics.kylo.spark.model.enums.SessionState)1 SparkShellProcess (com.thinkbiganalytics.spark.shell.SparkShellProcess)1 SparkShellSaveException (com.thinkbiganalytics.spark.shell.SparkShellSaveException)1 SparkShellTransformException (com.thinkbiganalytics.spark.shell.SparkShellTransformException)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 TimeoutException (java.util.concurrent.TimeoutException)1 Nonnull (javax.annotation.Nonnull)1 BadRequestException (javax.ws.rs.BadRequestException)1 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 NotFoundException (javax.ws.rs.NotFoundException)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 NoSuchMessageException (org.springframework.context.NoSuchMessageException)1