mirror of https://github.com/apache/jclouds.git
removed deprecated cloudwatch method
This commit is contained in:
parent
0b6b980adb
commit
8121444f04
|
@ -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
|
||||
* <p/>
|
||||
|
@ -49,48 +46,6 @@ public interface CloudWatchApi {
|
|||
@Region
|
||||
Set<String> getConfiguredRegions();
|
||||
|
||||
/**
|
||||
* This call returns data for one or more statistics of given a metric. For more information, see
|
||||
* Statistic and Metric.
|
||||
*
|
||||
* <p/>
|
||||
* <h3>Note</h3> 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.
|
||||
* <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
|
||||
* 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<Datapoint> getMetricStatisticsInRegion(@Nullable String region, String metricName, String namespace,
|
||||
Date startTime, Date endTime, int period, Statistics statistics, GetMetricStatisticsOptions... options);
|
||||
|
||||
/**
|
||||
* Provides synchronous access to Metric features.
|
||||
*/
|
||||
|
|
|
@ -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 {
|
||||
/**
|
||||
*
|
||||
|
@ -67,25 +47,6 @@ public interface CloudWatchAsyncApi {
|
|||
@Region
|
||||
Set<String> getConfiguredRegions();
|
||||
|
||||
/**
|
||||
* @see MetricAsyncApi#getMetricStatistics
|
||||
*/
|
||||
@Named("cloudwatch:GetMetricStatistics")
|
||||
@Deprecated
|
||||
@POST
|
||||
@Path("/")
|
||||
@XMLResponseParser(GetMetricStatisticsResponseHandler.class)
|
||||
@FormParams(keys = "Action", values = "GetMetricStatistics")
|
||||
ListenableFuture<? extends Set<Datapoint>> 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.
|
||||
*/
|
||||
|
|
|
@ -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<RestContext<CloudWatchApi, CloudWatchAsyncApi>> {
|
||||
public CloudWatchApiLiveTest() {
|
||||
provider = "cloudwatch";
|
||||
}
|
||||
|
||||
private CloudWatchApi api;
|
||||
|
||||
@Override
|
||||
@BeforeClass(groups = { "integration", "live" })
|
||||
public void setupContext() {
|
||||
super.setupContext();
|
||||
api = context.getApi();
|
||||
}
|
||||
|
||||
|
||||
protected Set<Datapoint> getEC2MetricStatisticsInRegion(String region) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(Calendar.MINUTE, -60 * 24 * 3); // 3 days
|
||||
|
||||
Set<Datapoint> 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<RestContext<CloudWatchApi, CloudWatchAsyncApi>> contextType() {
|
||||
return CloudWatchApiMetadata.CONTEXT_TOKEN;
|
||||
}
|
||||
|
||||
}
|
|
@ -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<CloudWatchAsyncApi> {
|
||||
|
||||
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<String, Supplier<URI>> get() {
|
||||
return transformValues(ImmutableMap.<String, URI> 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.<URI> 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);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue