com.twitter.heron.spi.packing.IPacking Maven / Gradle / Ivy
// Copyright 2016 Twitter. All rights reserved.
//
// Licensed 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 com.twitter.heron.spi.packing;
import com.twitter.heron.api.generated.TopologyAPI;
import com.twitter.heron.classification.InterfaceAudience;
import com.twitter.heron.classification.InterfaceStability;
import com.twitter.heron.spi.common.Config;
/**
* Packing algorithm to use for packing multiple instances into containers. Packing hints like
* number of containers may be passed through scheduler config. Configs might contain settings for
* the number of containers requested or the amount of instance or container resources to allocate.
* Implementations may choose to ignore some or all of these settings as needed, since they could be
* contradictory, or not all possible to be achieved based on the algorithm.
*/
@InterfaceAudience.LimitedPrivate
@InterfaceStability.Unstable
public interface IPacking extends AutoCloseable {
/**
* Initialize the packing algorithm with the static config and the topology
*/
void initialize(Config config, TopologyAPI.Topology topology);
/**
* Called by scheduler to generate container packing.
* Packing algorithm output generates instance id and container id.
*
* @return PackingPlan describing the job to schedule.
* @throws PackingException if the packing plan can not be generated
*/
PackingPlan pack() throws PackingException;
/**
* This is to for disposing or cleaning up any internal state accumulated by
* the uploader
*
* Closes this stream and releases any system resources associated
* with it. If the stream is already closed then invoking this
* method has no effect.
*/
void close();
}