Search in sources :

Example 1 with BackupRestoreContext

use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.dr.BackupRestoreContext in project cloudbreak by hortonworks.

the class DatabaseRestoreActions method databaseRestoreFailedAction.

@Bean(name = "DATABASE_RESTORE_FAILED_STATE")
public Action<?, ?> databaseRestoreFailedAction() {
    return new AbstractBackupRestoreActions<>(DatabaseRestoreFailedEvent.class) {

        @Override
        protected BackupRestoreContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, DatabaseRestoreFailedEvent payload) {
            Flow flow = getFlow(flowParameters.getFlowId());
            flow.setFlowFailed(payload.getException());
            return BackupRestoreContext.from(flowParameters, payload, null, null, true);
        }

        @Override
        protected void doExecute(BackupRestoreContext context, DatabaseRestoreFailedEvent payload, Map<Object, Object> variables) {
            backupRestoreStatusService.handleDatabaseRestoreFailure(context.getStackId(), payload.getException().getMessage(), payload.getDetailedStatus());
            sendEvent(context, DATABASE_RESTORE_FAIL_HANDLED_EVENT.event(), payload);
        }
    };
}
Also used : FlowParameters(com.sequenceiq.flow.core.FlowParameters) DatabaseRestoreFailedEvent(com.sequenceiq.cloudbreak.reactor.api.event.cluster.dr.restore.DatabaseRestoreFailedEvent) StateContext(org.springframework.statemachine.StateContext) AbstractBackupRestoreActions(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.dr.AbstractBackupRestoreActions) Map(java.util.Map) BackupRestoreContext(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.dr.BackupRestoreContext) Flow(com.sequenceiq.flow.core.Flow) Bean(org.springframework.context.annotation.Bean)

Example 2 with BackupRestoreContext

use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.dr.BackupRestoreContext in project cloudbreak by hortonworks.

the class DatabaseBackupActions method databaseBackupFailedAction.

@Bean(name = "DATABASE_BACKUP_FAILED_STATE")
public Action<?, ?> databaseBackupFailedAction() {
    return new AbstractBackupRestoreActions<>(DatabaseBackupFailedEvent.class) {

        @Override
        protected BackupRestoreContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, DatabaseBackupFailedEvent payload) {
            Flow flow = getFlow(flowParameters.getFlowId());
            flow.setFlowFailed(payload.getException());
            return BackupRestoreContext.from(flowParameters, payload, null, null, true);
        }

        @Override
        protected void doExecute(BackupRestoreContext context, DatabaseBackupFailedEvent payload, Map<Object, Object> variables) {
            backupRestoreStatusService.handleDatabaseBackupFailure(context.getStackId(), payload.getException().getMessage(), payload.getDetailedStatus());
            sendEvent(context, DATABASE_BACKUP_FAIL_HANDLED_EVENT.event(), payload);
        }
    };
}
Also used : FlowParameters(com.sequenceiq.flow.core.FlowParameters) StateContext(org.springframework.statemachine.StateContext) AbstractBackupRestoreActions(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.dr.AbstractBackupRestoreActions) DatabaseBackupFailedEvent(com.sequenceiq.cloudbreak.reactor.api.event.cluster.dr.backup.DatabaseBackupFailedEvent) Map(java.util.Map) BackupRestoreContext(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.dr.BackupRestoreContext) Flow(com.sequenceiq.flow.core.Flow) Bean(org.springframework.context.annotation.Bean)

Aggregations

AbstractBackupRestoreActions (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.dr.AbstractBackupRestoreActions)2 BackupRestoreContext (com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.dr.BackupRestoreContext)2 Flow (com.sequenceiq.flow.core.Flow)2 FlowParameters (com.sequenceiq.flow.core.FlowParameters)2 Map (java.util.Map)2 Bean (org.springframework.context.annotation.Bean)2 StateContext (org.springframework.statemachine.StateContext)2 DatabaseBackupFailedEvent (com.sequenceiq.cloudbreak.reactor.api.event.cluster.dr.backup.DatabaseBackupFailedEvent)1 DatabaseRestoreFailedEvent (com.sequenceiq.cloudbreak.reactor.api.event.cluster.dr.restore.DatabaseRestoreFailedEvent)1