Github user srdo commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2763#discussion_r203717231
  
    --- Diff: 
storm-server/src/main/java/org/apache/storm/daemon/nimbus/Nimbus.java ---
    @@ -2809,21 +2809,19 @@ public void launchServer() throws Exception {
                                             }
                                         });
     
    +            //Be cautious using method reference instead of lambda. 
subexpression preceding :: will be evaluated only upon evaluation
                 StormMetricsRegistry.registerGauge("nimbus:num-supervisors", 
() -> state.supervisors(null).size());
    -            StormMetricsRegistry.registerGauge("nimbus:fragmented-memory", 
() -> fragmentedMemory());
    -            StormMetricsRegistry.registerGauge("nimbus:fragmented-cpu", () 
-> fragmentedCpu());
    +            StormMetricsRegistry.registerGauge("nimbus:fragmented-memory", 
this::fragmentedMemory);
    +            StormMetricsRegistry.registerGauge("nimbus:fragmented-cpu", 
this::fragmentedCpu);
                 StormMetricsRegistry.registerGauge("nimbus:available-memory", 
() -> nodeIdToResources.get().values().parallelStream()
    -                                                                           
                      .mapToDouble(
    -                                                                           
                          SupervisorResources::getAvailableMem)
    -                                                                           
                      .sum());
    -            StormMetricsRegistry.registerGauge("nimbus:available-cpu", () 
-> nodeIdToResources.get().values().parallelStream().mapToDouble(
    -                SupervisorResources::getAvailableCpu).sum());
    +                .mapToDouble(SupervisorResources::getAvailableMem).sum());
    --- End diff --
    
    Nit: I think the readability of method chaining is improved by having one 
call per line, e.g. 
    
    ```
    x.stream
      .map
      .collect
    ```
    rather than
    ```
    x.stream
    .map.collect
    ```
    It's a super minor complaint though.



---

Reply via email to