@Test public void testAllocationNotChangedIfOnlyDefaultAppInFlexTier() { List<AgentInstanceGroup> instanceGroups = singletonList( getInstanceGroup(Tier.Flex, R4_8XLARGE_ID, 0, 1) ); when(agentManagementService.getInstanceGroups()).thenReturn(instanceGroups); CapacityRequirements requirements = new CapacityRequirements(singletonMap(Tier.Flex, singletonList(ApplicationSlaSample.DefaultFlex.build()))); CapacityAllocations allocations = strategy.compute(requirements); assertThat(allocations.getInstanceGroups()).isEmpty(); }
@Override public CapacityAllocations compute(CapacityRequirements capacityRequirements) { Map<AgentInstanceGroup, Integer> instanceAllocations = new HashMap<>(); Map<Tier, ResourceDimension> resourceShortage = new HashMap<>(); for (Tier tier : capacityRequirements.getTiers()) { boolean hasEnoughApps = (tier == Tier.Flex && capacityRequirements.getTierRequirements(tier).size() > 1) || (tier != Tier.Flex && capacityRequirements.getTierRequirements(tier).size() > 0); if (hasEnoughApps) { Optional<ResourceDimension> left = allocate(tier, capacityRequirements, instanceAllocations); left.ifPresent(resourceDimension -> resourceShortage.put(tier, resourceDimension)); } } return new CapacityAllocations(instanceAllocations, resourceShortage); }
SimpleCapacityGuaranteeStrategy implements CapacityGuaranteeStrategy { @Override public CapacityAllocations compute(CapacityRequirements capacityRequirements) { Map<AgentInstanceGroup, Integer> instanceAllocations = new HashMap<>(); Map<Tier, ResourceDimension> resourceShortage = new HashMap<>(); for (Tier tier : capacityRequirements.getTiers()) { boolean hasEnoughApps = (tier == Tier.Flex && capacityRequirements.getTierRequirements(tier).size() > 1) || (tier != Tier.Flex && capacityRequirements.getTierRequirements(tier).size() > 0); if (hasEnoughApps) { Optional<ResourceDimension> left = allocate(tier, capacityRequirements, instanceAllocations); left.ifPresent(resourceDimension -> resourceShortage.put(tier, resourceDimension)); } } return new CapacityAllocations(instanceAllocations, resourceShortage); } }
SimpleCapacityGuaranteeStrategy implements CapacityGuaranteeStrategy { @Override public CapacityAllocations compute(CapacityRequirements capacityRequirements) { Map<AgentInstanceGroup, Integer> instanceAllocations = new HashMap<>(); Map<Tier, ResourceDimension> resourceShortage = new HashMap<>(); for (Tier tier : capacityRequirements.getTiers()) { boolean hasEnoughApps = (tier == Tier.Flex && capacityRequirements.getTierRequirements(tier).size() > 1) || (tier != Tier.Flex && capacityRequirements.getTierRequirements(tier).size() > 0); if (hasEnoughApps) { Optional<ResourceDimension> left = allocate(tier, capacityRequirements, instanceAllocations); left.ifPresent(resourceDimension -> resourceShortage.put(tier, resourceDimension)); } } return new CapacityAllocations(instanceAllocations, resourceShortage); } @Inject  SimpleCapacityGuaranteeStrategy(CapacityManagementConfiguration configuration,
                                           AgentManagementService agentManagementService,
                                           ServerInfoResolver serverInfoResolver); }
SimpleCapacityGuaranteeStrategy implements CapacityGuaranteeStrategy { @Override public CapacityAllocations compute(CapacityRequirements capacityRequirements) { Map<AgentInstanceGroup, Integer> instanceAllocations = new HashMap<>(); Map<Tier, ResourceDimension> resourceShortage = new HashMap<>(); for (Tier tier : capacityRequirements.getTiers()) { boolean hasEnoughApps = (tier == Tier.Flex && capacityRequirements.getTierRequirements(tier).size() > 1) || (tier != Tier.Flex && capacityRequirements.getTierRequirements(tier).size() > 0); if (hasEnoughApps) { Optional<ResourceDimension> left = allocate(tier, capacityRequirements, instanceAllocations); left.ifPresent(resourceDimension -> resourceShortage.put(tier, resourceDimension)); } } return new CapacityAllocations(instanceAllocations, resourceShortage); } @Inject  SimpleCapacityGuaranteeStrategy(CapacityManagementConfiguration configuration,
                                           AgentManagementService agentManagementService,
                                           ServerInfoResolver serverInfoResolver); @Override CapacityAllocations compute(CapacityRequirements capacityRequirements); }
SimpleCapacityGuaranteeStrategy implements CapacityGuaranteeStrategy { @Override public CapacityAllocations compute(CapacityRequirements capacityRequirements) { Map<AgentInstanceGroup, Integer> instanceAllocations = new HashMap<>(); Map<Tier, ResourceDimension> resourceShortage = new HashMap<>(); for (Tier tier : capacityRequirements.getTiers()) { boolean hasEnoughApps = (tier == Tier.Flex && capacityRequirements.getTierRequirements(tier).size() > 1) || (tier != Tier.Flex && capacityRequirements.getTierRequirements(tier).size() > 0); if (hasEnoughApps) { Optional<ResourceDimension> left = allocate(tier, capacityRequirements, instanceAllocations); left.ifPresent(resourceDimension -> resourceShortage.put(tier, resourceDimension)); } } return new CapacityAllocations(instanceAllocations, resourceShortage); } @Inject  SimpleCapacityGuaranteeStrategy(CapacityManagementConfiguration configuration,
                                           AgentManagementService agentManagementService,
                                           ServerInfoResolver serverInfoResolver); @Override CapacityAllocations compute(CapacityRequirements capacityRequirements);  }