@Test public void testFillInstanceMetadataWhenManager() { Stack stack = new Stack(); InstanceGroup managerGroup = getARequestGroup("manager", 1, InstanceGroupType.GATEWAY); InstanceGroup gatewayGroup = getARequestGroup("gateway", 2, InstanceGroupType.CORE); InstanceGroup computeGroup = getARequestGroup("compute", 0, InstanceGroupType.CORE); InstanceGroup workerGroup = getARequestGroup("worker", 3, InstanceGroupType.CORE); InstanceGroup masterGroup = getARequestGroup("master", 2, InstanceGroupType.CORE); stack.setInstanceGroups(Set.of(masterGroup, workerGroup, computeGroup, managerGroup, gatewayGroup)); underTest.fillInstanceMetadata(stack); Map<String, Set<InstanceMetaData>> hostGroupInstances = stack.getInstanceGroups().stream().collect( Collectors.toMap(InstanceGroup::getGroupName, instanceGroup -> instanceGroup.getAllInstanceMetaData())); Long privateIdStart = 0L; validateInstanceMetadataPrivateId("manager", 1, privateIdStart, hostGroupInstances.get("manager")); privateIdStart = 1L; validateInstanceMetadataPrivateId("compute", 0, privateIdStart, hostGroupInstances.get("compute")); privateIdStart = 1L; validateInstanceMetadataPrivateId("gateway", 2, privateIdStart, hostGroupInstances.get("gateway")); privateIdStart = 3L; validateInstanceMetadataPrivateId("master", 2, privateIdStart, hostGroupInstances.get("master")); privateIdStart = 5L; validateInstanceMetadataPrivateId("worker", 3, privateIdStart, hostGroupInstances.get("worker")); }
void fillInstanceMetadata(Stack stack) { long privateIdNumber = 0; List<InstanceGroup> sortedInstanceGroups = stack.getInstanceGroups().stream() .sorted(Comparator.comparing(InstanceGroup::getInstanceGroupType) .thenComparing(InstanceGroup::getGroupName)).collect(Collectors.toList()); for (InstanceGroup instanceGroup : sortedInstanceGroups) { for (InstanceMetaData instanceMetaData : instanceGroup.getAllInstanceMetaData()) { instanceMetaData.setPrivateId(privateIdNumber++); instanceMetaData.setInstanceStatus(InstanceStatus.REQUESTED); } } }
StackCreatorService { void fillInstanceMetadata(Stack stack) { long privateIdNumber = 0; List<InstanceGroup> sortedInstanceGroups = stack.getInstanceGroups().stream() .sorted(Comparator.comparing(InstanceGroup::getInstanceGroupType) .thenComparing(InstanceGroup::getGroupName)).collect(Collectors.toList()); for (InstanceGroup instanceGroup : sortedInstanceGroups) { for (InstanceMetaData instanceMetaData : instanceGroup.getAllInstanceMetaData()) { instanceMetaData.setPrivateId(privateIdNumber++); instanceMetaData.setInstanceStatus(InstanceStatus.REQUESTED); } } } }
StackCreatorService { void fillInstanceMetadata(Stack stack) { long privateIdNumber = 0; List<InstanceGroup> sortedInstanceGroups = stack.getInstanceGroups().stream() .sorted(Comparator.comparing(InstanceGroup::getInstanceGroupType) .thenComparing(InstanceGroup::getGroupName)).collect(Collectors.toList()); for (InstanceGroup instanceGroup : sortedInstanceGroups) { for (InstanceMetaData instanceMetaData : instanceGroup.getAllInstanceMetaData()) { instanceMetaData.setPrivateId(privateIdNumber++); instanceMetaData.setInstanceStatus(InstanceStatus.REQUESTED); } } }  }
StackCreatorService { void fillInstanceMetadata(Stack stack) { long privateIdNumber = 0; List<InstanceGroup> sortedInstanceGroups = stack.getInstanceGroups().stream() .sorted(Comparator.comparing(InstanceGroup::getInstanceGroupType) .thenComparing(InstanceGroup::getGroupName)).collect(Collectors.toList()); for (InstanceGroup instanceGroup : sortedInstanceGroups) { for (InstanceMetaData instanceMetaData : instanceGroup.getAllInstanceMetaData()) { instanceMetaData.setPrivateId(privateIdNumber++); instanceMetaData.setInstanceStatus(InstanceStatus.REQUESTED); } } }  StackV4Response createStack(User user, Workspace workspace, StackV4Request stackRequest, boolean distroxRequest); }
StackCreatorService { void fillInstanceMetadata(Stack stack) { long privateIdNumber = 0; List<InstanceGroup> sortedInstanceGroups = stack.getInstanceGroups().stream() .sorted(Comparator.comparing(InstanceGroup::getInstanceGroupType) .thenComparing(InstanceGroup::getGroupName)).collect(Collectors.toList()); for (InstanceGroup instanceGroup : sortedInstanceGroups) { for (InstanceMetaData instanceMetaData : instanceGroup.getAllInstanceMetaData()) { instanceMetaData.setPrivateId(privateIdNumber++); instanceMetaData.setInstanceStatus(InstanceStatus.REQUESTED); } } }  StackV4Response createStack(User user, Workspace workspace, StackV4Request stackRequest, boolean distroxRequest);  }