xiaoyao1991 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_r245104513
 
 

 ##########
 File path: heron/common/src/java/org/apache/heron/common/basics/CPUShare.java
 ##########
 @@ -0,0 +1,125 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.heron.common.basics;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public final class CPUShare implements ResourceMeasure<CPUShare> {
 
 Review comment:
   It doesn't seem necessary to separate `RamShare` and `DiskShare` as RAM and 
disk are both measured in `ByteAmount`. CPU is measured in share of time used. 
   
   Previously, we didn't take CPU resource constraints into consideration when 
composing packing plan. Now that we do -- namely we need to collect instance 
cpu resource mapping,  and the logic of that is very similar to that of 
instance RAM resource mapping (previously as 
`getInstancesRAMMapInContainer()`). But due to the difference in the type of 
measurement(`ByteAmount` vs `double`), we might end up with a lot of code 
duplicates. Hence, I abstract out `CPUShare` so that it looks very similar to 
what we have in `ByteAmount`, and thus we can have one 
`calculateInstancesResourceMapInContainer()` that works for both CPU and RAM 
(potentially disk if needed) instance resource mapping collection. 

----------------------------------------------------------------
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

Reply via email to