Github user revans2 commented on a diff in the pull request: https://github.com/apache/storm/pull/2385#discussion_r147233694 --- Diff: examples/storm-loadgen/src/main/java/org/apache/storm/loadgen/CaptureLoad.java --- @@ -430,37 +427,37 @@ public static void main(String[] args) throws Exception { return topologyResources; } - static void checkIntialization(Map<String, Double> topologyResources, String com, - Map<String, Object> topologyConf) { - checkInitMem(topologyResources, com, topologyConf); - checkInitCpu(topologyResources, com, topologyConf); - } + /** + * Checks if the topology's resource requirements are initialized. + * @param topologyResources map of resouces requirements + * @param componentId component for which initialization is being conducted + * @param topologyConf topology configuration + * @throws Exception on any error + */ + public static void checkInitialization(Map<String, Double> topologyResources, String componentId, Map topologyConf) { + StringBuilder msgBuilder = new StringBuilder(); - static void checkInitMem(Map<String, Double> topologyResources, String com, - Map<String, Object> topologyConf) { - if (!topologyResources.containsKey(Config.TOPOLOGY_COMPONENT_RESOURCES_ONHEAP_MEMORY_MB)) { - Double onHeap = ObjectReader.getDouble( - topologyConf.get(Config.TOPOLOGY_COMPONENT_RESOURCES_ONHEAP_MEMORY_MB), null); - if (onHeap != null) { - topologyResources.put(Config.TOPOLOGY_COMPONENT_RESOURCES_ONHEAP_MEMORY_MB, onHeap); - } + for (String resourceName : topologyResources.keySet()) { + msgBuilder.append(checkInitResource(topologyResources, topologyConf, resourceName)); } - if (!topologyResources.containsKey(Config.TOPOLOGY_COMPONENT_RESOURCES_OFFHEAP_MEMORY_MB)) { - Double offHeap = ObjectReader.getDouble( - topologyConf.get(Config.TOPOLOGY_COMPONENT_RESOURCES_OFFHEAP_MEMORY_MB), null); - if (offHeap != null) { - topologyResources.put(Config.TOPOLOGY_COMPONENT_RESOURCES_OFFHEAP_MEMORY_MB, offHeap); - } + + if (msgBuilder.length() > 0) { + String resourceDefaults = msgBuilder.toString(); + LOG.debug( + "Unable to extract resource requirement for Component {} \n Resources : {}", + componentId, resourceDefaults); } } - static void checkInitCpu(Map<String, Double> topologyResources, String com, - Map<String, Object> topologyConf) { - if (!topologyResources.containsKey(Config.TOPOLOGY_COMPONENT_CPU_PCORE_PERCENT)) { - Double cpu = ObjectReader.getDouble(topologyConf.get(Config.TOPOLOGY_COMPONENT_CPU_PCORE_PERCENT), null); - if (cpu != null) { - topologyResources.put(Config.TOPOLOGY_COMPONENT_CPU_PCORE_PERCENT, cpu); - } + private static String checkInitResource(Map<String, Double> topologyResources, Map topologyConf, String resourceName) { + StringBuilder msgBuilder = new StringBuilder(); + if (topologyResources.containsKey(resourceName)) { + Double resourceValue = (Double) topologyConf.getOrDefault(resourceName, null); --- End diff -- I think you missed something in the translation. I think it should be more like ``` if (topologyResources.containsKey(resourceName)) { Double resourceValue = ObjectReader.getDouble(topologyConf.get(resourceName), null); if (resourceValue != null) { topologyResources.put(resourceName, resourceValue); } ... ```
---