Search in sources :

Example 6 with StackStatus

use of com.sequenceiq.cloudbreak.domain.StackStatus 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());
}
Also used : DetailedStackStatus(com.sequenceiq.cloudbreak.api.model.DetailedStackStatus) StackStatus(com.sequenceiq.cloudbreak.domain.StackStatus) DetailedStackStatus(com.sequenceiq.cloudbreak.api.model.DetailedStackStatus) Matchers.anyString(org.mockito.Matchers.anyString) Stack(com.sequenceiq.cloudbreak.domain.Stack) Test(org.junit.Test)

Example 7 with StackStatus

use of com.sequenceiq.cloudbreak.domain.StackStatus in project cloudbreak by hortonworks.

the class DefaultStackHostServiceTypeTest method stack.

private Stack stack(Status stackStatus, Status clusterStatus) {
    Credential gcpCredential = new Credential();
    Stack stack = new Stack();
    stack.setName("simplestack");
    stack.setStackStatus(new StackStatus(stack, stackStatus, "", DetailedStackStatus.UNKNOWN));
    stack.setCredential(gcpCredential);
    stack.setId(1L);
    Cluster cluster = new Cluster();
    cluster.setStatus(clusterStatus);
    cluster.setId(1L);
    stack.setCluster(cluster);
    return stack;
}
Also used : Credential(com.sequenceiq.cloudbreak.domain.Credential) DetailedStackStatus(com.sequenceiq.cloudbreak.api.model.DetailedStackStatus) StackStatus(com.sequenceiq.cloudbreak.domain.StackStatus) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 8 with StackStatus

use of com.sequenceiq.cloudbreak.domain.StackStatus 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;
}
Also used : Status(com.sequenceiq.cloudbreak.api.model.Status) DetailedStackStatus(com.sequenceiq.cloudbreak.api.model.DetailedStackStatus) StackStatus(com.sequenceiq.cloudbreak.domain.StackStatus) DetailedStackStatus(com.sequenceiq.cloudbreak.api.model.DetailedStackStatus) StackStatus(com.sequenceiq.cloudbreak.domain.StackStatus) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Aggregations

StackStatus (com.sequenceiq.cloudbreak.domain.StackStatus)8 DetailedStackStatus (com.sequenceiq.cloudbreak.api.model.DetailedStackStatus)7 Stack (com.sequenceiq.cloudbreak.domain.Stack)7 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)2 Credential (com.sequenceiq.cloudbreak.domain.Credential)2 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)2 Test (org.junit.Test)2 Status (com.sequenceiq.cloudbreak.api.model.Status)1 FailurePolicy (com.sequenceiq.cloudbreak.domain.FailurePolicy)1 Network (com.sequenceiq.cloudbreak.domain.Network)1 Orchestrator (com.sequenceiq.cloudbreak.domain.Orchestrator)1 SecurityConfig (com.sequenceiq.cloudbreak.domain.SecurityConfig)1 StackAuthentication (com.sequenceiq.cloudbreak.domain.StackAuthentication)1 Template (com.sequenceiq.cloudbreak.domain.Template)1 HashSet (java.util.HashSet)1 Transactional (javax.transaction.Transactional)1 Matchers.anyString (org.mockito.Matchers.anyString)1