[GitHub] [incubator-heron] xiaoyao1991 commented on a change in pull request #3375: Add instance resource usage in container

2019-10-23 Thread GitBox
xiaoyao1991 commented on a change in pull request #3375: Add instance resource 
usage in container
URL: https://github.com/apache/incubator-heron/pull/3375#discussion_r338281873
 
 

 ##
 File path: heron/tools/ui/resources/static/js/physical-plan.js
 ##
 @@ -86,6 +93,18 @@
   return d.children.length;
 });
 
+function formatByteSize(byteSize) {
+  if (byteSize > 1024 * 1024 * 1024 / 2) {
+return (byteSize / (1024 * 1024 * 1024)).toFixed(2) + 'GB';
+  } else if (byteSize > 1024 * 1024 / 2) {
+return (byteSize / (1024 * 1024)).toFixed(2) + 'MB';
+  } else if (byteSize > 1024 / 2) {
+return (byteSize / 1024).toFixed(2) + 'KB';
+  } else {
+return byteSize + 'B';
+  }
+}
 
 Review comment:
   There is a `pretty-bytes` npm package that does this. 


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-heron] xiaoyao1991 commented on a change in pull request #3375: Add instance resource usage in container

2019-10-23 Thread GitBox
xiaoyao1991 commented on a change in pull request #3375: Add instance resource 
usage in container
URL: https://github.com/apache/incubator-heron/pull/3375#discussion_r338281257
 
 

 ##
 File path: heron/tools/ui/resources/static/js/physical-plan.js
 ##
 @@ -63,16 +63,23 @@
   container.children = _.sortBy(container.children, 'name');
   // Parse index
   container.index = parseInt(container.id.split('-')[1]);
-  // Search for resource config in packing plan
+  // Search for container resource config in packing plan
   container.required_resources = {
-'cpu': 0,
-'disk': 0,
-'ram': 0
+'cpu': 'unknown',
+'disk': 'unknown',
+'ram': 'unknown'
   };
   for (var i in containerPlan) {
 var packing = containerPlan[i];
 if (packing.id === container.index) {
   container.required_resources = packing.required_resources;
+  // Get instance resources
+  var instance_resources = {};
+  for (var j in packing.instances) {
+var inst = packing.instances[j];
+instance_resources[inst.component_name + '_' + inst.task_id] = 
inst.instance_resources;
+  }
 
 Review comment:
   can probably be replaced with a `map` 


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services