Search in sources :

Example 21 with InstanceGroup

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

the class TestUtil method generateGcpInstanceGroupsByNodeCount.

public static Set<InstanceGroup> generateGcpInstanceGroupsByNodeCount(int... count) {
    Set<InstanceGroup> instanceGroups = new HashSet<>();
    instanceGroups.add(instanceGroup(0L, InstanceGroupType.GATEWAY, gcpTemplate(1L), count[0]));
    for (int i = 1; i < count.length; i++) {
        instanceGroups.add(instanceGroup((long) i, InstanceGroupType.CORE, gcpTemplate(1L), count[i]));
    }
    return instanceGroups;
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Constraint(com.sequenceiq.cloudbreak.domain.Constraint) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) HashSet(java.util.HashSet)

Example 22 with InstanceGroup

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

the class TestUtil method instanceGroup.

public static InstanceGroup instanceGroup(Long id, String name, InstanceGroupType instanceGroupType, Template template, int nodeCount) {
    InstanceGroup instanceGroup = new InstanceGroup();
    instanceGroup.setId(id);
    instanceGroup.setNodeCount(nodeCount);
    instanceGroup.setGroupName(name);
    instanceGroup.setInstanceGroupType(instanceGroupType);
    instanceGroup.setTemplate(template);
    instanceGroup.setSecurityGroup(securityGroup(1L));
    instanceGroup.setInstanceMetaData(generateInstanceMetaDatas(nodeCount, id, instanceGroup));
    return instanceGroup;
}
Also used : InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

Example 23 with InstanceGroup

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

the class StackSyncService method updateMetaDataToRunning.

private void updateMetaDataToRunning(Long stackId, Cluster cluster, InstanceMetaData instanceMetaData) {
    InstanceGroup instanceGroup = instanceMetaData.getInstanceGroup();
    if (InstanceStatus.TERMINATED.equals(instanceMetaData.getInstanceStatus())) {
        instanceGroup.setNodeCount(instanceGroup.getNodeCount() + 1);
    }
    HostMetadata hostMetadata = hostMetadataRepository.findHostInClusterByName(cluster.getId(), instanceMetaData.getDiscoveryFQDN());
    if (hostMetadata != null) {
        LOGGER.info("Instance '{}' was found in the cluster metadata, setting it's state to REGISTERED.", instanceMetaData.getInstanceId());
        instanceMetaData.setInstanceStatus(InstanceStatus.REGISTERED);
    } else {
        LOGGER.info("Instance '{}' was not found in the cluster metadata, setting it's state to UNREGISTERED.", instanceMetaData.getInstanceId());
        instanceMetaData.setInstanceStatus(InstanceStatus.UNREGISTERED);
    }
    instanceMetaDataRepository.save(instanceMetaData);
    instanceGroupRepository.save(instanceGroup);
    eventService.fireCloudbreakEvent(stackId, AVAILABLE.name(), cloudbreakMessagesService.getMessage(Msg.STACK_SYNC_INSTANCE_UPDATED.code(), Arrays.asList(instanceMetaData.getDiscoveryFQDN(), "running")));
}
Also used : InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) HostMetadata(com.sequenceiq.cloudbreak.domain.HostMetadata)

Example 24 with InstanceGroup

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

the class StackCreationService method updateNodeCount.

private void updateNodeCount(Long stackId, Iterable<Group> originalGroups, Iterable<CloudResourceStatus> statuses) {
    for (Group group : originalGroups) {
        int nodeCount = group.getInstancesSize();
        List<CloudResourceStatus> failedResources = removeFailedMetadata(stackId, statuses, group);
        if (!failedResources.isEmpty()) {
            int failedCount = failedResources.size();
            InstanceGroup instanceGroup = instanceGroupRepository.findOneByGroupNameInStack(stackId, group.getName());
            instanceGroup.setNodeCount(nodeCount - failedCount);
            instanceGroupRepository.save(instanceGroup);
            flowMessageService.fireEventAndLog(stackId, Msg.STACK_INFRASTRUCTURE_ROLLBACK_MESSAGE, UPDATE_IN_PROGRESS.name(), failedCount, group.getName(), failedResources.get(0).getStatusReason());
        }
    }
}
Also used : InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) Group(com.sequenceiq.cloudbreak.cloud.model.Group) CloudResourceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

Example 25 with InstanceGroup

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

the class StackDownscaleService method finishStackDownscale.

public void finishStackDownscale(StackScalingFlowContext context, String instanceGroupName, Collection<String> instanceIds) {
    Stack stack = context.getStack();
    InstanceGroup g = stack.getInstanceGroupByInstanceGroupName(instanceGroupName);
    int nodeCount = stackScalingService.updateRemovedResourcesState(stack, instanceIds, g);
    List<String> fqdns = instanceMetaDataRepository.findAllByInstanceIdIn(instanceIds).stream().map(InstanceMetaData::getDiscoveryFQDN).collect(toList());
    stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.DOWNSCALE_COMPLETED, String.format("Downscale of the cluster infrastructure finished successfully. Terminated node(s): %s", fqdns));
    flowMessageService.fireEventAndLog(stack.getId(), Msg.STACK_DOWNSCALE_SUCCESS, AVAILABLE.name(), fqdns);
    if (stack.getCluster() != null && stack.getCluster().getEmailNeeded()) {
        emailSenderService.sendDownScaleSuccessEmail(stack.getCluster().getOwner(), stack.getCluster().getEmailTo(), stackUtil.extractAmbariIp(stack), stack.getCluster().getName());
        flowMessageService.fireEventAndLog(context.getStack().getId(), Msg.STACK_NOTIFICATION_EMAIL, AVAILABLE.name());
    }
    usageService.scaleUsagesForStack(stack.getId(), instanceGroupName, nodeCount);
}
Also used : Stack(com.sequenceiq.cloudbreak.domain.Stack) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

Aggregations

InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)89 Test (org.junit.Test)32 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)27 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)27 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)24 HashSet (java.util.HashSet)16 JsonNode (com.fasterxml.jackson.databind.JsonNode)15 Stack (com.sequenceiq.cloudbreak.domain.Stack)14 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)9 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)8 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)8 Constraint (com.sequenceiq.cloudbreak.domain.Constraint)8 Matchers.anyString (org.mockito.Matchers.anyString)8 Orchestrator (com.sequenceiq.cloudbreak.domain.Orchestrator)6 StackAuthentication (com.sequenceiq.cloudbreak.domain.StackAuthentication)6 Template (com.sequenceiq.cloudbreak.domain.Template)6 ArrayList (java.util.ArrayList)6 InstanceGroupRequest (com.sequenceiq.cloudbreak.api.model.InstanceGroupRequest)5 StackAuthenticationRequest (com.sequenceiq.cloudbreak.api.model.StackAuthenticationRequest)5 FailurePolicy (com.sequenceiq.cloudbreak.domain.FailurePolicy)5