Search in sources :

Example 1 with SessionState

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

Example 2 with SessionState

use of com.thinkbiganalytics.kylo.spark.model.enums.SessionState in project kylo by Teradata.

the class LivyHeartbeatMonitor method serverReady.

public AtomicBoolean serverReady(SparkLivyProcess sparkLivyProcess) {
    Validate.notNull(sparkLivyProcess, "sparkShellProcess cannot be null");
    Optional<SessionState> sessionState = checkSession(sparkLivyProcess);
    AtomicBoolean connectionAlive = connectionStatusMap.get(sparkLivyProcess);
    if (sessionState.isPresent() && livyServer.getLivyServerStatus() == LivyServerStatus.alive) {
        connectionAlive.set(true);
    } else {
        connectionAlive.set(false);
    }
    return connectionAlive;
}
Also used : SessionState(com.thinkbiganalytics.kylo.spark.model.enums.SessionState) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean)

Example 3 with SessionState

use of com.thinkbiganalytics.kylo.spark.model.enums.SessionState in project kylo by Teradata.

the class LivyHeartbeatMonitor method checkSession.

public Optional<SessionState> checkSession(SparkLivyProcess sparkLivyProcess) {
    // TODO: checkSession seems to get in a state where it is called multiple times per heartbeat
    logger.entry(sparkLivyProcess);
    SessionState sessionState = null;
    try {
        Session session = livyClient.getSession(restClient, sparkLivyProcess);
        sessionState = session.getState();
    } catch (ProcessingException pe) {
        logger.trace("Caught ProcessingException:", pe);
        if (!(pe.getCause() instanceof SocketTimeoutException || pe.getCause() instanceof SSLHandshakeException || pe.getCause() instanceof SocketException)) {
            throw logger.throwing(pe);
        }
    } catch (WebApplicationException wae) {
    // recording of state for wae's was taken care of by livyClient.getSession
    }
    return logger.exit(Optional.ofNullable(sessionState));
}
Also used : SessionState(com.thinkbiganalytics.kylo.spark.model.enums.SessionState) SocketException(java.net.SocketException) SocketTimeoutException(java.net.SocketTimeoutException) WebApplicationException(javax.ws.rs.WebApplicationException) SSLHandshakeException(javax.net.ssl.SSLHandshakeException) Session(com.thinkbiganalytics.kylo.spark.model.Session) ProcessingException(javax.ws.rs.ProcessingException)

Aggregations

SessionState (com.thinkbiganalytics.kylo.spark.model.enums.SessionState)3 WebApplicationException (javax.ws.rs.WebApplicationException)2 LivyServerStatus (com.thinkbiganalytics.kylo.spark.client.model.enums.LivyServerStatus)1 LivySessionStatus (com.thinkbiganalytics.kylo.spark.client.model.enums.LivySessionStatus)1 Session (com.thinkbiganalytics.kylo.spark.model.Session)1 ServerStatusResponse (com.thinkbiganalytics.spark.rest.model.ServerStatusResponse)1 SocketException (java.net.SocketException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 SSLHandshakeException (javax.net.ssl.SSLHandshakeException)1 ProcessingException (javax.ws.rs.ProcessingException)1