Search in sources :

Example 1 with StandardStatusSnapshot

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;
}
Also used : StandardStatusSnapshot(org.apache.nifi.controller.status.history.StandardStatusSnapshot) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) TreeMap(java.util.TreeMap)

Aggregations

HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 StandardStatusSnapshot (org.apache.nifi.controller.status.history.StandardStatusSnapshot)1