mirror of https://github.com/apache/nifi.git
NIFI-9400: Ensure that we always use the CollectionUsage metrics in the mbeans instead of the Usage metrics.
Signed-off-by: Joe Gresock <jgresock@gmail.com> This closes #5798.
This commit is contained in:
parent
9d3788ff05
commit
0d0912d34b
|
@ -98,7 +98,7 @@ public class MonitorMemory extends AbstractReportingTask {
|
||||||
// Only allow memory pool beans that support usage thresholds, otherwise we wouldn't report anything anyway
|
// Only allow memory pool beans that support usage thresholds, otherwise we wouldn't report anything anyway
|
||||||
memPoolAllowableValues = ManagementFactory.getMemoryPoolMXBeans()
|
memPoolAllowableValues = ManagementFactory.getMemoryPoolMXBeans()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(MemoryPoolMXBean::isUsageThresholdSupported)
|
.filter(MemoryPoolMXBean::isCollectionUsageThresholdSupported)
|
||||||
.map(MemoryPoolMXBean::getName)
|
.map(MemoryPoolMXBean::getName)
|
||||||
.map(AllowableValue::new)
|
.map(AllowableValue::new)
|
||||||
.toArray(AllowableValue[]::new);
|
.toArray(AllowableValue[]::new);
|
||||||
|
@ -188,10 +188,11 @@ public class MonitorMemory extends AbstractReportingTask {
|
||||||
} else {
|
} else {
|
||||||
final String percentage = thresholdValue.substring(0, thresholdValue.length() - 1);
|
final String percentage = thresholdValue.substring(0, thresholdValue.length() - 1);
|
||||||
final double pct = Double.parseDouble(percentage) / 100D;
|
final double pct = Double.parseDouble(percentage) / 100D;
|
||||||
calculatedThreshold = (long) (monitoredBean.getUsage().getMax() * pct);
|
calculatedThreshold = (long) (monitoredBean.getCollectionUsage().getMax() * pct);
|
||||||
}
|
}
|
||||||
if (monitoredBean.isUsageThresholdSupported()) {
|
|
||||||
monitoredBean.setUsageThreshold(calculatedThreshold);
|
if (monitoredBean.isCollectionUsageThresholdSupported()) {
|
||||||
|
monitoredBean.setCollectionUsageThreshold(calculatedThreshold);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,7 +210,7 @@ public class MonitorMemory extends AbstractReportingTask {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final MemoryUsage usage = bean.getUsage();
|
final MemoryUsage usage = bean.getCollectionUsage();
|
||||||
if (usage == null) {
|
if (usage == null) {
|
||||||
getLogger().warn("{} could not determine memory usage for pool with name {}", new Object[] {this,
|
getLogger().warn("{} could not determine memory usage for pool with name {}", new Object[] {this,
|
||||||
context.getProperty(MEMORY_POOL_PROPERTY)});
|
context.getProperty(MEMORY_POOL_PROPERTY)});
|
||||||
|
@ -217,7 +218,7 @@ public class MonitorMemory extends AbstractReportingTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
final double percentageUsed = (double) usage.getUsed() / (double) usage.getMax() * 100D;
|
final double percentageUsed = (double) usage.getUsed() / (double) usage.getMax() * 100D;
|
||||||
if (bean.isUsageThresholdSupported() && bean.isUsageThresholdExceeded()) {
|
if (bean.isCollectionUsageThresholdSupported() && bean.isCollectionUsageThresholdExceeded()) {
|
||||||
if (System.currentTimeMillis() < reportingIntervalMillis + lastReportTime && lastReportTime > 0L) {
|
if (System.currentTimeMillis() < reportingIntervalMillis + lastReportTime && lastReportTime > 0L) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue