Skip to content

Commit

Permalink
Split numeric metric methods into a separate handler and adjust the e…
Browse files Browse the repository at this point in the history
…nd-point urls, tests, and ptrans.
  • Loading branch information
Stefan Negrea committed Apr 20, 2015
1 parent 5ce9f15 commit 9ccbfd7
Show file tree
Hide file tree
Showing 13 changed files with 485 additions and 83 deletions.
18 changes: 9 additions & 9 deletions api/metrics-api-jaxrs/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Returns a list of tenants. Notice that the second object does not include a

*Request URI*

POST /hawkular-metrics/{tenantId}/metrics/numeric
POST /hawkular-metrics/{tenantId}/numeric

*Request Body*

Expand All @@ -119,7 +119,7 @@ POST /hawkular-metrics/{tenantId}/metrics/numeric
*Example Request*

----
curl http://localhost:8080/hawkular-metrics/{tenantId}/metrics/numeric -d@request.json -HContent-Type:application/json
curl http://localhost:8080/hawkular-metrics/{tenantId}/numeric -d@request.json -HContent-Type:application/json
----

*Description*
Expand Down Expand Up @@ -216,7 +216,7 @@ PUT /hawkular-metrics/{tenantId}/numeric/{id}/meta
*Example Request*

----
curl -X PUT http://localhost:8080/hawkular-metrics/{tenantId}/metrics/numeric -d@request.json -HContent-Type:application/json
curl -X PUT http://localhost:8080/hawkular-metrics/{tenantId}/numeric -d@request.json -HContent-Type:application/json
----

*Description*
Expand All @@ -230,7 +230,7 @@ either created or overwritten.

*Request URI*

POST /hawkular-metrics/{tenantId}/metrics/numeric/{id}/data
POST /hawkular-metrics/{tenantId}/numeric/{id}/data

*Request Body*

Expand All @@ -246,7 +246,7 @@ POST /hawkular-metrics/{tenantId}/metrics/numeric/{id}/data
*Example Request*

----
curl -X POST http://localhost:8080/hawkular-metrics/{tenantId}/metrics/numeric/{id}/data -d@request.json -HContent-Type:application/json
curl -X POST http://localhost:8080/hawkular-metrics/{tenantId}/numeric/{id}/data -d@request.json -HContent-Type:application/json
----

*Description*
Expand Down Expand Up @@ -285,7 +285,7 @@ Inserts data for a single availablity metric. Accepted values are the strings

*Request URI*

POST /hawkular-metrics/{tenantId}/metrics/numeric/data
POST /hawkular-metrics/{tenantId}/numeric/data

*Request Body*

Expand All @@ -312,7 +312,7 @@ POST /hawkular-metrics/{tenantId}/metrics/numeric/data
*Example Request*

----
curl -X POST http://localhost:8080/hawkular-metrics/{tenantId}/metrics/numeric/data -d@request.json -HContent-Type:application/json
curl -X POST http://localhost:8080/hawkular-metrics/{tenantId}/numeric/data -d@request.json -HContent-Type:application/json
----

*Description*
Expand Down Expand Up @@ -361,7 +361,7 @@ Insert data for multiple availability metrics.

*Request URI*

GET /hawkular-metrics/{tenantId}/metrics/numeric/{id}/data
GET /hawkular-metrics/{tenantId}/numeric/{id}/data

*Request Parameters*

Expand All @@ -384,7 +384,7 @@ start and end times, having max/min/avg calculated for each bucket.
*Example Request*

----
curl http://localhost:8080/hawkular-metrics/{tenantId}/metrics/numeric/{id}/data?start=1416857688195&end=1416857688195 -d@request.json -HContent-Type:application/json
curl http://localhost:8080/hawkular-metrics/{tenantId}/numeric/{id}/data?start=1416857688195&end=1416857688195 -d@request.json -HContent-Type:application/json
----

*Response Body*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

import static java.util.concurrent.TimeUnit.HOURS;
import static java.util.concurrent.TimeUnit.MILLISECONDS;

import static javax.ws.rs.core.MediaType.APPLICATION_JSON;

import static org.hawkular.metrics.api.jaxrs.util.ApiUtils.badRequest;
import static org.hawkular.metrics.api.jaxrs.util.ApiUtils.executeAsync;
import static org.hawkular.metrics.core.api.MetricsService.DEFAULT_TENANT_ID;
Expand Down Expand Up @@ -80,6 +82,7 @@
import org.hawkular.metrics.core.api.NumericMetric;
import org.hawkular.metrics.core.impl.request.TagRequest;


/**
* Interface to deal with metrics
* @author Heiko W. Rupp
Expand Down Expand Up @@ -597,9 +600,7 @@ public void findAvailabilityData(
@ApiParam(value = "Defaults to now - 8 hours") @QueryParam("start") final Long start,
@ApiParam(value = "Defaults to now") @QueryParam("end") final Long end,
@ApiParam(value = "Total number of buckets") @QueryParam("buckets") Integer bucketsCount,
@ApiParam(value = "Bucket duration") @QueryParam("bucketDuration") Duration bucketDuration,
@ApiParam(value = "Set to true to return only distinct, contiguous values")
@QueryParam("distinct") Boolean distinct
@ApiParam(value = "Bucket duration") @QueryParam("bucketDuration") Duration bucketDuration
) {
executeAsync(
asyncResponse, () -> {
Expand All @@ -608,17 +609,13 @@ public void findAvailabilityData(
Long endTime = end == null ? now : end;

AvailabilityMetric metric = new AvailabilityMetric(tenantId, new MetricId(id));
ListenableFuture<List<Availability>> queryFuture;

if (distinct != null && distinct.equals(Boolean.TRUE)) {
queryFuture = metricsService.findAvailabilityData(tenantId, metric.getId(), startTime,
endTime, distinct);
return Futures.transform(queryFuture, ApiUtils.MAP_COLLECTION);
}

if (bucketsCount == null && bucketDuration == null) {
queryFuture = metricsService.findAvailabilityData(tenantId, metric.getId(), startTime, endTime);
return Futures.transform(queryFuture, ApiUtils.MAP_COLLECTION);
ListenableFuture<List<Availability>> dataFuture = metricsService.findAvailabilityData(
tenantId,
metric.getId(), startTime, endTime
);
return Futures.transform(dataFuture, ApiUtils.MAP_COLLECTION);
}

if (bucketsCount != null && bucketDuration != null) {
Expand Down

0 comments on commit 9ccbfd7

Please sign in to comment.