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

    https://github.com/apache/storm/pull/2385#discussion_r149160853
  
    --- Diff: 
storm-server/src/main/java/org/apache/storm/daemon/supervisor/timer/SupervisorHeartbeat.java
 ---
    @@ -73,11 +75,23 @@ private SupervisorInfo buildSupervisorInfo(Map<String, 
Object> conf, Supervisor
     
         private Map<String, Double> mkSupervisorCapacities(Map<String, Object> 
conf) {
             Map<String, Double> ret = new HashMap<String, Double>();
    +        // Put in legacy values
             Double mem = 
ObjectReader.getDouble(conf.get(Config.SUPERVISOR_MEMORY_CAPACITY_MB), 4096.0);
             ret.put(Config.SUPERVISOR_MEMORY_CAPACITY_MB, mem);
             Double cpu = 
ObjectReader.getDouble(conf.get(Config.SUPERVISOR_CPU_CAPACITY), 400.0);
             ret.put(Config.SUPERVISOR_CPU_CAPACITY, cpu);
    -        return ret;
    +
    +
    +        // If configs are present in Generic map and legacy - the legacy 
values will be overwritten
    +        Map<String, Double> resourcesMap = (Map<String,Double>) 
conf.get(Config.SUPERVISOR_RESOURCES_MAP);
    --- End diff --
    
    This is not guaranteed to be a Double.  It is guaranteed to be a Number.  
So we need to convert it with something like.
    
    ```
            if (resourcesMap != null) {
                for (Map.Entry<String, Number> stringNumberEntry : 
resourcesMap.entrySet()) {
                    ret.put(stringNumberEntry.getKey(), 
stringNumberEntry.getValue().doubleValue());
                }
            }
    ```


---

Reply via email to