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());
}
};
}
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()));
}
};
}
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);
}
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()));
}
};
}
Aggregations