From 8121444f04c859085412a140e3840b8f22aab70a Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 3 Jan 2013 16:13:27 -0800 Subject: [PATCH] removed deprecated cloudwatch method --- .../org/jclouds/cloudwatch/CloudWatchApi.java | 53 +------- .../cloudwatch/CloudWatchAsyncApi.java | 41 +----- .../cloudwatch/CloudWatchApiLiveTest.java | 75 ----------- .../cloudwatch/CloudWatchAsyncApiTest.java | 126 ------------------ .../cloudwatch/AWSCloudWatchApiLiveTest.java | 42 ------ 5 files changed, 5 insertions(+), 332 deletions(-) delete mode 100644 apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiLiveTest.java delete mode 100644 apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchAsyncApiTest.java delete mode 100644 providers/aws-cloudwatch/src/test/java/org/jclouds/aws/cloudwatch/AWSCloudWatchApiLiveTest.java diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApi.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApi.java index e8ca3145af..79a2494cec 100644 --- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApi.java +++ b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApi.java @@ -18,19 +18,16 @@ */ package org.jclouds.cloudwatch; -import com.google.inject.Provides; -import org.jclouds.cloudwatch.domain.Datapoint; -import org.jclouds.cloudwatch.domain.Statistics; +import java.util.Set; + import org.jclouds.cloudwatch.features.MetricApi; -import org.jclouds.cloudwatch.options.GetMetricStatisticsOptions; import org.jclouds.javax.annotation.Nullable; import org.jclouds.location.Region; import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.EndpointParam; -import java.util.Date; -import java.util.Set; +import com.google.inject.Provides; /** * Provides access to Amazon CloudWatch via the Query API *

@@ -48,49 +45,7 @@ public interface CloudWatchApi { @Provides @Region Set getConfiguredRegions(); - - /** - * This call returns data for one or more statistics of given a metric. For more information, see - * Statistic and Metric. - * - *

- *

Note

The maximum number of datapoints that the Amazon CloudWatch service will return - * in a single GetMetricStatistics request is 1,440. If a request is made that would generate - * more datapoints than this amount, Amazon CloudWatch will return an error. You can alter your - * request by narrowing the time range (StartTime, EndTime) or increasing the Period in your - * single request. You may also get all of the data at the granularity you originally asked for - * by making multiple requests with adjacent time ranges. - * - * @param region - * region to gather metrics in - * @param metricName - * The measure name that corresponds to the measure for the gathered metric. - *

- * note - *

- * 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 - * past. However, you will only get data for the past two weeks. - * @param endTime - * The timestamp to use for determining the last datapoint to return. This is the last - * datapoint to fetch, exclusive. - * @param period - * The granularity (in seconds) of the returned datapoints. - * @param statistics - * The statistics to be returned for the given metric. ex. Average - * @param options - * more filtering options (e.g. instance ID) - * @see MetricApi#getMetricStatistics(org.jclouds.cloudwatch.domain.GetMetricStatistics) - */ - @Deprecated - Set getMetricStatisticsInRegion(@Nullable String region, String metricName, String namespace, - Date startTime, Date endTime, int period, Statistics statistics, GetMetricStatisticsOptions... options); - + /** * Provides synchronous access to Metric features. */ diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchAsyncApi.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchAsyncApi.java index 7f4080cf65..a5d9fd98c6 100644 --- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchAsyncApi.java +++ b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchAsyncApi.java @@ -18,33 +18,15 @@ */ package org.jclouds.cloudwatch; -import java.util.Date; import java.util.Set; -import javax.inject.Named; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.cloudwatch.domain.Datapoint; -import org.jclouds.cloudwatch.domain.Statistics; import org.jclouds.cloudwatch.features.MetricAsyncApi; -import org.jclouds.cloudwatch.functions.ISO8601Format; -import org.jclouds.cloudwatch.options.GetMetricStatisticsOptions; -import org.jclouds.cloudwatch.xml.GetMetricStatisticsResponseHandler; import org.jclouds.javax.annotation.Nullable; import org.jclouds.location.Region; import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.EndpointParam; -import org.jclouds.rest.annotations.FormParams; -import org.jclouds.rest.annotations.ParamParser; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.VirtualHost; -import org.jclouds.rest.annotations.XMLResponseParser; -import com.google.common.util.concurrent.ListenableFuture; import com.google.inject.Provides; /** @@ -56,8 +38,6 @@ import com.google.inject.Provides; * /> * @author Adrian Cole */ -@RequestFilters(FormSigner.class) -@VirtualHost public interface CloudWatchAsyncApi { /** * @@ -66,26 +46,7 @@ public interface CloudWatchAsyncApi { @Provides @Region Set getConfiguredRegions(); - - /** - * @see MetricAsyncApi#getMetricStatistics - */ - @Named("cloudwatch:GetMetricStatistics") - @Deprecated - @POST - @Path("/") - @XMLResponseParser(GetMetricStatisticsResponseHandler.class) - @FormParams(keys = "Action", values = "GetMetricStatistics") - ListenableFuture> getMetricStatisticsInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @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") Statistics statistics, - GetMetricStatisticsOptions... options); - + /** * Provides asynchronous access to Metric features. */ diff --git a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiLiveTest.java b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiLiveTest.java deleted file mode 100644 index 73be0dae0b..0000000000 --- a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiLiveTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.cloudwatch; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Calendar; -import java.util.Date; -import java.util.Set; - -import org.jclouds.apis.BaseContextLiveTest; -import org.jclouds.cloudwatch.domain.Datapoint; -import org.jclouds.cloudwatch.domain.Statistics; -import org.jclouds.cloudwatch.domain.Unit; -import org.jclouds.cloudwatch.options.GetMetricStatisticsOptions; -import org.jclouds.rest.RestContext; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.reflect.TypeToken; - -/** - * Tests behavior of {@code CloudWatchApi} - * - * @author Adrian Cole - */ -@Test(groups = "live", testName ="CloudWatchApiLiveTest", singleThreaded = true) -@Deprecated -public class CloudWatchApiLiveTest extends BaseContextLiveTest> { - public CloudWatchApiLiveTest() { - provider = "cloudwatch"; - } - - private CloudWatchApi api; - - @Override - @BeforeClass(groups = { "integration", "live" }) - public void setupContext() { - super.setupContext(); - api = context.getApi(); - } - - - protected Set getEC2MetricStatisticsInRegion(String region) { - Calendar cal = Calendar.getInstance(); - cal.add(Calendar.MINUTE, -60 * 24 * 3); // 3 days - - Set datapoints = api.getMetricStatisticsInRegion(region, "CPUUtilization", "AWS/EC2", - cal.getTime(), new Date(), 180, Statistics.AVERAGE, GetMetricStatisticsOptions.Builder.unit(Unit.PERCENT)); - - return checkNotNull(datapoints, "Got null response for EC2 datapoints in region "); - } - - @Override - protected TypeToken> contextType() { - return CloudWatchApiMetadata.CONTEXT_TOKEN; - } - -} diff --git a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchAsyncApiTest.java b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchAsyncApiTest.java deleted file mode 100644 index a8d92d7e89..0000000000 --- a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchAsyncApiTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.cloudwatch; - -import static com.google.common.collect.Maps.transformValues; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.lang.reflect.Method; -import java.net.URI; -import java.util.Date; -import java.util.Map; - -import org.jclouds.apis.ApiMetadata; -import org.jclouds.aws.domain.Region; -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.cloudwatch.config.CloudWatchRestClientModule; -import org.jclouds.cloudwatch.domain.Statistics; -import org.jclouds.cloudwatch.options.GetMetricStatisticsOptions; -import org.jclouds.cloudwatch.xml.GetMetricStatisticsResponseHandler; -import org.jclouds.date.DateService; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.location.config.LocationModule; -import org.jclouds.location.suppliers.RegionIdToURISupplier; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.internal.BaseAsyncApiTest; -import org.jclouds.util.Suppliers2; -import org.testng.annotations.Test; - -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableMap; -import com.google.inject.Module; - -/** - * Tests behavior of {@code CloudWatchAsyncApi} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during -// surefire -@Test(groups = "unit", testName = "CloudWatchAsyncApiTest") -@Deprecated -public class CloudWatchAsyncApiTest extends BaseAsyncApiTest { - - public void testRegisterInstancesWithMeasure() throws SecurityException, NoSuchMethodException, IOException { - Date date = new Date(10000000l); - Method method = CloudWatchAsyncApi.class.getMethod("getMetricStatisticsInRegion", String.class, String.class, - String.class, Date.class, Date.class, int.class, Statistics.class, GetMetricStatisticsOptions[].class); - HttpRequest request = processor.createRequest(method, (String) null, "CPUUtilization", "AWS/EC2", date, date, 60, - Statistics.AVERAGE, GetMetricStatisticsOptions.Builder.instanceId("i-12312313")); - - assertRequestLineEquals(request, "POST https://monitoring.us-east-1.amazonaws.com/ HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Host: monitoring.us-east-1.amazonaws.com\n"); - assertPayloadEquals( - request, - "Action=GetMetricStatistics&Statistics.member.1=Average&Period=60&Namespace=AWS/EC2&MetricName=CPUUtilization&StartTime=1970-01-01T02%3A46%3A40Z&EndTime=1970-01-01T02%3A46%3A40Z&Dimensions.member.1.Name=InstanceId&Dimensions.member.1.Value=i-12312313", - "application/x-www-form-urlencoded", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, GetMetricStatisticsResponseHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - - @ConfiguresRestClient - private static final class TestMonitoringRestClientModule extends CloudWatchRestClientModule { - - @Override - protected void installLocations() { - install(new LocationModule()); - bind(RegionIdToURISupplier.class).toInstance(new RegionIdToURISupplier() { - - @Override - public Map> get() { - return transformValues(ImmutableMap. of(Region.EU_WEST_1, URI - .create("https://ec2.eu-west-1.amazonaws.com"), Region.US_EAST_1, URI - .create("https://ec2.us-east-1.amazonaws.com"), Region.US_WEST_1, URI - .create("https://ec2.us-west-1.amazonaws.com")), Suppliers2. ofInstanceFunction()); - } - - }); - } - - @Override - protected String provideTimeStamp(final DateService dateService) { - return "2009-11-08T15:54:08.897Z"; - } - } - - @Override - protected Module createModule() { - return new TestMonitoringRestClientModule(); - } - - @Override - public ApiMetadata createApiMetadata() { - return new CloudWatchApiMetadata(); - } - - @Override - protected void checkFilters(HttpRequest request) { - assertEquals(request.getFilters().size(), 1); - assertEquals(request.getFilters().get(0).getClass(), FormSigner.class); - } - - -} diff --git a/providers/aws-cloudwatch/src/test/java/org/jclouds/aws/cloudwatch/AWSCloudWatchApiLiveTest.java b/providers/aws-cloudwatch/src/test/java/org/jclouds/aws/cloudwatch/AWSCloudWatchApiLiveTest.java deleted file mode 100644 index ebcb2feb55..0000000000 --- a/providers/aws-cloudwatch/src/test/java/org/jclouds/aws/cloudwatch/AWSCloudWatchApiLiveTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.aws.cloudwatch; - -import org.jclouds.aws.domain.Region; -import org.jclouds.cloudwatch.CloudWatchApiLiveTest; -import org.testng.annotations.Test; - -/** - * Tests behavior of {@code CloudWatchApi} - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "AWSCloudWatchApiLiveTest") -public class AWSCloudWatchApiLiveTest extends CloudWatchApiLiveTest { - public AWSCloudWatchApiLiveTest() { - provider = "aws-cloudwatch"; - } - - @Test - public void testGetMetricStatisticsInRegion() { - for (String region : Region.DEFAULT_REGIONS) { - getEC2MetricStatisticsInRegion(region); - } - } -}