use of io.gravitee.repository.healthcheck.query.Bucket in project gravitee-management-rest-api by gravitee-io.
the class HealthCheckServiceImpl method convert.
private HistogramAnalytics convert(DateHistogramResponse histogramResponse) {
final HistogramAnalytics analytics = new HistogramAnalytics();
final List<Long> timestamps = histogramResponse.timestamps();
if (timestamps != null && timestamps.size() > 1) {
final long from = timestamps.get(0);
final long interval = timestamps.get(1) - from;
final long to = timestamps.get(timestamps.size() - 1);
analytics.setTimestamp(new Timestamp(from, to, interval));
List<io.gravitee.management.model.analytics.Bucket> buckets = new ArrayList<>(histogramResponse.values().size());
for (io.gravitee.repository.analytics.query.response.histogram.Bucket bucket : histogramResponse.values()) {
io.gravitee.management.model.analytics.Bucket analyticsBucket = convertBucket(histogramResponse.timestamps(), from, interval, bucket);
buckets.add(analyticsBucket);
}
analytics.setValues(buckets);
}
return analytics;
}
use of io.gravitee.repository.healthcheck.query.Bucket in project gravitee-management-rest-api by gravitee-io.
the class HealthCheckServiceImpl method convertBucket.
private io.gravitee.management.model.analytics.Bucket convertBucket(List<Long> timestamps, long from, long interval, io.gravitee.repository.analytics.query.response.histogram.Bucket bucket) {
io.gravitee.management.model.analytics.Bucket analyticsBucket = new io.gravitee.management.model.analytics.Bucket();
analyticsBucket.setName(bucket.name());
analyticsBucket.setField(bucket.field());
List<io.gravitee.management.model.analytics.Bucket> childBuckets = new ArrayList<>();
for (io.gravitee.repository.analytics.query.response.histogram.Bucket childBucket : bucket.buckets()) {
childBuckets.add(convertBucket(timestamps, from, interval, childBucket));
}
for (Map.Entry<String, List<Data>> dataBucket : bucket.data().entrySet()) {
io.gravitee.management.model.analytics.Bucket analyticsDataBucket = new io.gravitee.management.model.analytics.Bucket();
analyticsDataBucket.setName(dataBucket.getKey());
final Number[] values = new Number[timestamps.size()];
for (int i = 0; i < timestamps.size(); i++) {
values[i] = 0;
}
for (Data data : dataBucket.getValue()) {
values[(int) ((data.timestamp() - from) / interval)] = data.value();
}
analyticsDataBucket.setData(values);
childBuckets.add(analyticsDataBucket);
}
analyticsBucket.setBuckets(childBuckets);
return analyticsBucket;
}
use of io.gravitee.repository.healthcheck.query.Bucket in project gravitee-management-rest-api by gravitee-io.
the class HealthCheckServiceImpl method convertBucket.
private io.gravitee.rest.api.model.analytics.Bucket convertBucket(List<Long> timestamps, long from, long interval, io.gravitee.repository.analytics.query.response.histogram.Bucket bucket) {
io.gravitee.rest.api.model.analytics.Bucket analyticsBucket = new io.gravitee.rest.api.model.analytics.Bucket();
analyticsBucket.setName(bucket.name());
analyticsBucket.setField(bucket.field());
List<io.gravitee.rest.api.model.analytics.Bucket> childBuckets = new ArrayList<>();
for (io.gravitee.repository.analytics.query.response.histogram.Bucket childBucket : bucket.buckets()) {
childBuckets.add(convertBucket(timestamps, from, interval, childBucket));
}
for (Map.Entry<String, List<Data>> dataBucket : bucket.data().entrySet()) {
io.gravitee.rest.api.model.analytics.Bucket analyticsDataBucket = new io.gravitee.rest.api.model.analytics.Bucket();
analyticsDataBucket.setName(dataBucket.getKey());
final Number[] values = new Number[timestamps.size()];
for (int i = 0; i < timestamps.size(); i++) {
values[i] = 0;
}
for (Data data : dataBucket.getValue()) {
values[(int) ((data.timestamp() - from) / interval)] = data.value();
}
analyticsDataBucket.setData(values);
childBuckets.add(analyticsDataBucket);
}
analyticsBucket.setBuckets(childBuckets);
return analyticsBucket;
}
use of io.gravitee.repository.healthcheck.query.Bucket in project gravitee-management-rest-api by gravitee-io.
the class HealthCheckServiceImpl method convert.
private HistogramAnalytics convert(DateHistogramResponse histogramResponse) {
final HistogramAnalytics analytics = new HistogramAnalytics();
final List<Long> timestamps = histogramResponse.timestamps();
if (timestamps != null && timestamps.size() > 1) {
final long from = timestamps.get(0);
final long interval = timestamps.get(1) - from;
final long to = timestamps.get(timestamps.size() - 1);
analytics.setTimestamp(new Timestamp(from, to, interval));
List<io.gravitee.rest.api.model.analytics.Bucket> buckets = new ArrayList<>(histogramResponse.values().size());
for (io.gravitee.repository.analytics.query.response.histogram.Bucket bucket : histogramResponse.values()) {
io.gravitee.rest.api.model.analytics.Bucket analyticsBucket = convertBucket(histogramResponse.timestamps(), from, interval, bucket);
buckets.add(analyticsBucket);
}
analytics.setValues(buckets);
}
return analytics;
}
Aggregations