[GitHub] nifi pull request: NIFI-1690 Changed MonitorMemory to use allowabl...

2016-04-06 Thread joewitt
Github user joewitt commented on a diff in the pull request:

https://github.com/apache/nifi/pull/328#discussion_r58706787
  
--- Diff: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/main/java/org/apache/nifi/controller/MonitorMemory.java
 ---
@@ -91,12 +92,22 @@
 + " that the memory pool is exceeding this threshold.")
 public class MonitorMemory extends AbstractReportingTask {
 
+private static final AllowableValue[] memPoolAllowableValues;
+
+static {
+List memoryPoolBeans = 
ManagementFactory.getMemoryPoolMXBeans();
+memPoolAllowableValues = new 
AllowableValue[memoryPoolBeans.size()];
+for (int i = 0; i < memPoolAllowableValues.length; i++) {
+memPoolAllowableValues[i] = new 
AllowableValue(memoryPoolBeans.get(i).getName());
+}
+}
+
 public static final PropertyDescriptor MEMORY_POOL_PROPERTY = new 
PropertyDescriptor.Builder()
 .name("Memory Pool")
 .description("The name of the JVM Memory Pool to monitor")
 .required(true)
-.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
-.defaultValue(null)
+.allowableValues(memPoolAllowableValues)
+.defaultValue(memPoolAllowableValues.length == 0 ? null : 
memPoolAllowableValues[0].getValue())
--- End diff --

I think we're better off simply not having a default value.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] nifi pull request: NIFI-1690 Changed MonitorMemory to use allowabl...

2016-04-05 Thread olegz
GitHub user olegz opened a pull request:

https://github.com/apache/nifi/pull/328

NIFI-1690 Changed MonitorMemory to use allowable values for pool names

- removed dead code from MonitorMemory
- added MonitorMemoryTest
- minor refactoring in MonitorMemory
- initial fix for NIFI-1731 (WARN logging) that was required by 
MonitorMemoryTest

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/olegz/nifi NIFI-1690

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/nifi/pull/328.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #328


commit 837e17547c40005bf867ffccfd211d2a8ef8ffed
Author: Oleg Zhurakousky 
Date:   2016-04-05T18:24:46Z

NIFI-1690 Changed MonitorMemory to use allowable values for pool names
- removed dead code from MonitorMemory
- added MonitorMemoryTest
- minor refactoring in MonitorMemory
- initial fix for NIFI-1731 (WARN logging) that was required by 
MonitorMemoryTest




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---