Github user d2r commented on a diff in the pull request:
https://github.com/apache/storm/pull/921#discussion_r47793903
--- Diff:
storm-core/src/jvm/backtype/storm/scheduler/SupervisorDetails.java ---
@@ -119,10 +119,18 @@ private Double getTotalResource(String type) {
}
public Double getTotalMemory() {
- return getTotalResource(Config.SUPERVISOR_MEMORY_CAPACITY_MB);
+ Double totalMemory =
getTotalResource(Config.SUPERVISOR_MEMORY_CAPACITY_MB);
+ if (totalMemory == null) {
+ throw new IllegalStateException("default value for
supervisor.memory.capacity.mb is not set!");
+ }
+ return totalMemory;
}
public Double getTotalCPU() {
- return getTotalResource(Config.SUPERVISOR_CPU_CAPACITY);
+ Double totalCPU = getTotalResource(Config.SUPERVISOR_CPU_CAPACITY);
+ if (totalCPU == null) {
+ throw new IllegalStateException("default value for
supervisor.cpu.capacity is not set!");
+ }
+ return totalCPU;
--- End diff --
I just meant something like:
```Java
throw new IllegalStateException("default value for
"+Config.SUPERVISOR_CPU_CAPACITY+" is not set!");
```
However, as with the other logic that is checking for the mere presence of
an entry in defaults.yaml, this should really be a unit test. I think it would
be much better to move these kinds of checks into unit tests. Moving to a unit
test would simplify the code here by getting rid of unnecessary runtime checks
while still helping developers find when defaults are missing.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---