You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ab...@apache.org on 2013/08/02 02:53:29 UTC
git commit: JCLOUDS-221. Add availabilityZone to spot price history.
Updated Branches:
refs/heads/1.6.x e25a0843d -> 0cbcc7d64
JCLOUDS-221. Add availabilityZone to spot price history.
Project: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/commit/0cbcc7d6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/tree/0cbcc7d6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/diff/0cbcc7d6
Branch: refs/heads/1.6.x
Commit: 0cbcc7d6422e26b72ce06235169afb642bc93b87
Parents: e25a084
Author: Andrew Bayer <an...@gmail.com>
Authored: Thu Aug 1 16:04:39 2013 -0700
Committer: Andrew Bayer <an...@gmail.com>
Committed: Thu Aug 1 17:53:23 2013 -0700
----------------------------------------------------------------------
.../java/org/jclouds/aws/ec2/domain/Spot.java | 28 +++++++++++++++++---
.../org/jclouds/aws/ec2/xml/SpotHandler.java | 2 ++
...ribeSpotPriceHistoryResponseHandlerTest.java | 15 ++++++-----
.../resources/describe_spot_price_history.xml | 3 +++
4 files changed, 39 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/0cbcc7d6/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/domain/Spot.java
----------------------------------------------------------------------
diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/domain/Spot.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/domain/Spot.java
index 021dffc..3a4bac6 100644
--- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/domain/Spot.java
+++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/domain/Spot.java
@@ -37,6 +37,7 @@ public class Spot implements Comparable<Spot> {
private String productDescription;
private float spotPrice;
private Date timestamp;
+ private String availabilityZone;
public void clear() {
this.region = null;
@@ -44,6 +45,7 @@ public class Spot implements Comparable<Spot> {
this.productDescription = null;
this.spotPrice = 0.0f;
this.timestamp = null;
+ this.availabilityZone = null;
}
public Builder region(String region) {
@@ -71,8 +73,13 @@ public class Spot implements Comparable<Spot> {
return this;
}
+ public Builder availabilityZone(String availabilityZone) {
+ this.availabilityZone = availabilityZone;
+ return this;
+ }
+
public Spot build() {
- return new Spot(region, instanceType, productDescription, spotPrice, timestamp);
+ return new Spot(region, instanceType, productDescription, spotPrice, timestamp, availabilityZone);
}
}
@@ -81,13 +88,16 @@ public class Spot implements Comparable<Spot> {
private final String productDescription;
private final float spotPrice;
private final Date timestamp;
+ private final String availabilityZone;
- public Spot(String region, String instanceType, String productDescription, float spotPrice, Date timestamp) {
+ public Spot(String region, String instanceType, String productDescription, float spotPrice, Date timestamp,
+ String availabilityZone) {
this.region = checkNotNull(region, "region");
this.instanceType = checkNotNull(instanceType, "instanceType");
this.productDescription = checkNotNull(productDescription, "productDescription");
this.spotPrice = spotPrice;
this.timestamp = checkNotNull(timestamp, "timestamp");
+ this.availabilityZone = checkNotNull(availabilityZone, "availabilityZone");
}
/**
@@ -117,6 +127,10 @@ public class Spot implements Comparable<Spot> {
return timestamp;
}
+ public String getAvailabilityZone() {
+ return availabilityZone;
+ }
+
@Override
public int compareTo(Spot o) {
return Float.compare(spotPrice, o.spotPrice);
@@ -131,6 +145,7 @@ public class Spot implements Comparable<Spot> {
result = prime * result + ((region == null) ? 0 : region.hashCode());
result = prime * result + Float.floatToIntBits(spotPrice);
result = prime * result + ((timestamp == null) ? 0 : timestamp.hashCode());
+ result = prime * result + ((availabilityZone == null) ? 0 : availabilityZone.hashCode());
return result;
}
@@ -165,13 +180,20 @@ public class Spot implements Comparable<Spot> {
return false;
} else if (!timestamp.equals(other.timestamp))
return false;
+ if (availabilityZone == null) {
+ if (other.availabilityZone != null)
+ return false;
+ } else if (!availabilityZone.equals(other.availabilityZone)) {
+ return false;
+ }
return true;
}
@Override
public String toString() {
return "[region=" + region + ", instanceType=" + instanceType + ", productDescription=" + productDescription
- + ", spotPrice=" + spotPrice + ", timestamp=" + timestamp + "]";
+ + ", spotPrice=" + spotPrice + ", timestamp=" + timestamp + ", availabilityZone="
+ + availabilityZone + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/0cbcc7d6/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/SpotHandler.java
----------------------------------------------------------------------
diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/SpotHandler.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/SpotHandler.java
index 54035a9..ba01984 100644
--- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/SpotHandler.java
+++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/xml/SpotHandler.java
@@ -65,6 +65,8 @@ public class SpotHandler extends ParseSax.HandlerForGeneratedRequestWithResult<S
builder.spotPrice(Float.parseFloat(currentText.toString().trim()));
} else if (qName.equals("timestamp")) {
builder.timestamp(dateCodec.toDate(currentText.toString().trim()));
+ } else if (qName.equals("availabilityZone")) {
+ builder.availabilityZone(currentText.toString().trim());
}
currentText = new StringBuilder();
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/0cbcc7d6/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandlerTest.java
----------------------------------------------------------------------
diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandlerTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandlerTest.java
index 4a85af4..6af8a0f 100644
--- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandlerTest.java
+++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandlerTest.java
@@ -46,12 +46,15 @@ public class DescribeSpotPriceHistoryResponseHandlerTest extends BaseHandlerTest
InputStream is = getClass().getResourceAsStream("/describe_spot_price_history.xml");
Set<Spot> expected = ImmutableSet.of(
- Spot.builder().region("us-west-1").instanceType("t1.micro").productDescription("SUSE Linux").spotPrice(0.013f)
- .timestamp(new SimpleDateFormatDateService().iso8601DateParse("2011-03-07T12:17:19.000Z")).build(),
- Spot.builder().region("us-west-1").instanceType("m1.large").productDescription("Linux/UNIX").spotPrice(0.119f)
- .timestamp(new SimpleDateFormatDateService().iso8601DateParse("2011-03-07T16:29:16.000Z")).build(),
- Spot.builder().region("us-west-1").instanceType("t1.micro").productDescription("Windows").spotPrice(0.013f)
- .timestamp(new SimpleDateFormatDateService().iso8601DateParse("2011-03-07T17:56:54.000Z")).build()
+ Spot.builder().region("us-west-1").instanceType("t1.micro").productDescription("SUSE Linux").spotPrice(0.013f)
+ .timestamp(new SimpleDateFormatDateService().iso8601DateParse("2011-03-07T12:17:19.000Z"))
+ .availabilityZone("us-west-1a").build(),
+ Spot.builder().region("us-west-1").instanceType("m1.large").productDescription("Linux/UNIX").spotPrice(0.119f)
+ .timestamp(new SimpleDateFormatDateService().iso8601DateParse("2011-03-07T16:29:16.000Z"))
+ .availabilityZone("us-west-1b").build(),
+ Spot.builder().region("us-west-1").instanceType("t1.micro").productDescription("Windows").spotPrice(0.013f)
+ .timestamp(new SimpleDateFormatDateService().iso8601DateParse("2011-03-07T17:56:54.000Z"))
+ .availabilityZone("us-west-1c").build()
);
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/0cbcc7d6/providers/aws-ec2/src/test/resources/describe_spot_price_history.xml
----------------------------------------------------------------------
diff --git a/providers/aws-ec2/src/test/resources/describe_spot_price_history.xml b/providers/aws-ec2/src/test/resources/describe_spot_price_history.xml
index b71570a..c25a536 100644
--- a/providers/aws-ec2/src/test/resources/describe_spot_price_history.xml
+++ b/providers/aws-ec2/src/test/resources/describe_spot_price_history.xml
@@ -7,18 +7,21 @@
<productDescription>SUSE Linux</productDescription>
<spotPrice>0.013000</spotPrice>
<timestamp>2011-03-07T12:17:19.000Z</timestamp>
+ <availabilityZone>us-west-1a</availabilityZone>
</item>
<item>
<instanceType>m1.large</instanceType>
<productDescription>Linux/UNIX</productDescription>
<spotPrice>0.119000</spotPrice>
<timestamp>2011-03-07T16:29:16.000Z</timestamp>
+ <availabilityZone>us-west-1b</availabilityZone>
</item>
<item>
<instanceType>t1.micro</instanceType>
<productDescription>Windows</productDescription>
<spotPrice>0.013000</spotPrice>
<timestamp>2011-03-07T17:56:54.000Z</timestamp>
+ <availabilityZone>us-west-1c</availabilityZone>
</item>
</spotPriceHistorySet>
</DescribeSpotPriceHistoryResponse>
\ No newline at end of file