use of com.sequenceiq.datalake.flow.datalake.cmsync.event.SdxCmSyncFailedEvent in project cloudbreak by hortonworks.
the class SdxCmSyncWaitHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<SdxCmSyncWaitEvent> event) {
LOGGER.debug("Entering handler for calling sync CM and parcel versions from CM server");
SdxCmSyncWaitEvent sdxCmSyncWaitEvent = event.getData();
try {
SdxCluster sdxCluster = sdxService.getById(sdxCmSyncWaitEvent.getResourceId());
PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES).withStopPollingIfExceptionOccurred(true);
sdxWaitService.waitForCloudbreakFlow(sdxCluster, pollingConfig, "Sync cm");
return new SdxEvent(SDX_CM_SYNC_FINISHED_EVENT.event(), event.getData().getResourceId(), event.getData().getUserId());
} catch (SdxWaitException e) {
LOGGER.warn("Error happened during waiting for syncing CM and parcel versions from a datalake CM to component table {}, error: ", sdxCmSyncWaitEvent.getResourceId(), e);
return new SdxCmSyncFailedEvent(sdxCmSyncWaitEvent.getResourceId(), sdxCmSyncWaitEvent.getUserId(), e);
}
}
use of com.sequenceiq.datalake.flow.datalake.cmsync.event.SdxCmSyncFailedEvent in project cloudbreak by hortonworks.
the class SdxCmSyncActions method cmSyncFailedAction.
@Bean(name = "SDX_CM_SYNC_FAILED_STATE")
public Action<?, ?> cmSyncFailedAction() {
return new AbstractSdxAction<>(SdxCmSyncFailedEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxCmSyncFailedEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, SdxCmSyncFailedEvent payload, Map<Object, Object> variables) throws Exception {
LOGGER.info("Sdx cm sync failure, error: ", payload.getException());
Flow flow = getFlow(context.getFlowParameters().getFlowId());
flow.setFlowFailed(payload.getException());
sendEvent(context, SDX_CM_SYNC_FAILED_HANDLED_EVENT.event(), payload);
}
@Override
protected Object getFailurePayload(SdxCmSyncFailedEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return new SdxCmSyncFailedEvent(payload.getResourceId(), payload.getUserId(), ex);
}
};
}
Aggregations