Search in sources :

Example 1 with SdxRepairStartEvent

use of com.sequenceiq.datalake.flow.repair.event.SdxRepairStartEvent 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 SdxRepairStartEvent

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

the class SdxReactorFlowManager method triggerSdxRepairFlow.

public FlowIdentifier triggerSdxRepairFlow(SdxCluster cluster, SdxRepairRequest repairRequest) {
    LOGGER.info("Trigger Datalake repair for: {} with settings: {}", cluster, repairRequest);
    SdxRepairSettings settings = SdxRepairSettings.from(repairRequest);
    String selector = SDX_REPAIR_EVENT.event();
    String userId = ThreadBasedUserCrnProvider.getUserCrn();
    return notify(selector, new SdxRepairStartEvent(selector, cluster.getId(), userId, settings), cluster.getClusterName());
}
Also used : SdxRepairStartEvent(com.sequenceiq.datalake.flow.repair.event.SdxRepairStartEvent) SdxRepairSettings(com.sequenceiq.datalake.settings.SdxRepairSettings)

Aggregations

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