Search in sources :

Example 1 with LivyException

use of com.thinkbiganalytics.kylo.spark.exceptions.LivyException in project kylo by Teradata.

the class DefaultLivyClient method getSessions.

@Override
public SessionsGetResponse getSessions(JerseyRestClient client) {
    try {
        SessionsGetResponse sessions = client.get(SESSIONS_URL, SessionsGetResponse.class);
        livyServer.setLivyServerStatus(LivyServerStatus.alive);
        logger.debug("sessions={}", sessions);
        return sessions;
    } catch (WebApplicationException wae) {
        if (wae.getResponse().getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
            livyServer.setLivyServerStatus(LivyServerStatus.http_error);
        }
        throw wae;
    } catch (LivyException le) {
        livyServer.setLivyServerStatus(LivyServerStatus.http_error);
        throw le;
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) SessionsGetResponse(com.thinkbiganalytics.kylo.spark.model.SessionsGetResponse) LivyException(com.thinkbiganalytics.kylo.spark.exceptions.LivyException)

Example 2 with LivyException

use of com.thinkbiganalytics.kylo.spark.exceptions.LivyException in project kylo by Teradata.

the class DefaultLivyClient method getStatement.

@Override
public Statement getStatement(JerseyRestClient client, SparkLivyProcess sparkLivyProcess, Integer statementId) {
    Integer sessionId = sparkLivyProcess.getSessionId();
    try {
        Statement statement = client.get(STATEMENT_URL(sessionId, statementId), Statement.class);
        livyServer.setLivyServerStatus(LivyServerStatus.alive);
        logger.debug("statement={}", statement);
        return statement;
    } catch (WebApplicationException wae) {
        if (wae.getResponse().getStatus() != 404 || wae.getResponse().getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
            livyServer.setLivyServerStatus(LivyServerStatus.http_error);
        }
        throw wae;
    } catch (LivyException le) {
        livyServer.setLivyServerStatus(LivyServerStatus.http_error);
        throw le;
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Statement(com.thinkbiganalytics.kylo.spark.model.Statement) LivyException(com.thinkbiganalytics.kylo.spark.exceptions.LivyException)

Example 3 with LivyException

use of com.thinkbiganalytics.kylo.spark.exceptions.LivyException in project kylo by Teradata.

the class DefaultLivyClient method postSessions.

@Override
public Session postSessions(JerseyRestClient client, SessionsPost sessionsPost) {
    try {
        Session session = client.post(SESSIONS_URL, sessionsPost, Session.class);
        livyServer.setLivyServerStatus(LivyServerStatus.alive);
        livyServer.setSessionIdHighWaterMark(session.getId());
        livyServer.setLivySessionState(session.getId(), session.getState());
        logger.debug("session={}", session);
        return session;
    } catch (WebApplicationException wae) {
        if (wae.getResponse().getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
            livyServer.setLivyServerStatus(LivyServerStatus.http_error);
        }
        throw wae;
    } catch (LivyException le) {
        livyServer.setLivyServerStatus(LivyServerStatus.http_error);
        throw le;
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) LivyException(com.thinkbiganalytics.kylo.spark.exceptions.LivyException) Session(com.thinkbiganalytics.kylo.spark.model.Session)

Example 4 with LivyException

use of com.thinkbiganalytics.kylo.spark.exceptions.LivyException in project kylo by Teradata.

the class DefaultLivyClient method postStatement.

@Override
public Statement postStatement(JerseyRestClient client, SparkLivyProcess sparkLivyProcess, StatementsPost sp) {
    Integer sessionId = sparkLivyProcess.getSessionId();
    try {
        Statement statement = client.post(STATEMENTS_URL(sessionId), sp, Statement.class);
        livyServer.setLivyServerStatus(LivyServerStatus.alive);
        logger.debug("statement={}", statement);
        return statement;
    } catch (WebApplicationException wae) {
        if (wae.getResponse().getStatus() != 404 || wae.getResponse().getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
            livyServer.setLivyServerStatus(LivyServerStatus.http_error);
        }
        throw wae;
    } catch (LivyException le) {
        livyServer.setLivyServerStatus(LivyServerStatus.http_error);
        throw le;
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Statement(com.thinkbiganalytics.kylo.spark.model.Statement) LivyException(com.thinkbiganalytics.kylo.spark.exceptions.LivyException)

Example 5 with LivyException

use of com.thinkbiganalytics.kylo.spark.exceptions.LivyException in project kylo by Teradata.

the class SparkLivyProcessManager method startLivySession.

private Session startLivySession(SparkLivyProcess sparkLivyProcess) {
    // it was determined we needed a
    sparkLivyProcess.newSession();
    JerseyRestClient jerseyClient = getClient(sparkLivyProcess);
    Map<String, String> sparkProps = livyProperties.getSparkProperties();
    SessionsPost.Builder builder = new SessionsPost.Builder().kind(// "shared" most likely
    livyProperties.getLivySessionKind().toString()).conf(// "spark.driver.extraJavaOptions", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8990"
    sparkProps);
    logger.debug("LivyProperties={}", livyProperties);
    if (livyProperties.getProxyUser()) {
        String user = processCache.inverse().get(sparkLivyProcess);
        if (user != null) {
            builder.proxyUser(user);
        }
    }
    SessionsPost sessionsPost = builder.build();
    logger.info("sessionsPost={}", sessionsPost);
    Session currentSession;
    try {
        currentSession = livyClient.postSessions(jerseyClient, sessionsPost);
        if (currentSession == null) {
            logger.error("Server not reachable", new LivyServerNotReachableException("Empty result from LivyClient.postSessions"));
            throw new LivyUserException("livy.server_not_found");
        }
    } catch (LivyException le) {
        throw le;
    } catch (Exception e) {
        // resets the latch
        sparkLivyProcess.startFailed();
        this.processStopped(sparkLivyProcess);
        // NOTE: you can get "javax.ws.rs.ProcessingException: java.io.IOException: Error writing to server" on Ubuntu see: https://stackoverflow.com/a/39718929/154461
        throw new LivyException(e);
    }
    sparkLivyProcess.setSessionId(currentSession.getId());
    // notifies listeners
    this.processStarted(sparkLivyProcess);
    // begin monitoring this session if configured to do so..
    heartbeatMonitor.monitorSession(sparkLivyProcess);
    return currentSession;
}
Also used : SessionsPost(com.thinkbiganalytics.kylo.spark.model.SessionsPost) LivyException(com.thinkbiganalytics.kylo.spark.exceptions.LivyException) LivyUserException(com.thinkbiganalytics.kylo.spark.exceptions.LivyUserException) JerseyRestClient(com.thinkbiganalytics.rest.JerseyRestClient) LivyException(com.thinkbiganalytics.kylo.spark.exceptions.LivyException) LivyServerNotReachableException(com.thinkbiganalytics.kylo.spark.exceptions.LivyServerNotReachableException) LivyUserException(com.thinkbiganalytics.kylo.spark.exceptions.LivyUserException) LivyInvalidSessionException(com.thinkbiganalytics.kylo.spark.exceptions.LivyInvalidSessionException) Session(com.thinkbiganalytics.kylo.spark.model.Session) LivyServerNotReachableException(com.thinkbiganalytics.kylo.spark.exceptions.LivyServerNotReachableException)

Aggregations

LivyException (com.thinkbiganalytics.kylo.spark.exceptions.LivyException)5 WebApplicationException (javax.ws.rs.WebApplicationException)4 Session (com.thinkbiganalytics.kylo.spark.model.Session)2 Statement (com.thinkbiganalytics.kylo.spark.model.Statement)2 LivyInvalidSessionException (com.thinkbiganalytics.kylo.spark.exceptions.LivyInvalidSessionException)1 LivyServerNotReachableException (com.thinkbiganalytics.kylo.spark.exceptions.LivyServerNotReachableException)1 LivyUserException (com.thinkbiganalytics.kylo.spark.exceptions.LivyUserException)1 SessionsGetResponse (com.thinkbiganalytics.kylo.spark.model.SessionsGetResponse)1 SessionsPost (com.thinkbiganalytics.kylo.spark.model.SessionsPost)1 JerseyRestClient (com.thinkbiganalytics.rest.JerseyRestClient)1