mirror of https://github.com/apache/jclouds.git
JCLOUDS-221. Add availabilityZone to spot price history.
This commit is contained in:
parent
2fcd90c394
commit
82fe701c77
|
@ -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 + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
||||
);
|
||||
|
||||
|
|
|
@ -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>
|
Loading…
Reference in New Issue