use of com.sequenceiq.cloudbreak.api.model.DetailedStackStatus in project cloudbreak by hortonworks.
the class StackUpdaterTest method updateStackStatusWithoutStatusReasonThenNoNotificationSentOnWebsocket.
@Test
public void updateStackStatusWithoutStatusReasonThenNoNotificationSentOnWebsocket() {
Stack stack = TestUtil.stack();
DetailedStackStatus newStatus = DetailedStackStatus.DELETE_COMPLETED;
StackStatus testStackStatus = new StackStatus(stack, newStatus.getStatus(), "", newStatus);
when(stackStatusRepository.save(any(StackStatus.class))).thenReturn(testStackStatus);
when(stackRepository.findOne(anyLong())).thenReturn(stack);
when(stackRepository.save(any(Stack.class))).thenReturn(stack);
doNothing().when(cloudbreakEventService).fireCloudbreakEvent(anyLong(), anyString(), anyString());
when(statusToPollGroupConverter.convert(newStatus.getStatus())).thenReturn(PollGroup.POLLABLE);
Stack newStack = underTest.updateStackStatus(1L, DetailedStackStatus.DELETE_COMPLETED);
assertEquals(newStatus.getStatus(), newStack.getStatus());
assertEquals("", newStack.getStatusReason());
verify(cloudbreakEventService, times(0)).fireCloudbreakEvent(anyLong(), anyString(), anyString());
}
use of com.sequenceiq.cloudbreak.api.model.DetailedStackStatus 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());
}
}
use of com.sequenceiq.cloudbreak.api.model.DetailedStackStatus in project cloudbreak by hortonworks.
the class StackStartStopService method handleError.
private void handleError(StackView stackView, Exception exception, DetailedStackStatus detailedStackStatus, Msg msg, String logMessage) {
LOGGER.error(logMessage, exception);
Status stackStatus = detailedStackStatus.getStatus();
stackUpdater.updateStackStatus(stackView.getId(), detailedStackStatus, logMessage + exception.getMessage());
flowMessageService.fireEventAndLog(stackView.getId(), msg, stackStatus.name(), exception.getMessage());
if (stackView.getClusterView() != null) {
clusterService.updateClusterStatusByStackId(stackView.getId(), STOPPED);
if (stackView.getClusterView().getEmailNeeded()) {
emailSenderService.sendStopFailureEmail(stackView.getClusterView().getOwner(), stackView.getClusterView().getEmailTo(), stackUtil.extractAmbariIp(stackView), stackView.getClusterView().getName());
flowMessageService.fireEventAndLog(stackView.getId(), Msg.STACK_NOTIFICATION_EMAIL, stackStatus.name());
}
}
}
use of com.sequenceiq.cloudbreak.api.model.DetailedStackStatus in project cloudbreak by hortonworks.
the class StackUpdaterTest method updateStackStatusAndReasonThenNotificationSentOnWebsocket.
@Test
public void updateStackStatusAndReasonThenNotificationSentOnWebsocket() {
Stack stack = TestUtil.stack();
DetailedStackStatus newStatus = DetailedStackStatus.DELETE_COMPLETED;
String newStatusReason = "test";
StackStatus testStackStatus = new StackStatus(stack, newStatus.getStatus(), newStatusReason, newStatus);
when(stackStatusRepository.save(any(StackStatus.class))).thenReturn(testStackStatus);
when(stackRepository.findOne(anyLong())).thenReturn(stack);
when(stackRepository.save(any(Stack.class))).thenReturn(stack);
doNothing().when(cloudbreakEventService).fireCloudbreakEvent(anyLong(), anyString(), anyString());
when(statusToPollGroupConverter.convert(newStatus.getStatus())).thenReturn(PollGroup.POLLABLE);
Stack newStack = underTest.updateStackStatus(1L, newStatus, newStatusReason);
assertEquals(newStatus.getStatus(), newStack.getStatus());
assertEquals(newStatusReason, newStack.getStatusReason());
}
use of com.sequenceiq.cloudbreak.api.model.DetailedStackStatus in project cloudbreak by hortonworks.
the class StackUpdater method doUpdateStackStatus.
private Stack doUpdateStackStatus(Long stackId, DetailedStackStatus detailedStatus, String statusReason) {
Stack stack = stackRepository.findOne(stackId);
Status status = detailedStatus.getStatus();
if (!stack.isDeleteCompleted()) {
stack.setStackStatus(new StackStatus(stack, status, statusReason, detailedStatus));
if (status.isRemovableStatus()) {
InMemoryStateStore.deleteStack(stackId);
if (stack.getCluster() != null && stack.getCluster().getStatus().isRemovableStatus()) {
InMemoryStateStore.deleteCluster(stack.getCluster().getId());
}
} else {
InMemoryStateStore.putStack(stackId, statusToPollGroupConverter.convert(status));
}
stack = stackRepository.save(stack);
}
return stack;
}
Aggregations