test_class.declarator: ONE_POINT_ONE = new BigDecimal("1.1")
test_class.modifier: private static final
test_class.original_string: private static final BigDecimal ONE_POINT_ONE = new BigDecimal("1.1");
test_class.type: BigDecimal
test_class.var_name: ONE_POINT_ONE
test_class.declarator: ONE_POINT_ONE_ONE = new BigDecimal("1.11")
test_class.modifier: private static final
test_class.original_string: private static final BigDecimal ONE_POINT_ONE_ONE = new BigDecimal("1.11");
test_class.type: BigDecimal
test_class.var_name: ONE_POINT_ONE_ONE
test_class.declarator: ONE_UNIT = new BigDecimal("0.00001")
test_class.modifier: private static final
test_class.original_string: private static final BigDecimal ONE_UNIT = new BigDecimal("0.00001");
test_class.type: BigDecimal
test_class.var_name: ONE_UNIT
test_class.declarator: FIVE_UNIT = new BigDecimal("0.00005")
test_class.modifier: private static final
test_class.original_string: private static final BigDecimal FIVE_UNIT = new BigDecimal("0.00005");
test_class.type: BigDecimal
test_class.var_name: FIVE_UNIT
test_class.declarator: TEN_PERCENT = new BigDecimal("0.1")
test_class.modifier: private static final
test_class.original_string: private static final BigDecimal TEN_PERCENT = new BigDecimal("0.1");
test_class.type: BigDecimal
test_class.var_name: TEN_PERCENT
test_class.declarator: ON_DEMAND = new BigDecimal("1.00")
test_class.modifier: private static final
test_class.original_string: private static final BigDecimal ON_DEMAND = new BigDecimal("1.00");
test_class.type: BigDecimal
test_class.var_name: ON_DEMAND
test_class.declarator: ON_DEMAND_LESS_ONE = ON_DEMAND.subtract(ONE_UNIT)
test_class.modifier: private static final
test_class.original_string: private static final BigDecimal ON_DEMAND_LESS_ONE = ON_DEMAND.subtract(ONE_UNIT);
test_class.type: BigDecimal
test_class.var_name: ON_DEMAND_LESS_ONE
test_class.declarator: SPOT_PRICE_LOW = new BigDecimal(MockEc2OperationsImpl.SPOT_PRICE_LOW)
test_class.modifier: private static final
test_class.original_string: private static final BigDecimal SPOT_PRICE_LOW = new BigDecimal(MockEc2OperationsImpl.SPOT_PRICE_LOW);
test_class.type: BigDecimal
test_class.var_name: SPOT_PRICE_LOW
test_class.declarator: SPOT_PRICE_LOW_LESS_ONE = SPOT_PRICE_LOW.subtract(ONE_UNIT)
test_class.modifier: private static final
test_class.original_string: private static final BigDecimal SPOT_PRICE_LOW_LESS_ONE = SPOT_PRICE_LOW.subtract(ONE_UNIT);
test_class.type: BigDecimal
test_class.var_name: SPOT_PRICE_LOW_LESS_ONE
test_class.declarator: SPOT_PRICE_LOW_PLUS_ONE = SPOT_PRICE_LOW.add(ONE_UNIT)
test_class.modifier: private static final
test_class.original_string: private static final BigDecimal SPOT_PRICE_LOW_PLUS_ONE = SPOT_PRICE_LOW.add(ONE_UNIT);
test_class.type: BigDecimal
test_class.var_name: SPOT_PRICE_LOW_PLUS_ONE
test_class.declarator: SPOT_PRICE_VERY_HIGH = new BigDecimal(MockEc2OperationsImpl.SPOT_PRICE_VERY_HIGH)
test_class.modifier: private static final
test_class.original_string: private static final BigDecimal SPOT_PRICE_VERY_HIGH = new BigDecimal(MockEc2OperationsImpl.SPOT_PRICE_VERY_HIGH);
test_class.type: BigDecimal
test_class.var_name: SPOT_PRICE_VERY_HIGH
test_class.declarator: emrPricingHelper
test_class.modifier: @Autowired
      private
test_class.original_string: @Autowired
      private EmrPricingHelper emrPricingHelper;
test_class.type: EmrPricingHelper
test_class.var_name: emrPricingHelper
test_class.file: herd-code/herd-dao/src/test/java/org/finra/herd/dao/helper/EmrPricingHelperTest.java
test_class.identifier: EmrPricingHelperTest
test_class.superclass: extends AbstractDaoTest
test_case.body: @Test
      public void testBestPriceSubnetIsEmpty()
      {
          String subnetId = "";
  
          MasterInstanceDefinition masterInstanceDefinition = new MasterInstanceDefinition();
          masterInstanceDefinition.setInstanceCount(1);
          masterInstanceDefinition.setInstanceType(INSTANCE_TYPE_1);
  
          InstanceDefinition coreInstanceDefinition = new InstanceDefinition();
          coreInstanceDefinition.setInstanceCount(1);
          coreInstanceDefinition.setInstanceType(INSTANCE_TYPE_1);
  
          InstanceDefinition taskInstanceDefinition = null;
  
          EmrClusterDefinition emrClusterDefinition =
              updateEmrClusterDefinitionWithBestPrice(subnetId, masterInstanceDefinition, coreInstanceDefinition, taskInstanceDefinition);
  
          assertBestPriceCriteriaRemoved(emrClusterDefinition);
  
          assertTrue("subnet was not selected", StringUtils.isNotBlank(emrClusterDefinition.getSubnetId()));
      }
test_case.class_method_signature: EmrPricingHelperTest.testBestPriceSubnetIsEmpty()
test_case.full_signature: @Test public void testBestPriceSubnetIsEmpty()
test_case.identifier: testBestPriceSubnetIsEmpty
test_case.invocations: setInstanceCount setInstanceType setInstanceCount setInstanceType updateEmrClusterDefinitionWithBestPrice assertBestPriceCriteriaRemoved assertTrue isNotBlank getSubnetId
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testBestPriceSubnetIsEmpty()
focal_class.declarator: LOGGER = LoggerFactory.getLogger(EmrPricingHelper.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory.getLogger(EmrPricingHelper.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: ec2Dao
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private Ec2Dao ec2Dao;
focal_class.type: Ec2Dao
focal_class.var_name: ec2Dao
focal_class.declarator: emrVpcPricingStateFormatter
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private EmrVpcPricingStateFormatter emrVpcPricingStateFormatter;
focal_class.type: EmrVpcPricingStateFormatter
focal_class.var_name: emrVpcPricingStateFormatter
focal_class.declarator: herdStringHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private HerdStringHelper herdStringHelper;
focal_class.type: HerdStringHelper
focal_class.var_name: herdStringHelper
focal_class.declarator: jsonHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private JsonHelper jsonHelper;
focal_class.type: JsonHelper
focal_class.var_name: jsonHelper
focal_class.declarator: configurationHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private ConfigurationHelper configurationHelper;
focal_class.type: ConfigurationHelper
focal_class.var_name: configurationHelper
focal_class.file: herd-code/herd-dao/src/main/java/org/finra/herd/dao/helper/EmrPricingHelper.java
focal_class.identifier: EmrPricingHelper
focal_class.class_method_signature: EmrPricingHelper.updateEmrClusterDefinitionWithBestPrice(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition,
          AwsParamsDto awsParamsDto)
focal_class.full_signature: public void updateEmrClusterDefinitionWithBestPrice(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition,
          AwsParamsDto awsParamsDto)
focal_class.identifier: updateEmrClusterDefinitionWithBestPrice
focal_class.modifiers: public
focal_class.parameters: (EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition,
          AwsParamsDto awsParamsDto)
focal_class.return: void
focal_class.signature: void updateEmrClusterDefinitionWithBestPrice(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition,
          AwsParamsDto awsParamsDto)
focal_class.class_method_signature: EmrPricingHelper.getTotalInstanceCount(EmrClusterDefinition emrClusterDefinition)
focal_class.full_signature: private int getTotalInstanceCount(EmrClusterDefinition emrClusterDefinition)
focal_class.identifier: getTotalInstanceCount
focal_class.modifiers: private
focal_class.parameters: (EmrClusterDefinition emrClusterDefinition)
focal_class.return: int
focal_class.signature: int getTotalInstanceCount(EmrClusterDefinition emrClusterDefinition)
focal_class.class_method_signature: EmrPricingHelper.updateInstanceDefinitionsWithBestPrice(EmrClusterDefinition emrClusterDefinition, Subnet bestEmrClusterSubnet,
          EmrClusterPriceDto bestEmrClusterPrice)
focal_class.full_signature: private void updateInstanceDefinitionsWithBestPrice(EmrClusterDefinition emrClusterDefinition, Subnet bestEmrClusterSubnet,
          EmrClusterPriceDto bestEmrClusterPrice)
focal_class.identifier: updateInstanceDefinitionsWithBestPrice
focal_class.modifiers: private
focal_class.parameters: (EmrClusterDefinition emrClusterDefinition, Subnet bestEmrClusterSubnet,
          EmrClusterPriceDto bestEmrClusterPrice)
focal_class.return: void
focal_class.signature: void updateInstanceDefinitionsWithBestPrice(EmrClusterDefinition emrClusterDefinition, Subnet bestEmrClusterSubnet,
          EmrClusterPriceDto bestEmrClusterPrice)
focal_class.class_method_signature: EmrPricingHelper.getSpotBidPrice(Ec2PriceDto ec2Price)
focal_class.full_signature: private BigDecimal getSpotBidPrice(Ec2PriceDto ec2Price)
focal_class.identifier: getSpotBidPrice
focal_class.modifiers: private
focal_class.parameters: (Ec2PriceDto ec2Price)
focal_class.return: BigDecimal
focal_class.signature: BigDecimal getSpotBidPrice(Ec2PriceDto ec2Price)
focal_class.class_method_signature: EmrPricingHelper.getBestSubnetForAvailabilityZone(String availabilityZone, List<Subnet> subnets)
focal_class.full_signature: private Subnet getBestSubnetForAvailabilityZone(String availabilityZone, List<Subnet> subnets)
focal_class.identifier: getBestSubnetForAvailabilityZone
focal_class.modifiers: private
focal_class.parameters: (String availabilityZone, List<Subnet> subnets)
focal_class.return: Subnet
focal_class.signature: Subnet getBestSubnetForAvailabilityZone(String availabilityZone, List<Subnet> subnets)
focal_class.class_method_signature: EmrPricingHelper.getTop(List<T> list, Comparator<T> comparator)
focal_class.full_signature: private T getTop(List<T> list, Comparator<T> comparator)
focal_class.identifier: getTop
focal_class.modifiers: private
focal_class.parameters: (List<T> list, Comparator<T> comparator)
focal_class.return: T
focal_class.signature: T getTop(List<T> list, Comparator<T> comparator)
focal_class.class_method_signature: EmrPricingHelper.getEmrClusterPriceWithLowestCoreInstancePrice(final List<EmrClusterPriceDto> emrClusterPrices)
focal_class.full_signature:  EmrClusterPriceDto getEmrClusterPriceWithLowestCoreInstancePrice(final List<EmrClusterPriceDto> emrClusterPrices)
focal_class.identifier: getEmrClusterPriceWithLowestCoreInstancePrice
focal_class.parameters: (final List<EmrClusterPriceDto> emrClusterPrices)
focal_class.return: EmrClusterPriceDto
focal_class.signature: EmrClusterPriceDto getEmrClusterPriceWithLowestCoreInstancePrice(final List<EmrClusterPriceDto> emrClusterPrices)
focal_class.class_method_signature: EmrPricingHelper.getEmrClusterPricesWithinLowestCoreInstancePriceThreshold(final List<EmrClusterPriceDto> emrClusterPrices,
          final BigDecimal lowestCoreInstancePriceThresholdPercentage)
focal_class.full_signature:  List<EmrClusterPriceDto> getEmrClusterPricesWithinLowestCoreInstancePriceThreshold(final List<EmrClusterPriceDto> emrClusterPrices,
          final BigDecimal lowestCoreInstancePriceThresholdPercentage)
focal_class.identifier: getEmrClusterPricesWithinLowestCoreInstancePriceThreshold
focal_class.parameters: (final List<EmrClusterPriceDto> emrClusterPrices,
          final BigDecimal lowestCoreInstancePriceThresholdPercentage)
focal_class.return: List<EmrClusterPriceDto>
focal_class.signature: List<EmrClusterPriceDto> getEmrClusterPricesWithinLowestCoreInstancePriceThreshold(final List<EmrClusterPriceDto> emrClusterPrices,
          final BigDecimal lowestCoreInstancePriceThresholdPercentage)
focal_class.class_method_signature: EmrPricingHelper.getEmrClusterCoreInstancePrice(EmrClusterPriceDto emrClusterPrice)
focal_class.full_signature: private BigDecimal getEmrClusterCoreInstancePrice(EmrClusterPriceDto emrClusterPrice)
focal_class.identifier: getEmrClusterCoreInstancePrice
focal_class.modifiers: private
focal_class.parameters: (EmrClusterPriceDto emrClusterPrice)
focal_class.return: BigDecimal
focal_class.signature: BigDecimal getEmrClusterCoreInstancePrice(EmrClusterPriceDto emrClusterPrice)
focal_class.class_method_signature: EmrPricingHelper.removeSubnetsWithAvailableIpsLessThan(List<Subnet> subnets, int availableIps)
focal_class.full_signature: private void removeSubnetsWithAvailableIpsLessThan(List<Subnet> subnets, int availableIps)
focal_class.identifier: removeSubnetsWithAvailableIpsLessThan
focal_class.modifiers: private
focal_class.parameters: (List<Subnet> subnets, int availableIps)
focal_class.return: void
focal_class.signature: void removeSubnetsWithAvailableIpsLessThan(List<Subnet> subnets, int availableIps)
focal_class.class_method_signature: EmrPricingHelper.createEmrClusterPrice(AvailabilityZone availabilityZone, Ec2PriceDto masterPrice, Ec2PriceDto corePrice, Ec2PriceDto taskPrice)
focal_class.full_signature: private EmrClusterPriceDto createEmrClusterPrice(AvailabilityZone availabilityZone, Ec2PriceDto masterPrice, Ec2PriceDto corePrice, Ec2PriceDto taskPrice)
focal_class.identifier: createEmrClusterPrice
focal_class.modifiers: private
focal_class.parameters: (AvailabilityZone availabilityZone, Ec2PriceDto masterPrice, Ec2PriceDto corePrice, Ec2PriceDto taskPrice)
focal_class.return: EmrClusterPriceDto
focal_class.signature: EmrClusterPriceDto createEmrClusterPrice(AvailabilityZone availabilityZone, Ec2PriceDto masterPrice, Ec2PriceDto corePrice, Ec2PriceDto taskPrice)
focal_class.class_method_signature: EmrPricingHelper.getBestInstancePrice(BigDecimal spotPrice, InstanceDefinition instanceDefinition)
focal_class.full_signature: private Ec2PriceDto getBestInstancePrice(BigDecimal spotPrice, InstanceDefinition instanceDefinition)
focal_class.identifier: getBestInstancePrice
focal_class.modifiers: private
focal_class.parameters: (BigDecimal spotPrice, InstanceDefinition instanceDefinition)
focal_class.return: Ec2PriceDto
focal_class.signature: Ec2PriceDto getBestInstancePrice(BigDecimal spotPrice, InstanceDefinition instanceDefinition)
focal_class.class_method_signature: EmrPricingHelper.setBestPriceToSpotPricing(BigDecimal spotPrice, BigDecimal bidPrice, int instanceCount)
focal_class.full_signature: private Ec2PriceDto setBestPriceToSpotPricing(BigDecimal spotPrice, BigDecimal bidPrice, int instanceCount)
focal_class.identifier: setBestPriceToSpotPricing
focal_class.modifiers: private
focal_class.parameters: (BigDecimal spotPrice, BigDecimal bidPrice, int instanceCount)
focal_class.return: Ec2PriceDto
focal_class.signature: Ec2PriceDto setBestPriceToSpotPricing(BigDecimal spotPrice, BigDecimal bidPrice, int instanceCount)
focal_class.class_method_signature: EmrPricingHelper.getCoreInstanceDefinition(EmrClusterDefinition emrClusterDefinition)
focal_class.full_signature: private InstanceDefinition getCoreInstanceDefinition(EmrClusterDefinition emrClusterDefinition)
focal_class.identifier: getCoreInstanceDefinition
focal_class.modifiers: private
focal_class.parameters: (EmrClusterDefinition emrClusterDefinition)
focal_class.return: InstanceDefinition
focal_class.signature: InstanceDefinition getCoreInstanceDefinition(EmrClusterDefinition emrClusterDefinition)
focal_class.class_method_signature: EmrPricingHelper.getTaskInstanceDefinition(EmrClusterDefinition emrClusterDefinition)
focal_class.full_signature: private InstanceDefinition getTaskInstanceDefinition(EmrClusterDefinition emrClusterDefinition)
focal_class.identifier: getTaskInstanceDefinition
focal_class.modifiers: private
focal_class.parameters: (EmrClusterDefinition emrClusterDefinition)
focal_class.return: InstanceDefinition
focal_class.signature: InstanceDefinition getTaskInstanceDefinition(EmrClusterDefinition emrClusterDefinition)
focal_class.class_method_signature: EmrPricingHelper.getMasterInstanceDefinition(EmrClusterDefinition emrClusterDefinition)
focal_class.full_signature: private InstanceDefinition getMasterInstanceDefinition(EmrClusterDefinition emrClusterDefinition)
focal_class.identifier: getMasterInstanceDefinition
focal_class.modifiers: private
focal_class.parameters: (EmrClusterDefinition emrClusterDefinition)
focal_class.return: InstanceDefinition
focal_class.signature: InstanceDefinition getMasterInstanceDefinition(EmrClusterDefinition emrClusterDefinition)
focal_class.class_method_signature: EmrPricingHelper.getInstanceTypeSpotPrices(AvailabilityZone availabilityZone, Set<String> instanceTypes, AwsParamsDto awsParamsDto)
focal_class.full_signature: private Map<String, BigDecimal> getInstanceTypeSpotPrices(AvailabilityZone availabilityZone, Set<String> instanceTypes, AwsParamsDto awsParamsDto)
focal_class.identifier: getInstanceTypeSpotPrices
focal_class.modifiers: private
focal_class.parameters: (AvailabilityZone availabilityZone, Set<String> instanceTypes, AwsParamsDto awsParamsDto)
focal_class.return: Map<String, BigDecimal>
focal_class.signature: Map<String, BigDecimal> getInstanceTypeSpotPrices(AvailabilityZone availabilityZone, Set<String> instanceTypes, AwsParamsDto awsParamsDto)
focal_class.class_method_signature: EmrPricingHelper.getAvailabilityZones(List<Subnet> subnets, AwsParamsDto awsParamsDto)
focal_class.full_signature: private List<AvailabilityZone> getAvailabilityZones(List<Subnet> subnets, AwsParamsDto awsParamsDto)
focal_class.identifier: getAvailabilityZones
focal_class.modifiers: private
focal_class.parameters: (List<Subnet> subnets, AwsParamsDto awsParamsDto)
focal_class.return: List<AvailabilityZone>
focal_class.signature: List<AvailabilityZone> getAvailabilityZones(List<Subnet> subnets, AwsParamsDto awsParamsDto)
focal_class.class_method_signature: EmrPricingHelper.getSubnets(EmrClusterDefinition emrClusterDefinition, AwsParamsDto awsParamsDto)
focal_class.full_signature: public List<Subnet> getSubnets(EmrClusterDefinition emrClusterDefinition, AwsParamsDto awsParamsDto)
focal_class.identifier: getSubnets
focal_class.modifiers: public
focal_class.parameters: (EmrClusterDefinition emrClusterDefinition, AwsParamsDto awsParamsDto)
focal_class.return: List<Subnet>
focal_class.signature: List<Subnet> getSubnets(EmrClusterDefinition emrClusterDefinition, AwsParamsDto awsParamsDto)
focal_class.superclass: extends AwsHelper
focal_method.body: public void updateEmrClusterDefinitionWithBestPrice(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition,
          AwsParamsDto awsParamsDto)
      {
          EmrVpcPricingState emrVpcPricingState = new EmrVpcPricingState();
  
          // Get total count of instances this definition will attempt to create
          int totalInstanceCount = getTotalInstanceCount(emrClusterDefinition);
  
          // Get the subnet information
          List<Subnet> subnets = getSubnets(emrClusterDefinition, awsParamsDto);
          for (Subnet subnet : subnets)
          {
              emrVpcPricingState.getSubnetAvailableIpAddressCounts().put(subnet.getSubnetId(), subnet.getAvailableIpAddressCount());
          }
          // Filter out subnets with not enough available IPs
          removeSubnetsWithAvailableIpsLessThan(subnets, totalInstanceCount);
  
          if (subnets.isEmpty())
          {
              LOGGER.info(String.format("Insufficient IP availability. namespace=\"%s\" emrClusterDefinitionName=\"%s\" emrClusterName=\"%s\" " +
                      "totalRequestedInstanceCount=%s emrVpcPricingState=%s", emrClusterAlternateKeyDto.getNamespace(),
                  emrClusterAlternateKeyDto.getEmrClusterDefinitionName(), emrClusterAlternateKeyDto.getEmrClusterName(), totalInstanceCount,
                  jsonHelper.objectToJson(emrVpcPricingState)));
              throw new ObjectNotFoundException(String.format(
                  "There are no subnets in the current VPC which have sufficient IP addresses available to run your " +
                      "clusters. Try expanding the list of subnets or try again later. requestedInstanceCount=%s%n%s", totalInstanceCount,
                  emrVpcPricingStateFormatter.format(emrVpcPricingState)));
          }
  
          // Best prices are accumulated in this list
          List<EmrClusterPriceDto> emrClusterPrices = new ArrayList<>();
  
          InstanceDefinition masterInstanceDefinition = getMasterInstanceDefinition(emrClusterDefinition);
          InstanceDefinition coreInstanceDefinition = getCoreInstanceDefinition(emrClusterDefinition);
          InstanceDefinition taskInstanceDefinition = getTaskInstanceDefinition(emrClusterDefinition);
  
          Set<String> requestedInstanceTypes = new HashSet<>();
  
          String masterInstanceType = masterInstanceDefinition.getInstanceType();
          requestedInstanceTypes.add(masterInstanceType);
  
          if (coreInstanceDefinition != null)
          {
              String coreInstanceType = coreInstanceDefinition.getInstanceType();
              requestedInstanceTypes.add(coreInstanceType);
          }
  
          if (taskInstanceDefinition != null)
          {
              String taskInstanceType = taskInstanceDefinition.getInstanceType();
              requestedInstanceTypes.add(taskInstanceType);
          }
  
          // Get AZs for the subnets
          for (AvailabilityZone availabilityZone : getAvailabilityZones(subnets, awsParamsDto))
          {
              // Create a mapping of instance types to prices for more efficient, in-memory lookup
              // When AWS does not return any spot price history for an instance type in an availability zone, the algorithm will not use that availability zone
              // when selecting the lowest price.
              Map<String, BigDecimal> instanceTypeSpotPrices = getInstanceTypeSpotPrices(availabilityZone, requestedInstanceTypes, awsParamsDto);
  
              emrVpcPricingState.getSpotPricesPerAvailabilityZone().put(availabilityZone.getZoneName(), instanceTypeSpotPrices);
  
              // Get and compare master price
              BigDecimal masterSpotPrice = instanceTypeSpotPrices.get(masterInstanceType);
              Ec2PriceDto masterPrice = getBestInstancePrice(masterSpotPrice, masterInstanceDefinition);
  
              // Get and compare core price
              Ec2PriceDto corePrice = null;
              if (coreInstanceDefinition != null)
              {
                  String coreInstanceType = coreInstanceDefinition.getInstanceType();
                  BigDecimal coreSpotPrice = instanceTypeSpotPrices.get(coreInstanceType);
                  corePrice = getBestInstancePrice(coreSpotPrice, coreInstanceDefinition);
              }
  
              // Get and compare task price
              Ec2PriceDto taskPrice = null;
              if (taskInstanceDefinition != null)
              {
                  String taskInstanceType = taskInstanceDefinition.getInstanceType();
                  BigDecimal taskSpotPrice = instanceTypeSpotPrices.get(taskInstanceType);
                  taskPrice = getBestInstancePrice(taskSpotPrice, taskInstanceDefinition);
              }
  
              // If prices were found
              if (masterPrice != null && (coreInstanceDefinition == null || corePrice != null) && (taskInstanceDefinition == null || taskPrice != null))
              {
                  // Add the pricing result to the result list
                  emrClusterPrices.add(createEmrClusterPrice(availabilityZone, masterPrice, corePrice, taskPrice));
              }
  
              // If prices were not found for either master or core, this AZ cannot satisfy the search criteria. Ignore this AZ.
          }
  
          if (emrClusterPrices.isEmpty())
          {
              LOGGER.info(String.format("No subnets which satisfied the best price search criteria. namespace=\"%s\" emrClusterDefinitionName=\"%s\" " +
                      "emrClusterName=\"%s\" emrVpcPricingState=%s", emrClusterAlternateKeyDto.getNamespace(),
                  emrClusterAlternateKeyDto.getEmrClusterDefinitionName(), emrClusterAlternateKeyDto.getEmrClusterName(),
                  jsonHelper.objectToJson(emrVpcPricingState)));
              throw new ObjectNotFoundException(String.format(
                  "There were no subnets which satisfied your best price search criteria. If you explicitly opted to use spot EC2 instances, please confirm " +
                      "that your instance types support spot pricing. Otherwise, try setting the max price or the on-demand threshold to a higher value.%n%s",
                  emrVpcPricingStateFormatter.format(emrVpcPricingState)));
          }
  
          // Find the best prices from the result list
          EmrClusterPriceDto bestEmrClusterPrice = getEmrClusterPriceWithLowestCoreInstancePrice(emrClusterPrices);
  
          if (bestEmrClusterPrice != null)
          {
              // Find the best subnet among the best AZ's
              Subnet bestEmrClusterSubnet = getBestSubnetForAvailabilityZone(bestEmrClusterPrice.getAvailabilityZone(), subnets);
  
              // Update the definition with the new calculated values
              updateInstanceDefinitionsWithBestPrice(emrClusterDefinition, bestEmrClusterSubnet, bestEmrClusterPrice);
          }
      }
focal_method.class_method_signature: EmrPricingHelper.updateEmrClusterDefinitionWithBestPrice(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition,
          AwsParamsDto awsParamsDto)
focal_method.full_signature: public void updateEmrClusterDefinitionWithBestPrice(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition,
          AwsParamsDto awsParamsDto)
focal_method.identifier: updateEmrClusterDefinitionWithBestPrice
focal_method.invocations: getTotalInstanceCount getSubnets put getSubnetAvailableIpAddressCounts getSubnetId getAvailableIpAddressCount removeSubnetsWithAvailableIpsLessThan isEmpty info format getNamespace getEmrClusterDefinitionName getEmrClusterName objectToJson format format getMasterInstanceDefinition getCoreInstanceDefinition getTaskInstanceDefinition getInstanceType add getInstanceType add getInstanceType add getAvailabilityZones getInstanceTypeSpotPrices put getSpotPricesPerAvailabilityZone getZoneName get getBestInstancePrice getInstanceType get getBestInstancePrice getInstanceType get getBestInstancePrice add createEmrClusterPrice isEmpty info format getNamespace getEmrClusterDefinitionName getEmrClusterName objectToJson format format getEmrClusterPriceWithLowestCoreInstancePrice getBestSubnetForAvailabilityZone getAvailabilityZone updateInstanceDefinitionsWithBestPrice
focal_method.modifiers: public
focal_method.parameters: (EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition,
          AwsParamsDto awsParamsDto)
focal_method.return: void
focal_method.signature: void updateEmrClusterDefinitionWithBestPrice(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, EmrClusterDefinition emrClusterDefinition,
          AwsParamsDto awsParamsDto)