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

    https://github.com/apache/storm/pull/2385#discussion_r149144246
  
    --- Diff: storm-client/src/jvm/org/apache/storm/Constants.java ---
    @@ -56,5 +58,21 @@
         public static final String STORM_ACTIVE_ATOM = "storm-active-atom";
         public static final String COMPONENT_TO_DEBUG_ATOM = 
"storm-component->debug-atom";
         public static final Object LOAD_MAPPING = "load-mapping";
    +
    +    public static final String COMMON_CPU_RESOURCE_NAME = 
"cpu.pcore.percent";
    +    public static final String COMMON_ONHEAP_MEMORY_RESOURCE_NAME = 
"onheap.memory.mb";
    +    public static final String COMMON_OFFHEAP_MEMORY_RESOURCE_NAME = 
"offheap.memory.mb";
    +    public static final String COMMON_TOTAL_MEMORY_RESOURCE_NAME = 
"memory.mb";
    +
    +    public static final Map<String, String> resourceNameMapping;
    +
    +    static {
    +        resourceNameMapping = new HashMap();
    +        
resourceNameMapping.put(Config.TOPOLOGY_COMPONENT_CPU_PCORE_PERCENT, 
COMMON_CPU_RESOURCE_NAME);
    +        resourceNameMapping.put(Config.SUPERVISOR_CPU_CAPACITY, 
COMMON_CPU_RESOURCE_NAME);
    +        
resourceNameMapping.put(Config.TOPOLOGY_COMPONENT_RESOURCES_ONHEAP_MEMORY_MB, 
COMMON_ONHEAP_MEMORY_RESOURCE_NAME);
    +        
resourceNameMapping.put(Config.TOPOLOGY_COMPONENT_RESOURCES_OFFHEAP_MEMORY_MB, 
COMMON_OFFHEAP_MEMORY_RESOURCE_NAME);
    +        resourceNameMapping.put(Config.SUPERVISOR_MEMORY_CAPACITY_MB, 
COMMON_TOTAL_MEMORY_RESOURCE_NAME);
    --- End diff --
    
    nit: Can we make this a read only map when we save it?  I don't think we 
want to modify it after it is setup.
    
    ```
    static {
            Map<String, String> tmp = new HashMap<>();
            tmp.put(Config.TOPOLOGY_COMPONENT_CPU_PCORE_PERCENT, 
COMMON_CPU_RESOURCE_NAME);
            tmp.put(Config.SUPERVISOR_CPU_CAPACITY, COMMON_CPU_RESOURCE_NAME);
            tmp.put(Config.TOPOLOGY_COMPONENT_RESOURCES_ONHEAP_MEMORY_MB, 
COMMON_ONHEAP_MEMORY_RESOURCE_NAME);
            tmp.put(Config.TOPOLOGY_COMPONENT_RESOURCES_OFFHEAP_MEMORY_MB, 
COMMON_OFFHEAP_MEMORY_RESOURCE_NAME);
            tmp.put(Config.SUPERVISOR_MEMORY_CAPACITY_MB, 
COMMON_TOTAL_MEMORY_RESOURCE_NAME);
            resourceNameMapping = Collections.unmodifiableMap(tmp);
    }
    ```


---

Reply via email to