NIFI-9222 allow ControllerStatusReportingTask to log details even when there are no Counters present on Processors (#5573)

This commit is contained in:
Chris Sampson 2022-01-05 21:28:12 +00:00 committed by GitHub
parent d783e10e68
commit b0b1a57b98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 17 deletions

View File

@ -204,27 +204,29 @@ public class ControllerStatusReportingTask extends AbstractReportingTask {
for (final ProcessorStatus processorStatus : processorStatuses) {
final Map<String, Long> counters = processorStatus.getCounters();
for (final Map.Entry<String, Long> entry : counters.entrySet()) {
final String counterName = entry.getKey();
final Long counterValue = entry.getValue() / divisor;
if (counters != null && !counters.isEmpty()){
for (final Map.Entry<String, Long> entry : counters.entrySet()) {
final String counterName = entry.getKey();
final Long counterValue = entry.getValue() / divisor;
final String counterId = processorStatus.getId() + "_" + counterName;
final Long lastValue = lastCounterValues.getOrDefault(counterId, 0L);
final String counterId = processorStatus.getId() + "_" + counterName;
final Long lastValue = lastCounterValues.getOrDefault(counterId, 0L);
lastCounterValues.put(counterId, counterValue);
lastCounterValues.put(counterId, counterValue);
if (showDeltas) {
final String diff = toDiff(lastValue, counterValue);
if (showDeltas) {
final String diff = toDiff(lastValue, counterValue);
builder.append(String.format(COUNTER_LINE_FORMAT,
processorStatus.getName() + "(" + processorStatus.getId() + ")",
counterName,
counterValue + diff));
} else {
builder.append(String.format(COUNTER_LINE_FORMAT,
processorStatus.getName() + "(" + processorStatus.getId() + ")",
counterName,
counterValue));
builder.append(String.format(COUNTER_LINE_FORMAT,
processorStatus.getName() + "(" + processorStatus.getId() + ")",
counterName,
counterValue + diff));
} else {
builder.append(String.format(COUNTER_LINE_FORMAT,
processorStatus.getName() + "(" + processorStatus.getId() + ")",
counterName,
counterValue));
}
}
}
}