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;
}
}
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;
}
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;
}
Aggregations