Search in sources :

Example 1 with DatalakeDatabaseBackupCouldNotStartEvent

use of com.sequenceiq.datalake.flow.dr.backup.event.DatalakeDatabaseBackupCouldNotStartEvent in project cloudbreak by hortonworks.

the class DatalakeBackupActions method backupCouldNotStart.

@Bean(name = "DATALAKE_DATABASE_BACKUP_COULD_NOT_START_STATE")
public Action<?, ?> backupCouldNotStart() {
    return new AbstractSdxAction<>(DatalakeDatabaseBackupCouldNotStartEvent.class) {

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

        @Override
        protected void doExecute(SdxContext context, DatalakeDatabaseBackupCouldNotStartEvent payload, Map<Object, Object> variables) {
            Exception exception = payload.getException();
            LOGGER.error("Datalake database backup could not be started for datalake with id: {}", payload.getResourceId(), exception);
            String operationId = (String) variables.get(OPERATION_ID);
            sdxBackupRestoreService.updateDatabaseStatusEntry(operationId, SdxOperationStatus.FAILED, payload.getException().getMessage());
            SdxCluster sdxCluster = sdxService.getById(payload.getResourceId());
            eventSenderService.sendEventAndNotification(sdxCluster, context.getFlowTriggerUserCrn(), ResourceEvent.DATALAKE_DATABASE_BACKUP_FAILED);
            sendEvent(context, DATALAKE_DATABASE_BACKUP_FAILURE_HANDLED_EVENT.event(), payload);
        }

        @Override
        protected Object getFailurePayload(DatalakeDatabaseBackupCouldNotStartEvent payload, Optional<SdxContext> flowContext, Exception ex) {
            return DatalakeDatabaseBackupFailedEvent.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) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) DatalakeDatabaseBackupCouldNotStartEvent(com.sequenceiq.datalake.flow.dr.backup.event.DatalakeDatabaseBackupCouldNotStartEvent) Map(java.util.Map) PollerStoppedException(com.dyngr.exception.PollerStoppedException) SdxContext(com.sequenceiq.datalake.flow.SdxContext) Bean(org.springframework.context.annotation.Bean)

Aggregations

PollerStoppedException (com.dyngr.exception.PollerStoppedException)1 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)1 SdxContext (com.sequenceiq.datalake.flow.SdxContext)1 DatalakeDatabaseBackupCouldNotStartEvent (com.sequenceiq.datalake.flow.dr.backup.event.DatalakeDatabaseBackupCouldNotStartEvent)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