use of com.sequenceiq.datalake.flow.create.event.RdsWaitSuccessEvent in project cloudbreak by hortonworks.
the class RdsWaitHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<RdsWaitRequest> event) {
RdsWaitRequest rdsWaitRequest = event.getData();
Long sdxId = rdsWaitRequest.getResourceId();
String userId = rdsWaitRequest.getUserId();
try {
DetailedEnvironmentResponse env = environmentService.waitNetworkAndGetEnvironment(sdxId);
Optional<SdxCluster> sdxCluster = sdxClusterRepository.findById(sdxId);
if (sdxCluster.isPresent()) {
if (sdxCluster.get().hasExternalDatabase()) {
validForDatabaseCreation(sdxId, env);
LOGGER.debug("start polling database for sdx: {}", sdxId);
databaseService.create(sdxCluster.get(), env);
setRdsCreatedStatus(sdxCluster.get());
return new RdsWaitSuccessEvent(sdxId, userId);
} else {
LOGGER.debug("skipping creation of database for sdx: {}", sdxId);
return new RdsWaitSuccessEvent(sdxId, userId);
}
} else {
throw notFound("SDX cluster", sdxId).get();
}
} catch (UserBreakException userBreakException) {
LOGGER.error("Database polling exited before timeout. Cause: ", userBreakException);
return new SdxCreateFailedEvent(sdxId, userId, userBreakException);
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Database poller stopped for sdx: {}", sdxId, pollerStoppedException);
return new SdxCreateFailedEvent(sdxId, userId, new PollerStoppedException("Database creation timed out after " + durationInMinutes + " minutes"));
} catch (PollerException exception) {
LOGGER.error("Database polling failed for sdx: {}", sdxId, exception);
return new SdxCreateFailedEvent(sdxId, userId, exception);
} catch (Exception anotherException) {
LOGGER.error("Something wrong happened in sdx database creation wait phase", anotherException);
return new SdxCreateFailedEvent(sdxId, userId, anotherException);
}
}
use of com.sequenceiq.datalake.flow.create.event.RdsWaitSuccessEvent 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