mirror of https://github.com/apache/jclouds.git
Updated CloudWatchClient code to latest version
See http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/i ndex.html?API_GetMetricStatistics.html
This commit is contained in:
parent
51e2b40aa9
commit
b15db13574
|
@ -53,7 +53,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
@FormParams(keys = "Version", values = CloudWatchAsyncClient.VERSION)
|
||||
@VirtualHost
|
||||
public interface CloudWatchAsyncClient {
|
||||
public static final String VERSION = "2009-05-15";
|
||||
public static final String VERSION = "2010-08-01";
|
||||
|
||||
/**
|
||||
* @see CloudWatchClient#getMetricStatisticsInRegion
|
||||
|
@ -64,7 +64,8 @@ public interface CloudWatchAsyncClient {
|
|||
@FormParams(keys = "Action", values = "GetMetricStatistics")
|
||||
ListenableFuture<? extends Set<Datapoint>> getMetricStatisticsInRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
|
||||
@FormParam("MeasureName") String measureName,
|
||||
@FormParam("MetricName") String metricName,
|
||||
@FormParam("Namespace") String namespace,
|
||||
@FormParam("StartTime") @ParamParser(ISO8601Format.class) Date startTime,
|
||||
@FormParam("EndTime") @ParamParser(ISO8601Format.class) Date endTime, @FormParam("Period") int period,
|
||||
@FormParam("Statistics.member.1") String statistics);
|
||||
|
|
|
@ -51,13 +51,15 @@ public interface CloudWatchClient {
|
|||
*
|
||||
* @param region
|
||||
* region to gather metrics in
|
||||
* @param measureName
|
||||
* @param metricName
|
||||
* The measure name that corresponds to the measure for the gathered metric.
|
||||
* <p/>
|
||||
* note
|
||||
* <p/>
|
||||
* Must be a valid collected metric with the corresponding measure name, please see
|
||||
* Available Amazon CloudWatch Metrics
|
||||
* @param namespace
|
||||
* The namespace of the metric (e.g. AWS/EC2)
|
||||
* @param startTime
|
||||
* The timestamp of the first datapoint to return, inclusive. We round your value down
|
||||
* to the nearest minute. You can set your start time for more than two weeks in the
|
||||
|
@ -70,7 +72,7 @@ public interface CloudWatchClient {
|
|||
* @param statistics
|
||||
* The statistics to be returned for the given metric. ex. Average
|
||||
*/
|
||||
Set<Datapoint> getMetricStatisticsInRegion(@Nullable String region, String measureName, Date startTime,
|
||||
Date endTime, int period, String statistics);
|
||||
Set<Datapoint> getMetricStatisticsInRegion(@Nullable String region, String metricName, String namespace,
|
||||
Date startTime, Date endTime, int period, String statistics);
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ import java.util.Set;
|
|||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.cloudwatch.domain.Datapoint;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
|
@ -86,16 +85,17 @@ public class CloudWatchClientLiveTest {
|
|||
|
||||
@Test
|
||||
protected void testGetMetricStatisticsInRegion() {
|
||||
getMetricStatisticsInRegion(null);
|
||||
getEC2MetricStatisticsInRegion(null);
|
||||
}
|
||||
|
||||
protected void getMetricStatisticsInRegion(String region) {
|
||||
protected Set<Datapoint> getEC2MetricStatisticsInRegion(String region) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(Calendar.MINUTE, -1);
|
||||
cal.add(Calendar.MINUTE, -60 * 24 * 3); // 3 days
|
||||
|
||||
Set<Datapoint> datapoints = client.getMetricStatisticsInRegion(
|
||||
region, "CPUUtilization", cal.getTime(), new Date(), 60, "Average");
|
||||
assert datapoints != null;
|
||||
region, "CPUUtilization", "AWS/EC2", cal.getTime(), new Date(), 180, "Average");
|
||||
|
||||
return checkNotNull(datapoints, "Got null response for EC2 datapoints in region ");
|
||||
}
|
||||
|
||||
@AfterTest
|
||||
|
|
|
@ -36,7 +36,7 @@ public class AWSCloudWatchClientLiveTest extends CloudWatchClientLiveTest {
|
|||
@Test
|
||||
public void testGetMetricStatisticsInRegion() {
|
||||
for (String region : Region.DEFAULT_REGIONS) {
|
||||
getMetricStatisticsInRegion(region);
|
||||
getEC2MetricStatisticsInRegion(region);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,8 +155,9 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
|
|||
|
||||
try {
|
||||
Set<Datapoint> datapoints = monitoringContext.getApi().getMetricStatisticsInRegion(instance.getRegion(),
|
||||
"CPUUtilization", before, new Date(), 60, "Average");
|
||||
assert datapoints != null;
|
||||
"CPUUtilization", "AWS/EC2", before, new Date(), 60, "Average");
|
||||
assert datapoints != null && datapoints.size() > 0;
|
||||
|
||||
} finally {
|
||||
monitoringContext.close();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue