use of com.sequenceiq.datalake.flow.create.event.EnvWaitRequest 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;
}
use of com.sequenceiq.datalake.flow.create.event.EnvWaitRequest in project cloudbreak by hortonworks.
the class SdxCreateActions method envWaitInProgress.
@Bean(name = "SDX_CREATION_WAIT_ENV_STATE")
public Action<?, ?> envWaitInProgress() {
return new AbstractSdxAction<>(RdsWaitSuccessEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, RdsWaitSuccessEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, RdsWaitSuccessEvent payload, Map<Object, Object> variables) throws Exception {
EnvWaitRequest req = EnvWaitRequest.from(context);
sendEvent(context, req.selector(), req);
}
@Override
protected Object getFailurePayload(RdsWaitSuccessEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return SdxCreateFailedEvent.from(payload, ex);
}
};
}
Aggregations