Issue 695: Refactored getDailyCpuPerformanceStatistics into getPerformanceStatistics as it works for daily/hourly+memory/cpu

This commit is contained in:
Jason King 2011-12-08 12:01:09 +00:00
parent e4fdcbbeb1
commit f6c606e631
5 changed files with 38 additions and 18 deletions

View File

@ -123,11 +123,11 @@ public interface ResourceAsyncClient {
ListenableFuture<ComputePoolPerformanceStatistics> getComputePoolPerformanceStatistics(@EndpointParam URI uri);
/**
* @see ResourceClient#getDailyCpuPerformanceStatistics
* @see ResourceClient#getPerformanceStatistics
*/
@GET
@Consumes("application/vnd.tmrk.cloud.performanceStatistics")
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<PerformanceStatistics> getDailyCpuPerformanceStatistics(@EndpointParam URI uri);
ListenableFuture<PerformanceStatistics> getPerformanceStatistics(@EndpointParam URI uri);
}

View File

@ -155,18 +155,28 @@ public interface ResourceClient {
ComputePoolPerformanceStatistics getComputePoolPerformanceStatistics(URI uri);
/**
* The Get Resources Performance Statistics Processor Daily call returns daily
* information regarding processor performance for a specified compute pool
* The getPerformanceStatistics call returns information regarding performance for a specified compute pool.
* There are 2 time periods available: daily and hourly
* There is information for cpu (processor) and memory.
* To determine the correct URI to use, first call {@code getComputePoolPerformanceStatistics}
* then select the desired statistic from the result (e.g. hourly or daily then cpu or memory)
*
* returns statistics for the previous seven days.
* Daily statistics return results for the previous seven days.
*
* The default endTime is midnight the beginning of the current day and the default
* startTime is midnight seven days prior to the endTime.
* For example, if the call is made at 2011-07-12T14:48:00Z, then startTime is 2011-07-05T00:00:00Z
* and endTime is 2011-07-12T00:00:00Z.
* @param uri uri the uri of the call based upon the compute pool
* e.g. /cloudapi/ecloud/computepools/{id}/usage/cpu/performanceStatistics/daily
* @return
* The default endTime is midnight the beginning of the current day
* and the default startTime is midnight seven days prior to the endTime.
* For example, if the call is made at 2011-07-12T14:48:00Z,
* then startTime is 2011-07-05T00:00:00Z and endTime is 2011-07-12T00:00:00Z.
*
* Hourly statistics return results for the previous 24 hours
*
* The default endTime is the end of the hour prior to the current time
* and the default startTime is the beginning of the hour 24 hours prior to the endTime.
* For example, if the call is made at 2011-07- 12T14:48:00Z,
* then startTime is 2011-07-11T13:00:00Z and endTime is 2011-07-12T14:00:00Z.
*
* @param uri uri the uri of the call.
* @return the performance statistics for the desired period and metric
*/
PerformanceStatistics getDailyCpuPerformanceStatistics(URI uri);
PerformanceStatistics getPerformanceStatistics(URI uri);
}

View File

@ -158,8 +158,8 @@ public class ResourceAsyncClientTest extends BaseTerremarkEnterpriseCloudAsyncCl
checkFilters(httpRequest);
}
public void testGetDailyCpuPerformanceStatistics() throws SecurityException, NoSuchMethodException, IOException, URISyntaxException {
Method method = ResourceAsyncClient.class.getMethod("getDailyCpuPerformanceStatistics", URI.class);
public void testGetPerformanceStatistics() throws SecurityException, NoSuchMethodException, IOException, URISyntaxException {
Method method = ResourceAsyncClient.class.getMethod("getPerformanceStatistics", URI.class);
HttpRequest httpRequest = processor.createRequest(method, URI.create("/cloudapi/ecloud/computepools/89/usage/cpu/performancestatistics/daily"));
assertRequestLineEquals(httpRequest, "GET https://services-beta.enterprisecloud.terremark.com/cloudapi/ecloud/computepools/89/usage/cpu/performancestatistics/daily HTTP/1.1");

View File

@ -20,6 +20,7 @@ package org.jclouds.tmrk.enterprisecloud.features;
import org.jclouds.tmrk.enterprisecloud.domain.Link;
import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity;
import org.jclouds.tmrk.enterprisecloud.domain.resource.ComputePoolPerformanceStatistics;
import org.jclouds.tmrk.enterprisecloud.domain.resource.PerformanceStatistics;
import org.jclouds.tmrk.enterprisecloud.domain.resource.cpu.ComputePoolCpuUsage;
import org.jclouds.tmrk.enterprisecloud.domain.resource.ComputePoolResourceSummary;
@ -122,8 +123,17 @@ public class ResourceClientLiveTest extends BaseTerremarkEnterpriseCloudClientLi
assertNotNull(usage);
}
public void testGetDailyCpuPerformanceStatistics() throws Exception {
PerformanceStatistics stats = client.getDailyCpuPerformanceStatistics(URI.create("/cloudapi/ecloud/computepools/89/usage/cpu/performancestatistics/daily"));
public void testGetPerformanceStatistics() throws Exception {
ComputePoolPerformanceStatistics statistics = client.getComputePoolPerformanceStatistics(URI.create("/cloudapi/ecloud/computepools/89/performancestatistics"));
assertNotNull(statistics);
testPerformanceStatistic(statistics.getDaily().getCpu().getHref());
testPerformanceStatistic(statistics.getDaily().getMemory().getHref());
testPerformanceStatistic(statistics.getHourly().getCpu().getHref());
testPerformanceStatistic(statistics.getHourly().getMemory().getHref());
}
private void testPerformanceStatistic(URI uri) {
PerformanceStatistics stats = client.getPerformanceStatistics(uri);
assertNotNull(stats);
}
}

View File

@ -95,7 +95,7 @@ public class PerformanceStatisticsJAXBParsingTest extends BaseRestClientTest {
public void testParseWithJAXB() throws Exception {
Method method = ResourceAsyncClient.class.getMethod("getDailyCpuPerformanceStatistics", URI.class);
Method method = ResourceAsyncClient.class.getMethod("getPerformanceStatistics", URI.class);
HttpRequest request = factory(ResourceAsyncClient.class).createRequest(method,new URI("/1"));
assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);