Search in sources :

Example 1 with BackupContext

use of com.sequenceiq.freeipa.flow.freeipa.backup.full.BackupContext in project cloudbreak by hortonworks.

the class FullBackupActions method backupFailedAction.

@Bean(name = "BACKUP_FAILED_STATE")
public Action<?, ?> backupFailedAction() {
    return new AbstractBackupAction<>(StackFailureEvent.class) {

        @Inject
        private OperationService operationService;

        @Override
        protected void doExecute(BackupContext context, StackFailureEvent payload, Map<Object, Object> variables) {
            LOGGER.error("Full backup failed", payload.getException());
            failFlow(context, payload);
            if (isOperationIdSet(variables)) {
                LOGGER.debug("Fail operation with id: [{}]", getOperationId(variables));
                operationService.failOperation(context.getStack().getAccountId(), getOperationId(variables), payload.getException().getMessage());
            }
            sendEvent(context, new StackEvent(FULL_BACKUP_FAILURE_HANDLED_EVENT.event(), payload.getResourceId()));
        }

        private void failFlow(BackupContext context, StackFailureEvent payload) {
            Flow flow = getFlow(context.getFlowParameters().getFlowId());
            flow.setFlowFailed(payload.getException());
        }
    };
}
Also used : StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) StackFailureEvent(com.sequenceiq.freeipa.flow.stack.StackFailureEvent) BackupContext(com.sequenceiq.freeipa.flow.freeipa.backup.full.BackupContext) OperationService(com.sequenceiq.freeipa.service.operation.OperationService) Map(java.util.Map) Flow(com.sequenceiq.flow.core.Flow) Bean(org.springframework.context.annotation.Bean)

Example 2 with BackupContext

use of com.sequenceiq.freeipa.flow.freeipa.backup.full.BackupContext in project cloudbreak by hortonworks.

the class FullBackupActions method backupFinishedAction.

@Bean(name = "BACKUP_FINISHED_STATE")
public Action<?, ?> backupFinishedAction() {
    return new AbstractBackupAction<>(StackEvent.class) {

        @Inject
        private OperationService operationService;

        @Override
        protected void doExecute(BackupContext context, StackEvent payload, Map<Object, Object> variables) {
            LOGGER.info("Full backup flow finished");
            if (isOperationIdSet(variables) && (!isChainedAction(variables) || isFinalChain(variables))) {
                LOGGER.debug("Complete operation with id: [{}]", getOperationId(variables));
                Stack stack = context.getStack();
                SuccessDetails successDetails = new SuccessDetails(stack.getEnvironmentCrn());
                operationService.completeOperation(stack.getAccountId(), getOperationId(variables), Set.of(successDetails), Set.of());
            }
            sendEvent(context, new StackEvent(FULL_BACKUP_FINISHED_EVENT.event(), payload.getResourceId()));
        }
    };
}
Also used : SuccessDetails(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SuccessDetails) StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) BackupContext(com.sequenceiq.freeipa.flow.freeipa.backup.full.BackupContext) OperationService(com.sequenceiq.freeipa.service.operation.OperationService) Map(java.util.Map) Stack(com.sequenceiq.freeipa.entity.Stack) Bean(org.springframework.context.annotation.Bean)

Example 3 with BackupContext

use of com.sequenceiq.freeipa.flow.freeipa.backup.full.BackupContext in project cloudbreak by hortonworks.

the class AbstractBackupAction method createFlowContext.

@Override
protected BackupContext createFlowContext(FlowParameters flowParameters, StateContext<FullBackupState, FullBackupEvent> stateContext, P payload) {
    Stack stack = stackService.getStackById(payload.getResourceId());
    MDCBuilder.buildMdcContext(stack);
    return new BackupContext(flowParameters, stack);
}
Also used : BackupContext(com.sequenceiq.freeipa.flow.freeipa.backup.full.BackupContext) Stack(com.sequenceiq.freeipa.entity.Stack)

Example 4 with BackupContext

use of com.sequenceiq.freeipa.flow.freeipa.backup.full.BackupContext in project cloudbreak by hortonworks.

the class FullBackupActions method backupAction.

@Bean(name = "BACKUP_STATE")
public Action<?, ?> backupAction() {
    return new AbstractBackupAction<>(TriggerFullBackupEvent.class) {

        @Override
        protected void doExecute(BackupContext context, TriggerFullBackupEvent payload, Map<Object, Object> variables) {
            LOGGER.info("Full backup flow started with: {}", payload);
            setChainedAction(variables, payload.isChained());
            setFinalChain(variables, payload.isFinalChain());
            setOperationId(variables, payload.getOperationId());
            sendEvent(context, new CreateFullBackupEvent(payload.getResourceId()));
        }
    };
}
Also used : CreateFullBackupEvent(com.sequenceiq.freeipa.flow.freeipa.backup.full.event.CreateFullBackupEvent) TriggerFullBackupEvent(com.sequenceiq.freeipa.flow.freeipa.backup.full.event.TriggerFullBackupEvent) BackupContext(com.sequenceiq.freeipa.flow.freeipa.backup.full.BackupContext) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Aggregations

BackupContext (com.sequenceiq.freeipa.flow.freeipa.backup.full.BackupContext)4 Map (java.util.Map)3 Bean (org.springframework.context.annotation.Bean)3 Stack (com.sequenceiq.freeipa.entity.Stack)2 StackEvent (com.sequenceiq.freeipa.flow.stack.StackEvent)2 OperationService (com.sequenceiq.freeipa.service.operation.OperationService)2 Flow (com.sequenceiq.flow.core.Flow)1 SuccessDetails (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SuccessDetails)1 CreateFullBackupEvent (com.sequenceiq.freeipa.flow.freeipa.backup.full.event.CreateFullBackupEvent)1 TriggerFullBackupEvent (com.sequenceiq.freeipa.flow.freeipa.backup.full.event.TriggerFullBackupEvent)1 StackFailureEvent (com.sequenceiq.freeipa.flow.stack.StackFailureEvent)1