Search in sources :

Example 1 with SdxCmSyncFailedEvent

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);
    }
}
Also used : SdxCmSyncWaitEvent(com.sequenceiq.datalake.flow.datalake.cmsync.event.SdxCmSyncWaitEvent) SdxWaitException(com.sequenceiq.datalake.service.sdx.flowwait.exception.SdxWaitException) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) SdxEvent(com.sequenceiq.datalake.flow.SdxEvent) SdxCmSyncFailedEvent(com.sequenceiq.datalake.flow.datalake.cmsync.event.SdxCmSyncFailedEvent) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig)

Example 2 with SdxCmSyncFailedEvent

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);
        }
    };
}
Also used : FlowParameters(com.sequenceiq.flow.core.FlowParameters) AbstractSdxAction(com.sequenceiq.datalake.service.AbstractSdxAction) Optional(java.util.Optional) StateContext(org.springframework.statemachine.StateContext) SdxCmSyncFailedEvent(com.sequenceiq.datalake.flow.datalake.cmsync.event.SdxCmSyncFailedEvent) Map(java.util.Map) SdxContext(com.sequenceiq.datalake.flow.SdxContext) Flow(com.sequenceiq.flow.core.Flow) Bean(org.springframework.context.annotation.Bean)

Aggregations

SdxCmSyncFailedEvent (com.sequenceiq.datalake.flow.datalake.cmsync.event.SdxCmSyncFailedEvent)2 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)1 SdxContext (com.sequenceiq.datalake.flow.SdxContext)1 SdxEvent (com.sequenceiq.datalake.flow.SdxEvent)1 SdxCmSyncWaitEvent (com.sequenceiq.datalake.flow.datalake.cmsync.event.SdxCmSyncWaitEvent)1 AbstractSdxAction (com.sequenceiq.datalake.service.AbstractSdxAction)1 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)1 SdxWaitException (com.sequenceiq.datalake.service.sdx.flowwait.exception.SdxWaitException)1 Flow (com.sequenceiq.flow.core.Flow)1 FlowParameters (com.sequenceiq.flow.core.FlowParameters)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Bean (org.springframework.context.annotation.Bean)1 StateContext (org.springframework.statemachine.StateContext)1