From commits-return-44753-archive-asf-public=cust-asf.ponee.io@nifi.apache.org Fri Jun 11 12:08:22 2021 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mxout1-he-de.apache.org (mxout1-he-de.apache.org [95.216.194.37]) by mx-eu-01.ponee.io (Postfix) with ESMTPS id 87487180654 for ; Fri, 11 Jun 2021 14:08:22 +0200 (CEST) Received: from mail.apache.org (mailroute1-lw-us.apache.org [207.244.88.153]) by mxout1-he-de.apache.org (ASF Mail Server at mxout1-he-de.apache.org) with SMTP id 02EA86013B for ; Fri, 11 Jun 2021 12:08:21 +0000 (UTC) Received: (qmail 84752 invoked by uid 500); 11 Jun 2021 12:08:21 -0000 Mailing-List: contact commits-help@nifi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@nifi.apache.org Delivered-To: mailing list commits@nifi.apache.org Received: (qmail 84739 invoked by uid 99); 11 Jun 2021 12:08:21 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Jun 2021 12:08:21 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 21D4081A86; Fri, 11 Jun 2021 12:08:21 +0000 (UTC) Date: Fri, 11 Jun 2021 12:08:20 +0000 To: "commits@nifi.apache.org" Subject: [nifi] branch main updated: NIFI-8642 Select the default Old Gen Memory Pool for Memory Reporting Task MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <162341330042.18056.17990651794534773406@gitbox.apache.org> From: tpalfy@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: nifi X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Oldrev: 5c91143dc2f77d3656ff29f7a31fb341ded1cf76 X-Git-Newrev: d7a8d275c96040627dd357fa76ba4a8276df8682 X-Git-Rev: d7a8d275c96040627dd357fa76ba4a8276df8682 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. tpalfy pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/nifi.git The following commit(s) were added to refs/heads/main by this push: new d7a8d27 NIFI-8642 Select the default Old Gen Memory Pool for Memory Reporting Task d7a8d27 is described below commit d7a8d275c96040627dd357fa76ba4a8276df8682 Author: Timea Barna AuthorDate: Wed Jun 2 08:52:48 2021 +0200 NIFI-8642 Select the default Old Gen Memory Pool for Memory Reporting Task This closes #5115. Signed-off-by: Tamas Palfy --- .../org/apache/nifi/controller/MonitorMemory.java | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/main/java/org/apache/nifi/controller/MonitorMemory.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/main/java/org/apache/nifi/controller/MonitorMemory.java index c611375..6bfd8e6 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/main/java/org/apache/nifi/controller/MonitorMemory.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/main/java/org/apache/nifi/controller/MonitorMemory.java @@ -36,11 +36,11 @@ import java.lang.management.ManagementFactory; import java.lang.management.MemoryPoolMXBean; import java.lang.management.MemoryUsage; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.concurrent.TimeUnit; import java.util.regex.Pattern; -import java.util.stream.Collectors; /** * Reporting task used to monitor usage of memory after Garbage Collection has @@ -90,15 +90,23 @@ import java.util.stream.Collectors; + " that the memory pool is exceeding this threshold.") public class MonitorMemory extends AbstractReportingTask { + private static final List GC_OLD_GEN_POOLS = Collections.unmodifiableList(Arrays.asList("Tenured Gen", "PS Old Gen", "G1 Old Gen", "CMS Old Gen", "ZHeap")); private static final AllowableValue[] memPoolAllowableValues; + private static String defaultMemoryPool; static { // Only allow memory pool beans that support usage thresholds, otherwise we wouldn't report anything anyway - List memoryPoolBeans = ManagementFactory.getMemoryPoolMXBeans().stream().filter(MemoryPoolMXBean::isUsageThresholdSupported).collect(Collectors.toList()); - memPoolAllowableValues = new AllowableValue[memoryPoolBeans.size()]; - for (int i = 0; i < memPoolAllowableValues.length; i++) { - memPoolAllowableValues[i] = new AllowableValue(memoryPoolBeans.get(i).getName()); - } + memPoolAllowableValues = ManagementFactory.getMemoryPoolMXBeans() + .stream() + .filter(MemoryPoolMXBean::isUsageThresholdSupported) + .map(MemoryPoolMXBean::getName) + .map(AllowableValue::new) + .toArray(AllowableValue[]::new); + defaultMemoryPool = Arrays.stream(memPoolAllowableValues) + .map(AllowableValue::getValue) + .filter(GC_OLD_GEN_POOLS::contains) + .findFirst() + .orElse(null); } public static final PropertyDescriptor MEMORY_POOL_PROPERTY = new PropertyDescriptor.Builder() @@ -110,6 +118,7 @@ public class MonitorMemory extends AbstractReportingTask { + " running host platform and JVM") .required(true) .allowableValues(memPoolAllowableValues) + .defaultValue(defaultMemoryPool) .build(); public static final PropertyDescriptor THRESHOLD_PROPERTY = new PropertyDescriptor.Builder() .name("Usage Threshold")