Search in sources :

Example 41 with SdxContext

use of com.sequenceiq.datalake.flow.SdxContext in project cloudbreak by hortonworks.

the class DatalakeRestoreActions method datalakeFullResoreInProgress.

@Bean(name = "DATALAKE_FULL_RESTORE_IN_PROGRESS_STATE")
public Action<?, ?> datalakeFullResoreInProgress() {
    return new AbstractSdxAction<>(SdxEvent.class) {

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

        @Override
        protected void doExecute(SdxContext context, SdxEvent payload, Map<Object, Object> variables) {
            LOGGER.info("Full datalake restore is in progress for {} ", payload.getResourceId());
            String operationId = (String) variables.get(OPERATION_ID);
            String restoreId = (String) variables.get(RESTORE_ID);
            SdxCluster sdxCluster = sdxService.getById(payload.getResourceId());
            SdxDatabaseRestoreStatusResponse restoreStatusResponse = sdxBackupRestoreService.getDatabaseRestoreStatus(sdxCluster, operationId);
            if (restoreStatusResponse.getStatus().equals(DatalakeDatabaseDrStatus.INPROGRESS)) {
                sdxBackupRestoreService.updateDatabaseStatusEntry(operationId, SdxOperationStatus.SUCCEEDED, null);
            }
            sendEvent(context, DatalakeFullRestoreWaitRequest.from(context, restoreId));
        }

        @Override
        protected Object getFailurePayload(SdxEvent payload, Optional<SdxContext> flowContext, Exception ex) {
            return DatalakeRestoreFailedEvent.from(flowContext, payload, ex);
        }
    };
}
Also used : FlowParameters(com.sequenceiq.flow.core.FlowParameters) AbstractSdxAction(com.sequenceiq.datalake.service.AbstractSdxAction) Optional(java.util.Optional) StateContext(org.springframework.statemachine.StateContext) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) SdxEvent(com.sequenceiq.datalake.flow.SdxEvent) SdxDatabaseRestoreStatusResponse(com.sequenceiq.sdx.api.model.SdxDatabaseRestoreStatusResponse) Map(java.util.Map) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) SdxContext(com.sequenceiq.datalake.flow.SdxContext) Bean(org.springframework.context.annotation.Bean)

Example 42 with SdxContext

use of com.sequenceiq.datalake.flow.SdxContext in project cloudbreak by hortonworks.

the class DatalakeUpgradeActions method imageChangeWait.

@Bean(name = "DATALAKE_IMAGE_CHANGE_IN_PROGRESS_STATE")
public Action<?, ?> imageChangeWait() {
    return new AbstractSdxAction<>(DatalakeChangeImageWaitRequest.class) {

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

        @Override
        protected void doExecute(SdxContext context, DatalakeChangeImageWaitRequest payload, Map<Object, Object> variables) {
            LOGGER.info("Datalake upgrade image change is in progress for {} ", payload.getResourceId());
            sendEvent(context, new DatalakeChangeImageWaitRequest(context, payload.getUpgradeOption()));
        }

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

Example 43 with SdxContext

use of com.sequenceiq.datalake.flow.SdxContext in project cloudbreak by hortonworks.

the class DatalakeUpgradeActions method replaceVms.

@Bean(name = "DATALAKE_REPLACE_VMS_STATE")
public Action<?, ?> replaceVms() {
    return new AbstractSdxAction<>(DatalakeVmReplaceEvent.class) {

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

        @Override
        protected void doExecute(SdxContext context, DatalakeVmReplaceEvent payload, Map<Object, Object> variables) {
            if ((boolean) variables.get(REPLACE_VMS_AFTER_UPGRADE)) {
                LOGGER.info("Start Datalake upgrade vm replacement for {} ", payload.getResourceId());
                sdxUpgradeService.upgradeOs(payload.getResourceId());
                sendEvent(context, new SdxEvent(DATALAKE_VM_REPLACE_IN_PROGRESS_EVENT.event(), context));
            } else {
                LOGGER.info("Vm replacement is not required for {} ", payload.getResourceId());
                sendEvent(context, DATALAKE_UPGRADE_SUCCESS_EVENT.event(), new DatalakeUpgradeSuccessEvent(payload.getResourceId(), payload.getUserId()));
            }
        }

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

Example 44 with SdxContext

use of com.sequenceiq.datalake.flow.SdxContext in project cloudbreak by hortonworks.

the class DatalakeUpgradeActions method replaceVmsWait.

@Bean(name = "DATALAKE_REPLACE_VMS_IN_PROGRESS_STATE")
public Action<?, ?> replaceVmsWait() {
    return new AbstractSdxAction<>(SdxEvent.class) {

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

        @Override
        protected void doExecute(SdxContext context, SdxEvent payload, Map<Object, Object> variables) {
            LOGGER.info("Datalake upgrade vm replacement is in progress for {} ", payload.getResourceId());
            sendEvent(context, new DatalakeVmReplaceWaitRequest(context));
        }

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

Example 45 with SdxContext

use of com.sequenceiq.datalake.flow.SdxContext in project cloudbreak by hortonworks.

the class DatahubRefreshActions method datahubRefreshInProgressAction.

@Bean(name = "DATAHUB_REFRESH_IN_PROGRESS_STATE")
public Action<?, ?> datahubRefreshInProgressAction() {
    return new AbstractSdxAction<>(DatahubRefreshStartEvent.class) {

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

        @Override
        protected void doExecute(SdxContext context, DatahubRefreshStartEvent payload, Map<Object, Object> variables) throws Exception {
            LOGGER.info("Datahub refresh in progress for: {}", payload.getResourceId());
            sendEvent(context, new DatahubRefreshWaitEvent(payload.getResourceId(), payload.getUserId()));
        }

        @Override
        protected Object getFailurePayload(DatahubRefreshStartEvent payload, Optional<SdxContext> flowContext, Exception ex) {
            return new DatahubRefreshFailedEvent(payload.getResourceId(), payload.getUserId(), ex);
        }
    };
}
Also used : FlowParameters(com.sequenceiq.flow.core.FlowParameters) DatahubRefreshWaitEvent(com.sequenceiq.datalake.flow.refresh.event.DatahubRefreshWaitEvent) AbstractSdxAction(com.sequenceiq.datalake.service.AbstractSdxAction) Optional(java.util.Optional) DatahubRefreshFailedEvent(com.sequenceiq.datalake.flow.refresh.event.DatahubRefreshFailedEvent) StateContext(org.springframework.statemachine.StateContext) Map(java.util.Map) DatahubRefreshStartEvent(com.sequenceiq.datalake.flow.refresh.event.DatahubRefreshStartEvent) SdxContext(com.sequenceiq.datalake.flow.SdxContext) Bean(org.springframework.context.annotation.Bean)

Aggregations

SdxContext (com.sequenceiq.datalake.flow.SdxContext)61 Map (java.util.Map)57 Bean (org.springframework.context.annotation.Bean)57 FlowParameters (com.sequenceiq.flow.core.FlowParameters)56 Optional (java.util.Optional)53 AbstractSdxAction (com.sequenceiq.datalake.service.AbstractSdxAction)52 StateContext (org.springframework.statemachine.StateContext)52 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)32 SdxEvent (com.sequenceiq.datalake.flow.SdxEvent)18 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)8 Flow (com.sequenceiq.flow.core.Flow)8 PollerStoppedException (com.dyngr.exception.PollerStoppedException)7 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)7 DatalakeStatusUpdateException (com.sequenceiq.datalake.service.sdx.status.DatalakeStatusUpdateException)5 DatalakeStatusEnum (com.sequenceiq.datalake.entity.DatalakeStatusEnum)4 DatalakeTriggerRestoreEvent (com.sequenceiq.datalake.flow.dr.restore.event.DatalakeTriggerRestoreEvent)4 DatalakeRestoreStatusResponse (com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse)3 SdxCertRenewalFailedEvent (com.sequenceiq.datalake.flow.cert.renew.event.SdxCertRenewalFailedEvent)3 SdxCertRotationFailedEvent (com.sequenceiq.datalake.flow.cert.rotation.event.SdxCertRotationFailedEvent)3 SdxDetachFailedEvent (com.sequenceiq.datalake.flow.detach.event.SdxDetachFailedEvent)3