You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/10/15 11:39:04 UTC
[GitHub] [flink] XComp commented on a change in pull request #13640: [FLINK-19617] Added new metric for monitoring the JVM's Metaspace memory pool usage.
XComp commented on a change in pull request #13640:
URL: https://github.com/apache/flink/pull/13640#discussion_r505472376
##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/metrics/util/MetricUtils.java
##########
@@ -214,6 +219,29 @@ static void instantiateNonHeapMemoryMetrics(final MetricGroup metricGroup) {
instantiateMemoryUsageMetrics(metricGroup, () -> ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage());
}
+ @VisibleForTesting
+ static void instantiateMetaspaceMemoryMetrics(final MetricGroup parentMetricGroup) {
+ final List<MemoryPoolMXBean> memoryPoolMXBeans = ManagementFactory.getMemoryPoolMXBeans()
+ .stream()
+ .filter(bean -> "Metaspace".equals(bean.getName()))
+ .collect(Collectors.toList());
+
+ if (memoryPoolMXBeans.isEmpty()) {
+ LOG.warn("No memory pool named 'Metaspace' is present. The '{}' metric group is not going to be instantiated.", METRIC_GROUP_METASPACE_NAME);
+ return;
+ }
+
+ final MetricGroup metricGroup = parentMetricGroup.addGroup(METRIC_GROUP_METASPACE_NAME);
+ final Iterator<MemoryPoolMXBean> beanIterator = memoryPoolMXBeans.iterator();
+
+ final MemoryPoolMXBean firstPool = beanIterator.next();
+ instantiateMemoryUsageMetrics(metricGroup, firstPool::getUsage);
+
+ if (beanIterator.hasNext()) {
+ LOG.warn("More than one memory pool named '{}' are present. Only the first pool was used for instantiating the metric.", METRIC_GROUP_METASPACE_NAME);
Review comment:
Yup, I bet it's quite theoretical. I just felt a bit uneasy about ignoring this one.
The pool name issue was actually not what I intended and, therefore, a "bug". Thanks for pointing that out.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org