use of org.apache.nifi.controller.status.history.StandardStatusSnapshot in project nifi by apache.
the class StatusHistoryEndpointMerger method createSnapshot.
private StatusSnapshot createSnapshot(final StatusSnapshotDTO snapshotDto, final Map<String, MetricDescriptor<?>> metricDescriptors) {
final StandardStatusSnapshot snapshot = new StandardStatusSnapshot();
snapshot.setTimestamp(snapshotDto.getTimestamp());
// of missing all together.
for (final MetricDescriptor<?> descriptor : metricDescriptors.values()) {
snapshot.addStatusMetric(descriptor, 0L);
// If the DTO doesn't have an entry for the metric, add with a value of 0.
final Map<String, Long> dtoMetrics = snapshotDto.getStatusMetrics();
final String field = descriptor.getField();
if (!dtoMetrics.containsKey(field)) {
dtoMetrics.put(field, 0L);
}
}
final Map<String, Long> metrics = snapshotDto.getStatusMetrics();
for (final Map.Entry<String, Long> entry : metrics.entrySet()) {
final String metricId = entry.getKey();
final Long value = entry.getValue();
final MetricDescriptor<?> descriptor = metricDescriptors.get(metricId);
if (descriptor != null) {
snapshot.addStatusMetric(descriptor, value);
}
}
return snapshot;
}
Aggregations