Search in sources :

Example 1 with LivySessionStatus

use of com.thinkbiganalytics.kylo.spark.client.model.enums.LivySessionStatus 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

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 ServerStatusResponse (com.thinkbiganalytics.spark.rest.model.ServerStatusResponse)1 WebApplicationException (javax.ws.rs.WebApplicationException)1