use of io.gravitee.repository.analytics.query.response.histogram.Data 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.analytics.query.response.histogram.Data in project gravitee-management-rest-api by gravitee-io.
the class AnalyticsServiceImpl method convertBucket.
private Bucket convertBucket(List<Long> timestamps, long from, long interval, io.gravitee.repository.analytics.query.response.histogram.Bucket bucket) {
Bucket analyticsBucket = new Bucket();
analyticsBucket.setName(bucket.name());
analyticsBucket.setField(bucket.field());
List<Bucket> childBuckets = new ArrayList<>();
for (io.gravitee.repository.analytics.query.response.histogram.Bucket childBucket : bucket.buckets()) {
childBuckets.add(convertBucket(timestamps, from, interval, childBucket));
}
if (analyticsBucket.getField().equals("application")) {
// Prepare metadata
Map<String, Map<String, String>> metadata = new HashMap<>();
bucket.data().keySet().stream().forEach(app -> {
metadata.put(app, getApplicationMetadata(app));
});
analyticsBucket.setMetadata(metadata);
} else if (analyticsBucket.getField().equals("api")) {
// Prepare metadata
Map<String, Map<String, String>> metadata = new HashMap<>();
bucket.data().keySet().stream().forEach(api -> {
metadata.put(api, getAPIMetadata(api));
});
analyticsBucket.setMetadata(metadata);
} else if (analyticsBucket.getField().equals("tenant")) {
// Prepare metadata
Map<String, Map<String, String>> metadata = new HashMap<>();
bucket.data().keySet().stream().forEach(tenant -> {
metadata.put(tenant, getTenantMetadata(tenant));
});
analyticsBucket.setMetadata(metadata);
}
for (Map.Entry<String, List<Data>> dataBucket : bucket.data().entrySet()) {
Bucket analyticsDataBucket = new Bucket();
analyticsDataBucket.setName(dataBucket.getKey());
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.analytics.query.response.histogram.Data in project gravitee-management-rest-api by gravitee-io.
the class AnalyticsServiceImpl method convertBucket.
private Bucket convertBucket(List<Long> timestamps, long from, long interval, io.gravitee.repository.analytics.query.response.histogram.Bucket bucket) {
Bucket analyticsBucket = new Bucket();
analyticsBucket.setName(bucket.name());
analyticsBucket.setField(bucket.field());
List<Bucket> childBuckets = new ArrayList<>();
for (io.gravitee.repository.analytics.query.response.histogram.Bucket childBucket : bucket.buckets()) {
childBuckets.add(convertBucket(timestamps, from, interval, childBucket));
}
if (FIELD_APPLICATION.equals(analyticsBucket.getField())) {
// Prepare metadata
Map<String, Map<String, String>> metadata = new HashMap<>();
bucket.data().keySet().forEach(app -> metadata.put(app, getApplicationMetadata(app)));
analyticsBucket.setMetadata(metadata);
} else if (FIELD_API.equals(analyticsBucket.getField())) {
// Prepare metadata
Map<String, Map<String, String>> metadata = new HashMap<>();
bucket.data().keySet().forEach(api -> metadata.put(api, getAPIMetadata(api)));
analyticsBucket.setMetadata(metadata);
} else if (FIELD_TENANT.equals(analyticsBucket.getField())) {
// Prepare metadata
Map<String, Map<String, String>> metadata = new HashMap<>();
bucket.data().keySet().forEach(tenant -> metadata.put(tenant, getTenantMetadata(tenant)));
analyticsBucket.setMetadata(metadata);
}
for (Map.Entry<String, List<Data>> dataBucket : bucket.data().entrySet()) {
Bucket analyticsDataBucket = new Bucket();
analyticsDataBucket.setName(dataBucket.getKey());
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.analytics.query.response.histogram.Data 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;
}
Aggregations