mirror of
https://github.com/apache/nifi.git
synced 2025-03-04 08:29:55 +00:00
NIFI-5630: Ensure that we include counters in Status History when present
Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com> This closes #3026.
This commit is contained in:
parent
c4d3b5e94f
commit
4b4c9e14cb
@ -30,6 +30,7 @@ public class StandardStatusSnapshot implements StatusSnapshot {
|
||||
|
||||
private Map<MetricDescriptor<?>, Long> counterValues = null;
|
||||
private Date timestamp = new Date();
|
||||
private Set<MetricDescriptor<?>> metricDescriptorsWithCounters = null;
|
||||
|
||||
|
||||
public StandardStatusSnapshot(final Set<MetricDescriptor<?>> metricDescriptors) {
|
||||
@ -49,7 +50,17 @@ public class StandardStatusSnapshot implements StatusSnapshot {
|
||||
|
||||
@Override
|
||||
public Set<MetricDescriptor<?>> getMetricDescriptors() {
|
||||
return metricDescriptors;
|
||||
if (counterValues == null || counterValues.isEmpty()) {
|
||||
return metricDescriptors;
|
||||
} else {
|
||||
if (metricDescriptorsWithCounters == null) {
|
||||
metricDescriptorsWithCounters = new LinkedHashSet<>();
|
||||
metricDescriptorsWithCounters.addAll(metricDescriptors);
|
||||
metricDescriptorsWithCounters.addAll(counterValues.keySet());
|
||||
}
|
||||
|
||||
return metricDescriptorsWithCounters;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -75,7 +86,7 @@ public class StandardStatusSnapshot implements StatusSnapshot {
|
||||
}
|
||||
|
||||
public StandardStatusSnapshot withoutCounters() {
|
||||
if (counterValues == null) {
|
||||
if (counterValues == null || counterValues.isEmpty()) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -90,7 +101,7 @@ public class StandardStatusSnapshot implements StatusSnapshot {
|
||||
@Override
|
||||
public StatusSnapshot reduce(final List<StatusSnapshot> values) {
|
||||
Date reducedTimestamp = null;
|
||||
final Set<MetricDescriptor<?>> allDescriptors = new LinkedHashSet<>(metricDescriptors);
|
||||
final Set<MetricDescriptor<?>> allDescriptors = new LinkedHashSet<>(getMetricDescriptors());
|
||||
|
||||
for (final StatusSnapshot statusSnapshot : values) {
|
||||
if (reducedTimestamp == null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user