Search in sources :

Example 21 with InstanceGroup

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

the class InstanceMetaDataService method saveInstanceRequests.

public void saveInstanceRequests(Stack stack, List<Group> groups) {
    Set<InstanceGroup> instanceGroups = stack.getInstanceGroups();
    for (Group group : groups) {
        InstanceGroup instanceGroup = getInstanceGroup(instanceGroups, group.getName());
        List<InstanceMetaData> existingInGroup = repository.findAllByInstanceGroupAndInstanceStatus(instanceGroup, com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus.REQUESTED);
        for (CloudInstance cloudInstance : group.getInstances()) {
            InstanceTemplate instanceTemplate = cloudInstance.getTemplate();
            boolean exists = existingInGroup.stream().anyMatch(i -> i.getPrivateId().equals(instanceTemplate.getPrivateId()));
            if (com.sequenceiq.cloudbreak.cloud.model.InstanceStatus.CREATE_REQUESTED == instanceTemplate.getStatus() && !exists) {
                InstanceMetaData instanceMetaData = new InstanceMetaData();
                instanceMetaData.setPrivateId(instanceTemplate.getPrivateId());
                instanceMetaData.setInstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus.REQUESTED);
                instanceMetaData.setInstanceGroup(instanceGroup);
                instanceMetaData.setVariant(stack.getPlatformVariant());
                repository.save(instanceMetaData);
            }
        }
    }
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Group(com.sequenceiq.cloudbreak.cloud.model.Group) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)

Example 22 with InstanceGroup

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

the class StackCreatorService method fillInstanceMetadata.

@VisibleForTesting
void fillInstanceMetadata(DetailedEnvironmentResponse environment, Stack stack) {
    long privateIdNumber = 0;
    Map<String, String> subnetAzPairs = multiAzCalculatorService.prepareSubnetAzMap(environment);
    String stackSubnetId = getStackSubnetIdIfExists(stack);
    String stackAz = stackSubnetId == null ? null : subnetAzPairs.get(stackSubnetId);
    for (InstanceGroup instanceGroup : sortInstanceGroups(stack)) {
        for (InstanceMetaData instanceMetaData : instanceGroup.getAllInstanceMetaData()) {
            instanceMetaData.setPrivateId(privateIdNumber++);
            instanceMetaData.setInstanceStatus(InstanceStatus.REQUESTED);
        }
        multiAzCalculatorService.calculateByRoundRobin(subnetAzPairs, instanceGroup);
        prepareInstanceMetaDataSubnetAndAvailabilityZoneAndRackId(stackSubnetId, stackAz, instanceGroup);
    }
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 23 with InstanceGroup

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

the class InstanceMetaDataToCloudInstanceConverterTest method createSource.

@Override
public InstanceMetaData createSource() {
    InstanceGroup instanceGroup = TestUtil.instanceGroup(1L, InstanceGroupType.CORE, TestUtil.gcpTemplate(1L));
    Stack stack = TestUtil.stack();
    stack.setStackAuthentication(new StackAuthentication());
    instanceGroup.setStack(stack);
    return TestUtil.instanceMetaData(1L, 1L, InstanceStatus.SERVICES_RUNNING, false, instanceGroup);
}
Also used : StackAuthentication(com.sequenceiq.cloudbreak.domain.StackAuthentication) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 24 with InstanceGroup

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

the class StackValidatorTest method getInstanceGroup.

private InstanceGroup getInstanceGroup(Template template) {
    InstanceGroup instanceGroupRequest = new InstanceGroup();
    instanceGroupRequest.setGroupName("master");
    instanceGroupRequest.setTemplate(template);
    return instanceGroupRequest;
}
Also used : InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

Example 25 with InstanceGroup

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

the class InstanceGroupToInstanceGroupV4ResponseConverterTest method copyInstanceGroupType.

@ParameterizedTest
@EnumSource(InstanceGroupType.class)
@DisplayName("When conversion happens the original type of the InstanceGroup must be copied into the result InstanceGroupV4Response")
void copyInstanceGroupType(InstanceGroupType originalType) {
    InstanceGroup source = new InstanceGroup();
    source.setInstanceGroupType(originalType);
    InstanceGroupV4Response result = underTest.convert(source);
    Assertions.assertEquals(originalType, result.getType());
}
Also used : InstanceGroupV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.InstanceGroupV4Response) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)288 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)132 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)93 Test (org.junit.jupiter.api.Test)91 HashSet (java.util.HashSet)68 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)57 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)47 Template (com.sequenceiq.cloudbreak.domain.Template)45 Test (org.junit.Test)44 Json (com.sequenceiq.cloudbreak.common.json.Json)38 Set (java.util.Set)37 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)34 ArrayList (java.util.ArrayList)31 LinkedHashSet (java.util.LinkedHashSet)31 Map (java.util.Map)28 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)27 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)27 List (java.util.List)26 HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)25 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)22