use of com.sequenceiq.cloudbreak.domain.StackStatus in project cloudbreak by hortonworks.
the class AmbariClusterService method updateClusterStatusByStackId.
@Override
@Transactional(TxType.NEVER)
public Cluster updateClusterStatusByStackId(Long stackId, Status status, String statusReason) {
LOGGER.debug("Updating cluster status. stackId: {}, status: {}, statusReason: {}", stackId, status, statusReason);
StackStatus stackStatus = stackService.getCurrentStatusByStackId(stackId);
Cluster cluster = retrieveClusterByStackId(stackId);
if (cluster != null) {
cluster.setStatus(status);
cluster.setStatusReason(statusReason);
cluster = clusterRepository.save(cluster);
if (status.isRemovableStatus()) {
InMemoryStateStore.deleteCluster(cluster.getId());
if (stackStatus.getStatus().isRemovableStatus()) {
InMemoryStateStore.deleteStack(stackId);
}
} else {
InMemoryStateStore.putCluster(cluster.getId(), statusToPollGroupConverter.convert(status));
if (InMemoryStateStore.getStack(stackId) == null) {
InMemoryStateStore.putStack(stackId, statusToPollGroupConverter.convert(stackStatus.getStatus()));
}
}
}
return cluster;
}
use of com.sequenceiq.cloudbreak.domain.StackStatus in project cloudbreak by hortonworks.
the class TestUtil method stack.
public static Stack stack(Status stackStatus, Credential credential) {
Stack stack = new Stack();
stack.setStackStatus(new StackStatus(stack, stackStatus, "statusReason", DetailedStackStatus.UNKNOWN));
stack.setCredential(credential);
stack.setName("simplestack");
stack.setOwner("userid");
stack.setAccount("account");
stack.setId(1L);
stack.setInstanceGroups(generateGcpInstanceGroups(3));
stack.setRegion("region");
stack.setCreated(123L);
stack.setCloudPlatform(credential.cloudPlatform());
stack.setOrchestrator(orchestrator());
switch(credential.cloudPlatform()) {
case AWS:
stack.setInstanceGroups(generateAwsInstanceGroups(3));
break;
case GCP:
stack.setInstanceGroups(generateGcpInstanceGroups(3));
break;
case OPENSTACK:
stack.setInstanceGroups(generateOpenStackInstanceGroups(3));
break;
default:
break;
}
stack.setSecurityConfig(new SecurityConfig());
return stack;
}
use of com.sequenceiq.cloudbreak.domain.StackStatus in project cloudbreak by hortonworks.
the class StackRequestToStackConverter method convert.
@Override
public Stack convert(StackRequest source) {
Stack stack = new Stack();
stack.setName(source.getName());
stack.setDisplayName(source.getName());
stack.setRegion(getRegion(source));
setPlatform(source);
stack.setCloudPlatform(source.getCloudPlatform());
Map<String, String> sourceTags = source.getApplicationTags();
stack.setTags(getTags(mergeTags(sourceTags, source.getUserDefinedTags(), getDefaultTags(source))));
if (sourceTags != null && sourceTags.get("datalakeId") != null) {
stack.setDatalakeId(Long.valueOf(String.valueOf(sourceTags.get("datalakeId"))));
}
StackAuthentication stackAuthentication = conversionService.convert(source.getStackAuthentication(), StackAuthentication.class);
stack.setStackAuthentication(stackAuthentication);
validateStackAuthentication(source);
stack.setOwner(source.getOwner());
stack.setAvailabilityZone(source.getAvailabilityZone());
stack.setOnFailureActionAction(source.getOnFailureAction());
stack.setStackStatus(new StackStatus(stack, DetailedStackStatus.PROVISION_REQUESTED.getStatus(), "", DetailedStackStatus.PROVISION_REQUESTED));
stack.setFailurePolicy(getConversionService().convert(source.getFailurePolicy(), FailurePolicy.class));
stack.setCreated(Calendar.getInstance().getTimeInMillis());
stack.setPlatformVariant(source.getPlatformVariant());
stack.setOrchestrator(getConversionService().convert(source.getOrchestrator(), Orchestrator.class));
if (source.getCredential() != null) {
stack.setCredential(getConversionService().convert(source.getCredential(), Credential.class));
}
Set<InstanceGroup> instanceGroups = convertInstanceGroups(source, stack);
stack.setInstanceGroups(instanceGroups);
if (source.getNetwork() != null) {
stack.setNetwork(getConversionService().convert(source.getNetwork(), Network.class));
}
stack.setCustomDomain(source.getCustomDomain());
stack.setCustomHostname(source.getCustomHostname());
stack.setClusterNameAsSubdomain(source.isClusterNameAsSubdomain());
stack.setHostgroupNameAsHostname(source.isHostgroupNameAsHostname());
stack.setUuid(UUID.randomUUID().toString());
return stack;
}
use of com.sequenceiq.cloudbreak.domain.StackStatus 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.domain.StackStatus in project cloudbreak by hortonworks.
the class ServiceTestUtils method createStack.
public static Stack createStack(String owner, String account, Template template, Credential credential, Cluster cluster, Set<Resource> resources) {
Template template1 = createTemplate(AWS);
Template template2 = createTemplate(AWS);
Set<InstanceGroup> instanceGroups = new HashSet<>();
InstanceGroup instanceGroup1 = new InstanceGroup();
instanceGroup1.setNodeCount(2);
instanceGroup1.setGroupName("master");
instanceGroup1.setTemplate(template1);
instanceGroups.add(instanceGroup1);
InstanceGroup instanceGroup2 = new InstanceGroup();
instanceGroup2.setNodeCount(2);
instanceGroup2.setGroupName("slave_1");
instanceGroup2.setTemplate(template2);
instanceGroups.add(instanceGroup2);
Stack stack = new Stack();
stack.setCredential(credential);
stack.setRegion("EU_WEST_1");
stack.setOwner(owner);
stack.setAccount(account);
stack.setStackStatus(new StackStatus(stack, Status.REQUESTED, "", DetailedStackStatus.PROVISION_REQUESTED));
stack.setInstanceGroups(instanceGroups);
stack.setCluster(cluster);
stack.setPublicInAccount(true);
stack.setResources(resources);
return stack;
}
Aggregations