use of com.sequenceiq.datalake.flow.start.event.SdxStartSuccessEvent in project cloudbreak by hortonworks.
the class SdxStartWaitHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<SdxStartWaitRequest> event) {
SdxStartWaitRequest waitRequest = event.getData();
Long sdxId = waitRequest.getResourceId();
String userId = waitRequest.getUserId();
Selectable response;
try {
LOGGER.debug("Start polling stack start process for id: {}", sdxId);
PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
sdxStartService.waitCloudbreakCluster(sdxId, pollingConfig);
response = new SdxStartSuccessEvent(sdxId, userId);
} catch (UserBreakException userBreakException) {
LOGGER.error("Start polling exited before timeout. Cause: ", userBreakException);
response = new SdxStartFailedEvent(sdxId, userId, userBreakException);
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Start poller stopped for stack: {}", sdxId);
response = new SdxStartFailedEvent(sdxId, userId, new PollerStoppedException("Datalake start timed out after " + durationInMinutes + " minutes"));
} catch (PollerException exception) {
LOGGER.error("Start polling failed for stack: {}", sdxId);
response = new SdxStartFailedEvent(sdxId, userId, exception);
}
return response;
}
use of com.sequenceiq.datalake.flow.start.event.SdxStartSuccessEvent in project cloudbreak by hortonworks.
the class SdxStartActions method finishedAction.
@Bean(name = "SDX_START_FINISHED_STATE")
public Action<?, ?> finishedAction() {
return new AbstractSdxAction<>(SdxStartSuccessEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxStartSuccessEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, SdxStartSuccessEvent payload, Map<Object, Object> variables) throws Exception {
LOGGER.info("SDX start finalized: {}", payload.getResourceId());
SdxCluster sdxCluster = sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.RUNNING, "Datalake is running", payload.getResourceId());
metricService.incrementMetricCounter(MetricType.SDX_START_FINISHED, sdxCluster);
sendEvent(context, SDX_START_FINALIZED_EVENT.event(), payload);
}
@Override
protected Object getFailurePayload(SdxStartSuccessEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return null;
}
};
}
Aggregations