nwangtw commented on a change in pull request #3142: Validate resource
constraint (RAM and CPU) in RoundRobinPacking
URL: https://github.com/apache/incubator-heron/pull/3142#discussion_r245051109
##########
File path:
heron/packing/src/java/org/apache/heron/packing/roundrobin/RoundRobinPacking.java
##########
@@ -133,16 +143,36 @@ private PackingPlan packInternal(int numContainer,
Map<String, Integer> parallel
// Get the RAM map for every instance
Map<Integer, Map<InstanceId, ByteAmount>> instancesRamMap =
- getInstancesRamMapInContainer(roundRobinAllocation);
+ calculateInstancesResourceMapInContainer(
+ roundRobinAllocation,
+ TopologyUtils.getComponentRamMapConfig(topology),
+ getContainerRamHint(roundRobinAllocation),
+ instanceRamDefault,
+ containerRamPadding,
+ ByteAmount.ZERO,
+ NOT_SPECIFIED_BYTE_AMOUNT,
+ RAM);
+
+ // Get the CPU map for every instance
+ Map<Integer, Map<InstanceId, CPUShare>> instancesCpuMap =
+ calculateInstancesResourceMapInContainer(
+ roundRobinAllocation,
+
CPUShare.convertDoubleMapToCpuShareMap(TopologyUtils.getComponentCpuMapConfig(topology)),
+ CPUShare.fromDouble(getContainerCpuHint(roundRobinAllocation)),
+ CPUShare.fromDouble(instanceCpuDefault),
+ CPUShare.fromDouble(containerCpuPadding),
+ CPUShare.fromDouble(0.0),
+ CPUShare.fromDouble(NOT_SPECIFIED_CPU_SHARE),
+ CPU);
ByteAmount containerDiskInBytes =
getContainerDiskHint(roundRobinAllocation);
- double containerCpu = getContainerCpuHint(roundRobinAllocation);
+ double containerCpuHint = getContainerCpuHint(roundRobinAllocation);
ByteAmount containerRamHint = getContainerRamHint(roundRobinAllocation);
- LOG.info(String.format("Pack internal: container CPU hint: %f, RAM hint:
%s, disk hint: %s.",
- containerCpu,
- containerDiskInBytes.toString(),
- containerRamHint.toString()));
+ LOG.info(String.format("Pack internal: container CPU hint: %.1f, RAM hint:
%s, disk hint: %s.",
Review comment:
"%.3f" is more consistent to the toString function in CPUShare. Or maybe
wrap it into CPUShare and call the toString() function like the
containerRamHint var.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services