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