Github user srdo commented on a diff in the pull request: https://github.com/apache/storm/pull/2764#discussion_r208722273 --- Diff: storm-server/src/main/java/org/apache/storm/daemon/nimbus/Nimbus.java --- @@ -2807,16 +2897,15 @@ public void launchServer() throws Exception { } }); - StormMetricsRegistry.registerGauge("nimbus:num-supervisors", () -> state.supervisors(null).size()); - StormMetricsRegistry.registerGauge("nimbus:fragmented-memory", this::fragmentedMemory); - StormMetricsRegistry.registerGauge("nimbus:fragmented-cpu", this::fragmentedCpu); - StormMetricsRegistry.registerGauge("nimbus:available-memory", () -> nodeIdToResources.get().values() + //Be cautious using method reference instead of lambda. subexpression preceding :: will be evaluated only upon evaluation + // Num supervisor, and fragmented resources have been included in cluster summary + StormMetricsRegistry.registerGauge("nimbus:total-available-memory (nonegative)", () -> nodeIdToResources.get().values() .parallelStream() - .mapToDouble(SupervisorResources::getAvailableMem) + .mapToDouble(supervisorResources -> Math.max(supervisorResources.getAvailableMem(), 0)) .sum()); - StormMetricsRegistry.registerGauge("nimbus:available-cpu", () -> nodeIdToResources.get().values() + StormMetricsRegistry.registerGauge("nimbus:available-cpu (nonnegative)", () -> nodeIdToResources.get().values() --- End diff -- I don't know whether we need to worry about this, but do we need to change the metric names here? If so, I'd rather build the non-negativity into the name, e.g. `nimbus:available-cpu-non-negative`.
---