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 String productDescription;
|
||||||
private float spotPrice;
|
private float spotPrice;
|
||||||
private Date timestamp;
|
private Date timestamp;
|
||||||
|
private String availabilityZone;
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
this.region = null;
|
this.region = null;
|
||||||
|
@ -44,6 +45,7 @@ public class Spot implements Comparable<Spot> {
|
||||||
this.productDescription = null;
|
this.productDescription = null;
|
||||||
this.spotPrice = 0.0f;
|
this.spotPrice = 0.0f;
|
||||||
this.timestamp = null;
|
this.timestamp = null;
|
||||||
|
this.availabilityZone = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder region(String region) {
|
public Builder region(String region) {
|
||||||
|
@ -71,8 +73,13 @@ public class Spot implements Comparable<Spot> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder availabilityZone(String availabilityZone) {
|
||||||
|
this.availabilityZone = availabilityZone;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Spot build() {
|
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 String productDescription;
|
||||||
private final float spotPrice;
|
private final float spotPrice;
|
||||||
private final Date timestamp;
|
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.region = checkNotNull(region, "region");
|
||||||
this.instanceType = checkNotNull(instanceType, "instanceType");
|
this.instanceType = checkNotNull(instanceType, "instanceType");
|
||||||
this.productDescription = checkNotNull(productDescription, "productDescription");
|
this.productDescription = checkNotNull(productDescription, "productDescription");
|
||||||
this.spotPrice = spotPrice;
|
this.spotPrice = spotPrice;
|
||||||
this.timestamp = checkNotNull(timestamp, "timestamp");
|
this.timestamp = checkNotNull(timestamp, "timestamp");
|
||||||
|
this.availabilityZone = checkNotNull(availabilityZone, "availabilityZone");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,6 +127,10 @@ public class Spot implements Comparable<Spot> {
|
||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAvailabilityZone() {
|
||||||
|
return availabilityZone;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Spot o) {
|
public int compareTo(Spot o) {
|
||||||
return Float.compare(spotPrice, o.spotPrice);
|
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 + ((region == null) ? 0 : region.hashCode());
|
||||||
result = prime * result + Float.floatToIntBits(spotPrice);
|
result = prime * result + Float.floatToIntBits(spotPrice);
|
||||||
result = prime * result + ((timestamp == null) ? 0 : timestamp.hashCode());
|
result = prime * result + ((timestamp == null) ? 0 : timestamp.hashCode());
|
||||||
|
result = prime * result + ((availabilityZone == null) ? 0 : availabilityZone.hashCode());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,13 +180,20 @@ public class Spot implements Comparable<Spot> {
|
||||||
return false;
|
return false;
|
||||||
} else if (!timestamp.equals(other.timestamp))
|
} else if (!timestamp.equals(other.timestamp))
|
||||||
return false;
|
return false;
|
||||||
|
if (availabilityZone == null) {
|
||||||
|
if (other.availabilityZone != null)
|
||||||
|
return false;
|
||||||
|
} else if (!availabilityZone.equals(other.availabilityZone)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[region=" + region + ", instanceType=" + instanceType + ", productDescription=" + productDescription
|
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()));
|
builder.spotPrice(Float.parseFloat(currentText.toString().trim()));
|
||||||
} else if (qName.equals("timestamp")) {
|
} else if (qName.equals("timestamp")) {
|
||||||
builder.timestamp(dateCodec.toDate(currentText.toString().trim()));
|
builder.timestamp(dateCodec.toDate(currentText.toString().trim()));
|
||||||
|
} else if (qName.equals("availabilityZone")) {
|
||||||
|
builder.availabilityZone(currentText.toString().trim());
|
||||||
}
|
}
|
||||||
currentText = new StringBuilder();
|
currentText = new StringBuilder();
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,12 +46,15 @@ public class DescribeSpotPriceHistoryResponseHandlerTest extends BaseHandlerTest
|
||||||
InputStream is = getClass().getResourceAsStream("/describe_spot_price_history.xml");
|
InputStream is = getClass().getResourceAsStream("/describe_spot_price_history.xml");
|
||||||
|
|
||||||
Set<Spot> expected = ImmutableSet.of(
|
Set<Spot> expected = ImmutableSet.of(
|
||||||
Spot.builder().region("us-west-1").instanceType("t1.micro").productDescription("SUSE Linux").spotPrice(0.013f)
|
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(),
|
.timestamp(new SimpleDateFormatDateService().iso8601DateParse("2011-03-07T12:17:19.000Z"))
|
||||||
Spot.builder().region("us-west-1").instanceType("m1.large").productDescription("Linux/UNIX").spotPrice(0.119f)
|
.availabilityZone("us-west-1a").build(),
|
||||||
.timestamp(new SimpleDateFormatDateService().iso8601DateParse("2011-03-07T16:29:16.000Z")).build(),
|
Spot.builder().region("us-west-1").instanceType("m1.large").productDescription("Linux/UNIX").spotPrice(0.119f)
|
||||||
Spot.builder().region("us-west-1").instanceType("t1.micro").productDescription("Windows").spotPrice(0.013f)
|
.timestamp(new SimpleDateFormatDateService().iso8601DateParse("2011-03-07T16:29:16.000Z"))
|
||||||
.timestamp(new SimpleDateFormatDateService().iso8601DateParse("2011-03-07T17:56:54.000Z")).build()
|
.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>
|
<productDescription>SUSE Linux</productDescription>
|
||||||
<spotPrice>0.013000</spotPrice>
|
<spotPrice>0.013000</spotPrice>
|
||||||
<timestamp>2011-03-07T12:17:19.000Z</timestamp>
|
<timestamp>2011-03-07T12:17:19.000Z</timestamp>
|
||||||
|
<availabilityZone>us-west-1a</availabilityZone>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<instanceType>m1.large</instanceType>
|
<instanceType>m1.large</instanceType>
|
||||||
<productDescription>Linux/UNIX</productDescription>
|
<productDescription>Linux/UNIX</productDescription>
|
||||||
<spotPrice>0.119000</spotPrice>
|
<spotPrice>0.119000</spotPrice>
|
||||||
<timestamp>2011-03-07T16:29:16.000Z</timestamp>
|
<timestamp>2011-03-07T16:29:16.000Z</timestamp>
|
||||||
|
<availabilityZone>us-west-1b</availabilityZone>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<instanceType>t1.micro</instanceType>
|
<instanceType>t1.micro</instanceType>
|
||||||
<productDescription>Windows</productDescription>
|
<productDescription>Windows</productDescription>
|
||||||
<spotPrice>0.013000</spotPrice>
|
<spotPrice>0.013000</spotPrice>
|
||||||
<timestamp>2011-03-07T17:56:54.000Z</timestamp>
|
<timestamp>2011-03-07T17:56:54.000Z</timestamp>
|
||||||
|
<availabilityZone>us-west-1c</availabilityZone>
|
||||||
</item>
|
</item>
|
||||||
</spotPriceHistorySet>
|
</spotPriceHistorySet>
|
||||||
</DescribeSpotPriceHistoryResponse>
|
</DescribeSpotPriceHistoryResponse>
|
Loading…
Reference in New Issue