@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAvailabilityZone() == null) ? 0 : getAvailabilityZone().hashCode()); hashCode = prime * hashCode + ((getInstanceType() == null) ? 0 : getInstanceType().hashCode()); hashCode = prime * hashCode + ((getProductDescription() == null) ? 0 : getProductDescription().hashCode()); hashCode = prime * hashCode + ((getSpotPrice() == null) ? 0 : getSpotPrice().hashCode()); hashCode = prime * hashCode + ((getTimestamp() == null) ? 0 : getTimestamp().hashCode()); return hashCode; }
/** * <p> * The Availability Zone. * </p> * * @param availabilityZone * The Availability Zone. * @return Returns a reference to this object so that method calls can be chained together. */ public SpotPrice withAvailabilityZone(String availabilityZone) { setAvailabilityZone(availabilityZone); return this; }
/** * <p> * The instance type. * </p> * * @param instanceType * The instance type. * @return Returns a reference to this object so that method calls can be chained together. * @see InstanceType */ public SpotPrice withInstanceType(String instanceType) { setInstanceType(instanceType); return this; }
public SpotPrice unmarshall(StaxUnmarshallerContext context) throws Exception { SpotPrice spotPrice = new SpotPrice(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; spotPrice.setAvailabilityZone(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; spotPrice.setInstanceType(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; spotPrice.setProductDescription(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; spotPrice.setSpotPrice(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; spotPrice.setTimestamp(DateStaxUnmarshallerFactory.getInstance("iso8601").unmarshall(context)); continue;
/** * Converts this object into an AWS equivalent object. * * @return A new equivalent AWS object */ public SpotPrice toAwsObject() { SpotPrice spotPrice = new SpotPrice(); spotPrice.setAvailabilityZone(availabilityZone); spotPrice.setInstanceType(type); spotPrice.setSpotPrice(this.spotPrice); return spotPrice; }
/** * Returns a mapping of instance types to spot prices for the given AZ and instance types. The spot prices are retrieved from EC2 API. * <p/> * This method also validates that the given instance types are real instance types supported by AWS. * * @param availabilityZone the AZ of the spot instances * @param instanceTypes the size of the spot instances * @param awsParamsDto the AWS related parameters for access/secret keys and proxy details * * @return the mapping of instance type to spot prices * @throws ObjectNotFoundException when any of the instance type does not exist in AWS */ private Map<String, BigDecimal> getInstanceTypeSpotPrices(AvailabilityZone availabilityZone, Set<String> instanceTypes, AwsParamsDto awsParamsDto) { List<String> productDescriptions = herdStringHelper.getDelimitedConfigurationValue(ConfigurationValue.EMR_SPOT_PRICE_HISTORY_PRODUCT_DESCRIPTIONS); List<SpotPrice> spotPrices = ec2Dao.getLatestSpotPrices(availabilityZone.getZoneName(), instanceTypes, productDescriptions, awsParamsDto); Map<String, BigDecimal> instanceTypeSpotPrices = new HashMap<>(); for (SpotPrice spotPrice : spotPrices) { instanceTypeSpotPrices.put(spotPrice.getInstanceType(), new BigDecimal(spotPrice.getSpotPrice())); } return instanceTypeSpotPrices; }
SpotPrice currentPrice = result.getSpotPriceHistory().get(0); cp = currentPrice.getSpotPrice();
/** * <p> * The maximum price per hour that you are willing to pay for a Spot Instance. * </p> * * @param spotPrice * The maximum price per hour that you are willing to pay for a Spot Instance. * @return Returns a reference to this object so that method calls can be chained together. */ public SpotPrice withSpotPrice(String spotPrice) { setSpotPrice(spotPrice); return this; }
/** * This implementation uses DescribeSpotPriceHistory API which returns the latest spot price history for the specified AZ and instance types. This method * then filters the returned list to only contain the latest spot price for each instance type. */ @Override public List<SpotPrice> getLatestSpotPrices(String availabilityZone, Collection<String> instanceTypes, Collection<String> productDescriptions, AwsParamsDto awsParamsDto) { AmazonEC2Client ec2Client = getEc2Client(awsParamsDto); DescribeSpotPriceHistoryRequest describeSpotPriceHistoryRequest = new DescribeSpotPriceHistoryRequest(); describeSpotPriceHistoryRequest.setAvailabilityZone(availabilityZone); describeSpotPriceHistoryRequest.setInstanceTypes(instanceTypes); describeSpotPriceHistoryRequest.setProductDescriptions(productDescriptions); DescribeSpotPriceHistoryResult describeSpotPriceHistoryResult = ec2Operations.describeSpotPriceHistory(ec2Client, describeSpotPriceHistoryRequest); List<SpotPrice> spotPrices = new ArrayList<>(); Set<String> instanceTypesFound = new HashSet<>(); for (SpotPrice spotPriceHistoryEntry : describeSpotPriceHistoryResult.getSpotPriceHistory()) { if (instanceTypesFound.add(spotPriceHistoryEntry.getInstanceType())) { spotPrices.add(spotPriceHistoryEntry); } } return spotPrices; }
/** * <p> * A general description of the AMI. * </p> * * @param productDescription * A general description of the AMI. * @return Returns a reference to this object so that method calls can be chained together. * @see RIProductDescription */ public SpotPrice withProductDescription(String productDescription) { setProductDescription(productDescription); return this; }
public SpotPrice unmarshall(StaxUnmarshallerContext context) throws Exception { SpotPrice spotPrice = new SpotPrice(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; spotPrice.setInstanceType(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; spotPrice.setProductDescription(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; spotPrice.setSpotPrice(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; spotPrice.setTimestamp(DateStaxUnmarshaller.getInstance().unmarshall(context)); continue; spotPrice.setAvailabilityZone(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue;
/** * Returns a mapping of instance types to spot prices for the given AZ and instance types. The spot prices are retrieved from EC2 API. * <p/> * This method also validates that the given instance types are real instance types supported by AWS. * * @param availabilityZone the AZ of the spot instances * @param instanceTypes the size of the spot instances * @param awsParamsDto the AWS related parameters for access/secret keys and proxy details * * @return the mapping of instance type to spot prices * @throws ObjectNotFoundException when any of the instance type does not exist in AWS */ private Map<String, BigDecimal> getInstanceTypeSpotPrices(AvailabilityZone availabilityZone, Set<String> instanceTypes, AwsParamsDto awsParamsDto) { List<String> productDescriptions = herdStringHelper.getDelimitedConfigurationValue(ConfigurationValue.EMR_SPOT_PRICE_HISTORY_PRODUCT_DESCRIPTIONS); List<SpotPrice> spotPrices = ec2Dao.getLatestSpotPrices(availabilityZone.getZoneName(), instanceTypes, productDescriptions, awsParamsDto); Map<String, BigDecimal> instanceTypeSpotPrices = new HashMap<>(); for (SpotPrice spotPrice : spotPrices) { instanceTypeSpotPrices.put(spotPrice.getInstanceType(), new BigDecimal(spotPrice.getSpotPrice())); } return instanceTypeSpotPrices; }
SpotPrice currentPrice = result.getSpotPriceHistory().get(0); cp = currentPrice.getSpotPrice();
/** * <p> * The maximum price per hour that you are willing to pay for a Spot Instance. * </p> * * @param spotPrice * The maximum price per hour that you are willing to pay for a Spot Instance. * @return Returns a reference to this object so that method calls can be chained together. */ public SpotPrice withSpotPrice(String spotPrice) { setSpotPrice(spotPrice); return this; }
/** * This implementation uses DescribeSpotPriceHistory API which returns the latest spot price history for the specified AZ and instance types. This method * then filters the returned list to only contain the latest spot price for each instance type. */ @Override public List<SpotPrice> getLatestSpotPrices(String availabilityZone, Collection<String> instanceTypes, Collection<String> productDescriptions, AwsParamsDto awsParamsDto) { AmazonEC2Client ec2Client = getEc2Client(awsParamsDto); DescribeSpotPriceHistoryRequest describeSpotPriceHistoryRequest = new DescribeSpotPriceHistoryRequest(); describeSpotPriceHistoryRequest.setAvailabilityZone(availabilityZone); describeSpotPriceHistoryRequest.setInstanceTypes(instanceTypes); describeSpotPriceHistoryRequest.setProductDescriptions(productDescriptions); DescribeSpotPriceHistoryResult describeSpotPriceHistoryResult = ec2Operations.describeSpotPriceHistory(ec2Client, describeSpotPriceHistoryRequest); List<SpotPrice> spotPrices = new ArrayList<>(); Set<String> instanceTypesFound = new HashSet<>(); for (SpotPrice spotPriceHistoryEntry : describeSpotPriceHistoryResult.getSpotPriceHistory()) { if (instanceTypesFound.add(spotPriceHistoryEntry.getInstanceType())) { spotPrices.add(spotPriceHistoryEntry); } } return spotPrices; }
/** * <p> * A general description of the AMI. * </p> * * @param productDescription * A general description of the AMI. * @return Returns a reference to this object so that method calls can be chained together. * @see RIProductDescription */ public SpotPrice withProductDescription(String productDescription) { setProductDescription(productDescription); return this; }
return false; SpotPrice other = (SpotPrice) obj; if (other.getAvailabilityZone() == null ^ this.getAvailabilityZone() == null) return false; if (other.getAvailabilityZone() != null && other.getAvailabilityZone().equals(this.getAvailabilityZone()) == false) return false; if (other.getInstanceType() == null ^ this.getInstanceType() == null) return false; if (other.getInstanceType() != null && other.getInstanceType().equals(this.getInstanceType()) == false) return false; if (other.getProductDescription() == null ^ this.getProductDescription() == null) return false; if (other.getProductDescription() != null && other.getProductDescription().equals(this.getProductDescription()) == false) return false; if (other.getSpotPrice() == null ^ this.getSpotPrice() == null) return false; if (other.getSpotPrice() != null && other.getSpotPrice().equals(this.getSpotPrice()) == false) return false; if (other.getTimestamp() == null ^ this.getTimestamp() == null) return false; if (other.getTimestamp() != null && other.getTimestamp().equals(this.getTimestamp()) == false) return false; return true;
public SpotPrice unmarshall(StaxUnmarshallerContext context) throws Exception { SpotPrice spotPrice = new SpotPrice(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; spotPrice.setAvailabilityZone(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; spotPrice.setInstanceType(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; spotPrice.setProductDescription(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; spotPrice.setSpotPrice(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; spotPrice.setTimestamp(DateStaxUnmarshallerFactory.getInstance("iso8601").unmarshall(context)); continue;
/** * <p> * The Availability Zone. * </p> * * @param availabilityZone * The Availability Zone. * @return Returns a reference to this object so that method calls can be chained together. */ public SpotPrice withAvailabilityZone(String availabilityZone) { setAvailabilityZone(availabilityZone); return this; }
/** * <p> * The instance type. * </p> * * @param instanceType * The instance type. * @return Returns a reference to this object so that method calls can be chained together. * @see InstanceType */ public SpotPrice withInstanceType(String instanceType) { setInstanceType(instanceType); return this; }