Search in sources :

Example 1 with SessionsGetResponse

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

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

the class SparkLivyProcessManager method waitForSessionToBecomeIdle.

/**
 * returns true is session becomes idle; false if it fails to start
 */
private boolean waitForSessionToBecomeIdle(JerseyRestClient jerseyClient, Integer id) {
    Optional<Session> optSession;
    do {
        try {
            Thread.sleep(livyProperties.getPollingInterval());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        SessionsGetResponse sessions = livyClient.getSessions(jerseyClient);
        logger.debug("poll server for session with id='{}'", id);
        optSession = sessions.getSessionWithId(id);
        if (optSession.isPresent() && SessionState.FINAL_STATES.contains(optSession.get().getState())) {
            return false;
        }
    } while (!(optSession.isPresent() && optSession.get().getState().equals(SessionState.idle)));
    return true;
}
Also used : SessionsGetResponse(com.thinkbiganalytics.kylo.spark.model.SessionsGetResponse) Session(com.thinkbiganalytics.kylo.spark.model.Session)

Example 3 with SessionsGetResponse

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

the class SparkLivyProcessManager method getLivySession.

private Optional<Session> getLivySession(SparkLivyProcess sparkLivyProcess) {
    JerseyRestClient jerseyClient = getClient(sparkLivyProcess);
    SessionsGetResponse sessions = livyClient.getSessions(jerseyClient);
    if (sessions == null) {
        logger.error("Server not reachable", new LivyServerNotReachableException("Empty result from LivyClient.getSessions"));
        throw new LivyUserException("livy.server_not_found");
    }
    Optional<Session> optSession = sessions.getSessionWithId(sparkLivyProcess.getSessionId());
    if (!optSession.isPresent()) {
        // current client not found... let's make a new one
        clearClientState(sparkLivyProcess);
    }
    return optSession;
}
Also used : SessionsGetResponse(com.thinkbiganalytics.kylo.spark.model.SessionsGetResponse) LivyUserException(com.thinkbiganalytics.kylo.spark.exceptions.LivyUserException) JerseyRestClient(com.thinkbiganalytics.rest.JerseyRestClient) LivyServerNotReachableException(com.thinkbiganalytics.kylo.spark.exceptions.LivyServerNotReachableException) Session(com.thinkbiganalytics.kylo.spark.model.Session)

Aggregations

SessionsGetResponse (com.thinkbiganalytics.kylo.spark.model.SessionsGetResponse)3 Session (com.thinkbiganalytics.kylo.spark.model.Session)2 LivyException (com.thinkbiganalytics.kylo.spark.exceptions.LivyException)1 LivyServerNotReachableException (com.thinkbiganalytics.kylo.spark.exceptions.LivyServerNotReachableException)1 LivyUserException (com.thinkbiganalytics.kylo.spark.exceptions.LivyUserException)1 JerseyRestClient (com.thinkbiganalytics.rest.JerseyRestClient)1 WebApplicationException (javax.ws.rs.WebApplicationException)1