Search in sources :

Example 1 with SdxRepairStartRequest

use of com.sequenceiq.datalake.flow.repair.event.SdxRepairStartRequest in project cloudbreak by hortonworks.

the class SdxRepairActions method sdxRepairStarted.

@Bean(name = "SDX_REPAIR_START_STATE")
public Action<?, ?> sdxRepairStarted() {
    return new AbstractSdxAction<>(SdxRepairStartEvent.class) {

        @Override
        protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxRepairStartEvent payload) {
            return SdxContext.from(flowParameters, payload);
        }

        @Override
        protected void doExecute(SdxContext context, SdxRepairStartEvent payload, Map<Object, Object> variables) throws Exception {
            LOGGER.info("Start repair flow for Datalake: {}", payload.getResourceId());
            SdxRepairStartRequest request = new SdxRepairStartRequest(payload.getResourceId(), payload.getUserId(), payload.getRepairSettings());
            sendEvent(context, request.selector(), request);
        }

        @Override
        protected Object getFailurePayload(SdxRepairStartEvent payload, Optional<SdxContext> flowContext, Exception ex) {
            return SdxRepairCouldNotStartEvent.from(payload, ex);
        }
    };
}
Also used : FlowParameters(com.sequenceiq.flow.core.FlowParameters) AbstractSdxAction(com.sequenceiq.datalake.service.AbstractSdxAction) Optional(java.util.Optional) SdxRepairStartRequest(com.sequenceiq.datalake.flow.repair.event.SdxRepairStartRequest) StateContext(org.springframework.statemachine.StateContext) SdxRepairStartEvent(com.sequenceiq.datalake.flow.repair.event.SdxRepairStartEvent) Map(java.util.Map) SdxContext(com.sequenceiq.datalake.flow.SdxContext) Bean(org.springframework.context.annotation.Bean)

Example 2 with SdxRepairStartRequest

use of com.sequenceiq.datalake.flow.repair.event.SdxRepairStartRequest in project cloudbreak by hortonworks.

the class SdxRepairStartHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<SdxRepairStartRequest> event) {
    SdxRepairStartRequest request = event.getData();
    Long sdxId = request.getResourceId();
    String userId = request.getUserId();
    try {
        repairService.startSdxRepair(sdxId, request.getRepairSettings());
    } catch (Exception e) {
        LOGGER.error("Sdx repair start failed, sdxId: {}, error: {}", sdxId, e.getMessage());
        return new SdxRepairCouldNotStartEvent(sdxId, userId, e);
    }
    return new SdxRepairInProgressEvent(sdxId, userId);
}
Also used : SdxRepairStartRequest(com.sequenceiq.datalake.flow.repair.event.SdxRepairStartRequest) SdxRepairCouldNotStartEvent(com.sequenceiq.datalake.flow.repair.event.SdxRepairCouldNotStartEvent) SdxRepairInProgressEvent(com.sequenceiq.datalake.flow.repair.event.SdxRepairInProgressEvent)

Aggregations

SdxRepairStartRequest (com.sequenceiq.datalake.flow.repair.event.SdxRepairStartRequest)2 SdxContext (com.sequenceiq.datalake.flow.SdxContext)1 SdxRepairCouldNotStartEvent (com.sequenceiq.datalake.flow.repair.event.SdxRepairCouldNotStartEvent)1 SdxRepairInProgressEvent (com.sequenceiq.datalake.flow.repair.event.SdxRepairInProgressEvent)1 SdxRepairStartEvent (com.sequenceiq.datalake.flow.repair.event.SdxRepairStartEvent)1 AbstractSdxAction (com.sequenceiq.datalake.service.AbstractSdxAction)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