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)
|
@FormParams(keys = "Version", values = CloudWatchAsyncClient.VERSION)
|
||||||
@VirtualHost
|
@VirtualHost
|
||||||
public interface CloudWatchAsyncClient {
|
public interface CloudWatchAsyncClient {
|
||||||
public static final String VERSION = "2009-05-15";
|
public static final String VERSION = "2010-08-01";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CloudWatchClient#getMetricStatisticsInRegion
|
* @see CloudWatchClient#getMetricStatisticsInRegion
|
||||||
|
@ -64,7 +64,8 @@ public interface CloudWatchAsyncClient {
|
||||||
@FormParams(keys = "Action", values = "GetMetricStatistics")
|
@FormParams(keys = "Action", values = "GetMetricStatistics")
|
||||||
ListenableFuture<? extends Set<Datapoint>> getMetricStatisticsInRegion(
|
ListenableFuture<? extends Set<Datapoint>> getMetricStatisticsInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
|
@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("StartTime") @ParamParser(ISO8601Format.class) Date startTime,
|
||||||
@FormParam("EndTime") @ParamParser(ISO8601Format.class) Date endTime, @FormParam("Period") int period,
|
@FormParam("EndTime") @ParamParser(ISO8601Format.class) Date endTime, @FormParam("Period") int period,
|
||||||
@FormParam("Statistics.member.1") String statistics);
|
@FormParam("Statistics.member.1") String statistics);
|
||||||
|
|
|
@ -51,13 +51,15 @@ public interface CloudWatchClient {
|
||||||
*
|
*
|
||||||
* @param region
|
* @param region
|
||||||
* region to gather metrics in
|
* region to gather metrics in
|
||||||
* @param measureName
|
* @param metricName
|
||||||
* The measure name that corresponds to the measure for the gathered metric.
|
* The measure name that corresponds to the measure for the gathered metric.
|
||||||
* <p/>
|
* <p/>
|
||||||
* note
|
* note
|
||||||
* <p/>
|
* <p/>
|
||||||
* Must be a valid collected metric with the corresponding measure name, please see
|
* Must be a valid collected metric with the corresponding measure name, please see
|
||||||
* Available Amazon CloudWatch Metrics
|
* Available Amazon CloudWatch Metrics
|
||||||
|
* @param namespace
|
||||||
|
* The namespace of the metric (e.g. AWS/EC2)
|
||||||
* @param startTime
|
* @param startTime
|
||||||
* The timestamp of the first datapoint to return, inclusive. We round your value down
|
* 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
|
* 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
|
* @param statistics
|
||||||
* The statistics to be returned for the given metric. ex. Average
|
* The statistics to be returned for the given metric. ex. Average
|
||||||
*/
|
*/
|
||||||
Set<Datapoint> getMetricStatisticsInRegion(@Nullable String region, String measureName, Date startTime,
|
Set<Datapoint> getMetricStatisticsInRegion(@Nullable String region, String metricName, String namespace,
|
||||||
Date endTime, int period, String statistics);
|
Date startTime, Date endTime, int period, String statistics);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.cloudwatch.domain.Datapoint;
|
import org.jclouds.cloudwatch.domain.Datapoint;
|
||||||
import org.jclouds.logging.Logger;
|
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
import org.jclouds.rest.RestContextFactory;
|
||||||
|
@ -86,16 +85,17 @@ public class CloudWatchClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
protected void testGetMetricStatisticsInRegion() {
|
protected void testGetMetricStatisticsInRegion() {
|
||||||
getMetricStatisticsInRegion(null);
|
getEC2MetricStatisticsInRegion(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void getMetricStatisticsInRegion(String region) {
|
protected Set<Datapoint> getEC2MetricStatisticsInRegion(String region) {
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.add(Calendar.MINUTE, -1);
|
cal.add(Calendar.MINUTE, -60 * 24 * 3); // 3 days
|
||||||
|
|
||||||
Set<Datapoint> datapoints = client.getMetricStatisticsInRegion(
|
Set<Datapoint> datapoints = client.getMetricStatisticsInRegion(
|
||||||
region, "CPUUtilization", cal.getTime(), new Date(), 60, "Average");
|
region, "CPUUtilization", "AWS/EC2", cal.getTime(), new Date(), 180, "Average");
|
||||||
assert datapoints != null;
|
|
||||||
|
return checkNotNull(datapoints, "Got null response for EC2 datapoints in region ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterTest
|
@AfterTest
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class AWSCloudWatchClientLiveTest extends CloudWatchClientLiveTest {
|
||||||
@Test
|
@Test
|
||||||
public void testGetMetricStatisticsInRegion() {
|
public void testGetMetricStatisticsInRegion() {
|
||||||
for (String region : Region.DEFAULT_REGIONS) {
|
for (String region : Region.DEFAULT_REGIONS) {
|
||||||
getMetricStatisticsInRegion(region);
|
getEC2MetricStatisticsInRegion(region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,8 +155,9 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Set<Datapoint> datapoints = monitoringContext.getApi().getMetricStatisticsInRegion(instance.getRegion(),
|
Set<Datapoint> datapoints = monitoringContext.getApi().getMetricStatisticsInRegion(instance.getRegion(),
|
||||||
"CPUUtilization", before, new Date(), 60, "Average");
|
"CPUUtilization", "AWS/EC2", before, new Date(), 60, "Average");
|
||||||
assert datapoints != null;
|
assert datapoints != null && datapoints.size() > 0;
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
monitoringContext.close();
|
monitoringContext.close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue