nwangtw commented on a change in pull request #3187: Consolidate Packing URL: https://github.com/apache/incubator-heron/pull/3187#discussion_r255190980
########## 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); Review comment: Suggest to add a blank line above but not a blocker. ---------------------------------------------------------------- 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
