nwangtw commented on a change in pull request #3187: Consolidate Packing
URL: https://github.com/apache/incubator-heron/pull/3187#discussion_r255191371
 
 

 ##########
 File path: heron/packing/src/java/org/apache/heron/packing/AbstractPacking.java
 ##########
 @@ -0,0 +1,140 @@
+/**
+ * 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.packing;
+
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import org.apache.heron.api.generated.TopologyAPI;
+import org.apache.heron.api.utils.TopologyUtils;
+import org.apache.heron.common.basics.ByteAmount;
+import org.apache.heron.packing.utils.PackingUtils;
+import org.apache.heron.spi.common.Config;
+import org.apache.heron.spi.common.Context;
+import org.apache.heron.spi.packing.IPacking;
+import org.apache.heron.spi.packing.IRepacking;
+import org.apache.heron.spi.packing.Resource;
+
+import static org.apache.heron.api.Config.TOPOLOGY_CONTAINER_CPU_PADDING;
+import static org.apache.heron.api.Config.TOPOLOGY_CONTAINER_CPU_REQUESTED;
+import static org.apache.heron.api.Config.TOPOLOGY_CONTAINER_DISK_REQUESTED;
+import static org.apache.heron.api.Config.TOPOLOGY_CONTAINER_MAX_NUM_INSTANCES;
+import static 
org.apache.heron.api.Config.TOPOLOGY_CONTAINER_PADDING_PERCENTAGE;
+import static org.apache.heron.api.Config.TOPOLOGY_CONTAINER_RAM_PADDING;
+import static org.apache.heron.api.Config.TOPOLOGY_CONTAINER_RAM_REQUESTED;
+
+/**
+ * Common configuration finalization for packing algorithms
+ */
+public abstract class AbstractPacking implements IPacking, IRepacking {
+  private static final Logger LOG = 
Logger.getLogger(AbstractPacking.class.getName());
+  protected TopologyAPI.Topology topology;
+
+  // instance & container
+  protected Resource defaultInstanceResources;
+  protected Resource maxContainerResources;
+  protected int maxNumInstancesPerContainer;
+  protected Map<String, Resource> componentResourceMap;
+
+  // padding
+  protected Resource padding;
+
+  @Override
+  public void initialize(Config config, TopologyAPI.Topology inputTopology) {
+    this.topology = inputTopology;
+    setPackingConfigs(config);
+    LOG.info(String.format("Initalizing Packing: \n"
+            + "Max number of instances per container: %d \n"
+            + "Default instance CPU: %f, Default instance RAM: %s, Default 
instance DISK: %s \n"
+            + "Paddng: %s \n"
+            + "Container CPU: %f, Container RAM: %s, Container DISK: %s",
 
 Review comment:
   Maybe "Container resource, CPU: %f, RAM: %s, DSIK: %s"

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