use of com.sequenceiq.cloudbreak.core.flow2.stack.Msg in project cloudbreak by hortonworks.
the class StackTerminationService method handleStackTerminationError.
public void handleStackTerminationError(StackView stackView, StackFailureEvent payload, boolean forced, Boolean deleteDependencies) {
String stackUpdateMessage;
Msg eventMessage;
DetailedStackStatus status;
if (!forced) {
Exception errorDetails = payload.getException();
stackUpdateMessage = "Termination failed: " + errorDetails.getMessage();
status = DetailedStackStatus.DELETE_FAILED;
eventMessage = Msg.STACK_INFRASTRUCTURE_DELETE_FAILED;
stackUpdater.updateStackStatus(stackView.getId(), status, stackUpdateMessage);
LOGGER.error("Error during stack termination flow: ", errorDetails);
} else {
terminationService.finalizeTermination(stackView.getId(), true);
clusterService.updateClusterStatusByStackId(stackView.getId(), DELETE_COMPLETED);
stackUpdateMessage = "Stack was force terminated.";
status = DetailedStackStatus.DELETE_COMPLETED;
eventMessage = Msg.STACK_FORCED_DELETE_COMPLETED;
if (deleteDependencies) {
dependecyDeletionService.deleteDependencies(stackView);
}
}
flowMessageService.fireEventAndLog(stackView.getId(), eventMessage, status.name(), stackUpdateMessage);
if (stackView.getClusterView() != null && stackView.getClusterView().getEmailNeeded()) {
String ambariIp = stackUtil.extractAmbariIp(stackView);
if (forced) {
emailSenderService.sendTerminationSuccessEmail(stackView.getClusterView().getOwner(), stackView.getClusterView().getEmailTo(), ambariIp, stackView.getClusterView().getName());
} else {
emailSenderService.sendTerminationFailureEmail(stackView.getClusterView().getOwner(), stackView.getClusterView().getEmailTo(), ambariIp, stackView.getClusterView().getName());
}
flowMessageService.fireEventAndLog(stackView.getId(), Msg.STACK_NOTIFICATION_EMAIL, status.name());
}
}
Aggregations