Search in sources :

Example 46 with Stack

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

the class StackStopRestartAction method restart.

@Override
public void restart(String flowId, String flowChainId, String event, Object payload) {
    Payload stackPayload = (Payload) payload;
    Stack stack = stackService.getByIdWithLists(stackPayload.getStackId());
    stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.STOP_REQUESTED, stack.getStatusReason());
    super.restart(flowId, flowChainId, event, payload);
}
Also used : Payload(com.sequenceiq.cloudbreak.cloud.event.Payload) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 47 with Stack

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

the class StackScalingServiceTest method shouldRemoveHostMetadataUsingId.

@Test
public void shouldRemoveHostMetadataUsingId() {
    Stack stack = mock(Stack.class);
    when(stack.getId()).thenReturn(123L);
    InstanceMetaData instanceMetaData = mock(InstanceMetaData.class);
    when(instanceMetaData.getInstanceId()).thenReturn("i-1234567");
    HostMetadata hostMetadata = mock(HostMetadata.class);
    when(hostMetadata.getId()).thenReturn(456L);
    stackScalingService.removeHostmetadataIfExists(stack, instanceMetaData, hostMetadata);
    verify(hostMetadataRepository).delete(456L);
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) Stack(com.sequenceiq.cloudbreak.domain.Stack) HostMetadata(com.sequenceiq.cloudbreak.domain.HostMetadata) Test(org.junit.Test)

Example 48 with Stack

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

the class UnhealthyInstancesFinalizerTest method shouldFinalizeInstancesThatAreNotFound.

@Test
public void shouldFinalizeInstancesThatAreNotFound() {
    Stack stack = TestUtil.stack(Status.AVAILABLE, TestUtil.awsCredential());
    CloudCredential cloudCredential = mock(CloudCredential.class);
    when(credentialConverter.convert(stack.getCredential())).thenReturn(cloudCredential);
    String instanceId1 = "i-0f1e0605506aaaaaa";
    String instanceId2 = "i-0f1e0605506bbbbbb";
    Set<InstanceMetaData> candidateUnhealthyInstances = new HashSet<>();
    setupInstanceMetaData(instanceId1, candidateUnhealthyInstances);
    setupInstanceMetaData(instanceId2, candidateUnhealthyInstances);
    List<CloudInstance> cloudInstances = new ArrayList<>();
    CloudInstance cloudInstance1 = setupCloudInstance(instanceId1, cloudInstances);
    when(cloudInstanceConverter.convert(candidateUnhealthyInstances)).thenReturn(cloudInstances);
    List<CloudVmInstanceStatus> cloudVmInstanceStatusList = new ArrayList<>();
    setupCloudVmInstanceStatus(cloudInstance1, InstanceStatus.TERMINATED, cloudVmInstanceStatusList);
    when(instanceStateQuery.getCloudVmInstanceStatuses(eq(cloudCredential), any(CloudContext.class), eq(cloudInstances))).thenReturn(cloudVmInstanceStatusList);
    Set<String> unhealthyInstances = underTest.finalizeUnhealthyInstances(stack, candidateUnhealthyInstances);
    assertEquals(2, unhealthyInstances.size());
    assertTrue(unhealthyInstances.contains(instanceId1));
    assertTrue(unhealthyInstances.contains(instanceId2));
}
Also used : CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) CloudVmInstanceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmInstanceStatus) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) ArrayList(java.util.ArrayList) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) Stack(com.sequenceiq.cloudbreak.domain.Stack) InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 49 with Stack

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

the class UptimeNotifierTest method notificationSendingWhenEverythingWorkFine.

@Test
public void notificationSendingWhenEverythingWorkFine() {
    doNothing().when(notificationSender).send(any(Notification.class));
    List<Cluster> clusters = TestUtil.generateCluster(1);
    when(clusterRepository.findByStatuses(any())).thenReturn(Collections.singletonList(clusters.get(0)));
    Stack stack1 = TestUtil.stack();
    when(stackRepository.findStackForCluster(anyLong())).thenReturn(stack1);
    underTest.sendUptime();
    ArgumentCaptor<Notification> argument1 = ArgumentCaptor.forClass(Notification.class);
    verify(notificationSender).send(argument1.capture());
    Notification<CloudbreakEventsJson> notification = argument1.getValue();
    assertEquals(GCP, notification.getNotification().getCloud());
    assertEquals("null", notification.getNotification().getBlueprintName());
    assertEquals(null, notification.getNotification().getBlueprintId());
    verify(notificationSender, times(1)).send(any(Notification.class));
}
Also used : CloudbreakEventsJson(com.sequenceiq.cloudbreak.api.model.CloudbreakEventsJson) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) Notification(com.sequenceiq.cloudbreak.service.notification.Notification) Stack(com.sequenceiq.cloudbreak.domain.Stack) Test(org.junit.Test)

Example 50 with Stack

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

the class ClusterServiceRunner method updateSaltState.

public void updateSaltState(Long stackId) throws CloudbreakException {
    Stack stack = stackService.getByIdWithLists(stackId);
    Orchestrator orchestrator = stack.getOrchestrator();
    OrchestratorType orchestratorType = orchestratorTypeResolver.resolveType(orchestrator.getType());
    if (orchestratorType.containerOrchestrator()) {
        LOGGER.info("Container orchestrator is not supported for this action.");
    } else {
        Cluster cluster = clusterService.retrieveClusterByStackId(stack.getId());
        hostRunner.runAmbariServices(stack, cluster);
    }
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.Cluster) OrchestratorType(com.sequenceiq.cloudbreak.common.model.OrchestratorType) Orchestrator(com.sequenceiq.cloudbreak.domain.Orchestrator) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Aggregations

Stack (com.sequenceiq.cloudbreak.domain.Stack)207 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)74 Test (org.junit.Test)70 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)32 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)30 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)26 DetailedStackStatus (com.sequenceiq.cloudbreak.api.model.DetailedStackStatus)23 ArrayList (java.util.ArrayList)20 List (java.util.List)20 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)18 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)18 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)18 HashMap (java.util.HashMap)18 HashSet (java.util.HashSet)18 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)17 Map (java.util.Map)17 Matchers.anyString (org.mockito.Matchers.anyString)16 HostMetadata (com.sequenceiq.cloudbreak.domain.HostMetadata)15 Set (java.util.Set)15 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)14