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);
}
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);
}
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));
}
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));
}
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);
}
}
Aggregations