Search in sources :

Example 1 with EnvWaitSuccessEvent

use of com.sequenceiq.datalake.flow.create.event.EnvWaitSuccessEvent in project cloudbreak by hortonworks.

the class EnvWaitHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<EnvWaitRequest> event) {
    EnvWaitRequest envWaitRequest = event.getData();
    Long datalakeId = envWaitRequest.getResourceId();
    String userId = envWaitRequest.getUserId();
    Selectable response;
    try {
        LOGGER.debug("start polling env for sdx: {}", datalakeId);
        DetailedEnvironmentResponse detailedEnvironmentResponse = environmentService.waitAndGetEnvironment(datalakeId);
        response = new EnvWaitSuccessEvent(datalakeId, userId, detailedEnvironmentResponse);
        setEnvCreatedStatus(datalakeId);
    } catch (UserBreakException userBreakException) {
        LOGGER.error("Env polling exited before timeout. Cause: ", userBreakException);
        response = new SdxCreateFailedEvent(datalakeId, userId, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.error("Env poller stopped for sdx: {}", datalakeId, pollerStoppedException);
        response = new SdxCreateFailedEvent(datalakeId, userId, new PollerStoppedException("Env wait timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.error("Env polling failed for sdx: {}", datalakeId, exception);
        response = new SdxCreateFailedEvent(datalakeId, userId, exception);
    } catch (Exception anotherException) {
        LOGGER.error("Something wrong happened in sdx creation wait phase", anotherException);
        response = new SdxCreateFailedEvent(datalakeId, userId, anotherException);
    }
    return response;
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) SdxCreateFailedEvent(com.sequenceiq.datalake.flow.create.event.SdxCreateFailedEvent) PollerException(com.dyngr.exception.PollerException) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) EnvWaitRequest(com.sequenceiq.datalake.flow.create.event.EnvWaitRequest) EnvWaitSuccessEvent(com.sequenceiq.datalake.flow.create.event.EnvWaitSuccessEvent) PollerStoppedException(com.dyngr.exception.PollerStoppedException) UserBreakException(com.dyngr.exception.UserBreakException) PollerException(com.dyngr.exception.PollerException) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Aggregations

PollerException (com.dyngr.exception.PollerException)1 PollerStoppedException (com.dyngr.exception.PollerStoppedException)1 UserBreakException (com.dyngr.exception.UserBreakException)1 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 EnvWaitRequest (com.sequenceiq.datalake.flow.create.event.EnvWaitRequest)1 EnvWaitSuccessEvent (com.sequenceiq.datalake.flow.create.event.EnvWaitSuccessEvent)1 SdxCreateFailedEvent (com.sequenceiq.datalake.flow.create.event.SdxCreateFailedEvent)1 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)1