Search in sources :

Example 1 with Bucket

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;
}
Also used : Timestamp(io.gravitee.management.model.analytics.Timestamp) FieldBucket(io.gravitee.repository.healthcheck.query.FieldBucket) Bucket(io.gravitee.repository.healthcheck.query.Bucket) HistogramAnalytics(io.gravitee.management.model.analytics.HistogramAnalytics)

Example 2 with Bucket

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;
}
Also used : Data(io.gravitee.repository.analytics.query.response.histogram.Data) Endpoint(io.gravitee.definition.model.Endpoint) FieldBucket(io.gravitee.repository.healthcheck.query.FieldBucket) Bucket(io.gravitee.repository.healthcheck.query.Bucket)

Example 3 with Bucket

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;
}
Also used : Data(io.gravitee.repository.analytics.query.response.histogram.Data) Endpoint(io.gravitee.definition.model.Endpoint) FieldBucket(io.gravitee.repository.healthcheck.query.FieldBucket) Bucket(io.gravitee.repository.healthcheck.query.Bucket)

Example 4 with Bucket

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;
}
Also used : Timestamp(io.gravitee.rest.api.model.analytics.Timestamp) FieldBucket(io.gravitee.repository.healthcheck.query.FieldBucket) Bucket(io.gravitee.repository.healthcheck.query.Bucket) HistogramAnalytics(io.gravitee.rest.api.model.analytics.HistogramAnalytics)

Aggregations

Bucket (io.gravitee.repository.healthcheck.query.Bucket)4 FieldBucket (io.gravitee.repository.healthcheck.query.FieldBucket)4 Endpoint (io.gravitee.definition.model.Endpoint)2 Data (io.gravitee.repository.analytics.query.response.histogram.Data)2 HistogramAnalytics (io.gravitee.management.model.analytics.HistogramAnalytics)1 Timestamp (io.gravitee.management.model.analytics.Timestamp)1 HistogramAnalytics (io.gravitee.rest.api.model.analytics.HistogramAnalytics)1 Timestamp (io.gravitee.rest.api.model.analytics.Timestamp)1