use of com.sequenceiq.cloudbreak.reactor.api.event.stack.TerminationType in project cloudbreak by hortonworks.
the class StackTerminationFailureAction method doExecute.
@Override
protected void doExecute(StackFailureContext context, StackFailureEvent payload, Map<Object, Object> variables) {
TerminationType terminationType = (TerminationType) variables.getOrDefault(TERMINATION_TYPE, TerminationType.REGULAR);
boolean forced = terminationType.isForced();
boolean recovery = terminationType.isRecovery();
Exception payloadException = payload.getException();
StackView stackView = context.getStackView();
try {
if (recovery) {
recoveryTeardownService.handleRecoveryTeardownError(stackView, payloadException);
} else {
stackTerminationService.handleStackTerminationError(stackView, payloadException, forced);
}
} catch (Exception e) {
LOGGER.error("Exception occurred while Cloudbreak tried to handle stack {} termination.", terminationType.name(), e);
}
sendEvent(context);
}
use of com.sequenceiq.cloudbreak.reactor.api.event.stack.TerminationType in project cloudbreak by hortonworks.
the class AbstractStackTerminationAction method createFlowContext.
@Override
protected StackTerminationContext createFlowContext(FlowParameters flowParameters, StateContext<StackTerminationState, StackTerminationEvent> stateContext, P payload) {
Map<Object, Object> variables = stateContext.getExtendedState().getVariables();
TerminationType terminationType = (TerminationType) variables.getOrDefault(TERMINATION_TYPE, TerminationType.REGULAR);
Stack stack = stackService.getByIdWithListsInTransaction(payload.getResourceId());
stack.setResources(new HashSet<>(resourceService.getAllByStackId(payload.getResourceId())));
MDCBuilder.buildMdcContext(stack);
Location location = location(region(stack.getRegion()), availabilityZone(stack.getAvailabilityZone()));
CloudContext cloudContext = CloudContext.Builder.builder().withId(stack.getId()).withName(stack.getName()).withOriginalName(stack.getOriginalName()).withCrn(stack.getResourceCrn()).withPlatform(stack.getCloudPlatform()).withVariant(stack.getPlatformVariant()).withLocation(location).withWorkspaceId(stack.getWorkspace().getId()).withAccountId(Crn.safeFromString(stack.getResourceCrn()).getAccountId()).withTenantId(stack.getTenant().getId()).build();
CloudCredential cloudCredential = stackUtil.getCloudCredential(stack);
CloudStack cloudStack = cloudStackConverter.convert(stack);
List<CloudResource> resources = stack.getResources().stream().map(r -> cloudResourceConverter.convert(r)).collect(Collectors.toList());
return createStackTerminationContext(flowParameters, stack, cloudContext, cloudCredential, cloudStack, resources, terminationType);
}
Aggregations