use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class StackUpdaterTest method updateStackStatusAndReason.
@Test
public void updateStackStatusAndReason() {
Stack stack = TestUtil.stack(TestUtil.cluster());
DetailedStackStatus newStatus = DetailedStackStatus.DELETE_COMPLETED;
String newStatusReason = "test";
when(stackService.getByIdWithTransaction(anyLong())).thenReturn(stack);
when(stackService.save(any(Stack.class))).thenReturn(stack);
Stack newStack = underTest.updateStackStatus(1L, newStatus, newStatusReason);
assertEquals(newStatus.getStatus(), newStack.getStatus());
assertEquals(newStatusReason, newStack.getStatusReason());
verify(stackService, times(1)).save(eq(stack));
verify(clusterService, times(1)).save(eq(stack.getCluster()));
verify(usageLoggingUtil, times(1)).logClusterStatusChangeUsageEvent(eq(Status.AVAILABLE), eq(Status.DELETE_COMPLETED), eq(stack.getCluster()));
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class StackOperationServiceTest method testStop.
@ParameterizedTest(name = "{0}: With stackStatus={1}")
@MethodSource("stackStatusForStop")
public void testStop(String methodName, DetailedStackStatus stackStatus) {
Stack stack = new Stack();
stack.setId(9876L);
stack.setStackStatus(new StackStatus(stack, stackStatus));
Cluster cluster = new Cluster();
cluster.setId(1L);
stack.setCluster(cluster);
when(stackStopRestrictionService.isInfrastructureStoppable(any())).thenReturn(StopRestrictionReason.NONE);
// On demand instances
when(spotInstanceUsageCondition.isStackRunsOnSpotInstances(stack)).thenReturn(false);
when(stackService.getByIdWithLists(stack.getId())).thenReturn(stack);
when(clusterService.findOneWithLists(cluster.getId())).thenReturn(Optional.of(cluster));
underTest.updateStatus(stack.getId(), StatusRequest.STOPPED, true);
if (stackStatus == STOP_FAILED) {
verify(flowManager).triggerStackStop(stack.getId());
} else {
verify(clusterOperationService).updateStatus(stack.getId(), StatusRequest.STOPPED);
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class ClusterStatusUpdaterTest method createStack.
private Stack createStack(DetailedStackStatus detailedStackStatus) {
Stack stack = new Stack();
stack.setId(TEST_STACK_ID);
stack.setStackStatus(new StackStatus(stack, detailedStackStatus.getStatus(), "", detailedStackStatus));
return stack;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class ClusterDownscaleService method handleClusterDownscaleFailure.
public void handleClusterDownscaleFailure(long stackId, Exception error) {
String errorDetails = error.getMessage();
LOGGER.warn("Error during Cluster downscale flow: ", error);
DetailedStackStatus detailedStackStatus = DetailedStackStatus.DOWNSCALE_FAILED;
if (error instanceof NotEnoughNodeException || error instanceof NodeIsBusyException) {
detailedStackStatus = DetailedStackStatus.AVAILABLE;
}
stackUpdater.updateStackStatus(stackId, detailedStackStatus, "Node(s) could not be removed from the cluster: " + errorDetails);
flowMessageService.fireEventAndLog(stackId, UPDATE_FAILED.name(), CLUSTER_SCALING_FAILED, "removed from", errorDetails);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus in project cloudbreak by hortonworks.
the class BlueprintServiceTest method patchWithStackStatus.
private void patchWithStackStatus(Cluster cluster1, DetailedStackStatus detailedStackStatus) {
Stack stack = new Stack();
stack.setStackStatus(new StackStatus(stack, detailedStackStatus));
stack.setType(StackType.WORKLOAD);
stack.setName(cluster1.getName());
stack.setId(cluster1.getId());
cluster1.setStack(stack);
}
Aggregations