use of com.twitter.heron.spi.packing.PackingPlan.ContainerPlan in project incubator-heron by apache.
the class HeronMasterDriver method scheduleHeronWorkers.
/**
* Container allocation is asynchronous. Requests all containers in the input set serially
* to ensure allocated resources match the required resources.
*/
void scheduleHeronWorkers(Set<ContainerPlan> containers) throws ContainerAllocationException {
for (ContainerPlan containerPlan : containers) {
int id = containerPlan.getId();
if (containerPlans.containsKey(containerPlan.getId())) {
throw new ContainerAllocationException("Received duplicate allocation request for " + id);
}
Resource reqResource = containerPlan.getRequiredResource();
containerPlans.put(id, containerPlan);
requestContainerForWorker(id, new HeronWorker(id, reqResource));
}
}
use of com.twitter.heron.spi.packing.PackingPlan.ContainerPlan in project heron by twitter.
the class HeronMasterDriver method scheduleHeronWorkers.
/**
* Container allocation is asynchronous. Requests all containers in the input set serially
* to ensure allocated resources match the required resources.
*/
void scheduleHeronWorkers(Set<ContainerPlan> containers) throws ContainerAllocationException {
for (ContainerPlan containerPlan : containers) {
int id = containerPlan.getId();
if (containerPlans.containsKey(containerPlan.getId())) {
throw new ContainerAllocationException("Received duplicate allocation request for " + id);
}
Resource reqResource = containerPlan.getRequiredResource();
containerPlans.put(id, containerPlan);
requestContainerForWorker(id, new HeronWorker(id, reqResource));
}
}
use of com.twitter.heron.spi.packing.PackingPlan.ContainerPlan in project heron by twitter.
the class HeronMasterDriver method restartWorker.
public void restartWorker(int id) throws ContainerAllocationException {
LOG.log(Level.INFO, "Find & restart container for id={0}", id);
Optional<HeronWorker> worker = multiKeyWorkerMap.lookupByWorkerId(id);
if (!worker.isPresent()) {
LOG.log(Level.WARNING, "Requesting a new container for: {0}", id);
ContainerPlan containerPlan = containerPlans.get(id);
if (containerPlan == null) {
throw new IllegalArgumentException(String.format("There is no container for %s in packing plan.", id));
}
worker = Optional.of(new HeronWorker(id, containerPlan.getRequiredResource()));
} else {
AllocatedEvaluator evaluator = multiKeyWorkerMap.detachEvaluatorAndRemove(worker.get());
LOG.log(Level.INFO, "Shutting down container {0}", evaluator.getId());
evaluator.close();
}
requestContainerForWorker(worker.get().workerId, worker.get());
}
use of com.twitter.heron.spi.packing.PackingPlan.ContainerPlan in project heron by twitter.
the class UpdateDryRunRenderTest method setUp.
@Before
public void setUp() throws Exception {
// set up original packing plan
final String COMPONENT_A = "exclaim1";
final String COMPONENT_B = "word";
ContainerPlan containerPlanA = PackingTestUtils.testContainerPlan(1, new Pair<>(COMPONENT_A, 1), new Pair<>(COMPONENT_A, 3), new Pair<>(COMPONENT_B, 5));
ContainerPlan containerPlanB = PackingTestUtils.testContainerPlan(2, new Pair<>(COMPONENT_A, 2), new Pair<>(COMPONENT_A, 4), new Pair<>(COMPONENT_B, 6));
Set<ContainerPlan> containerPlans = new HashSet<>();
containerPlans.add(containerPlanA);
containerPlans.add(containerPlanB);
originalPlan = new PackingPlan("ORIG", containerPlans);
// setup new packing plan A: word:1, exclaim1:9
Set<ContainerPlan> containerPlansA = new HashSet<>();
containerPlansA.add(containerPlanA);
containerPlansA.add(PackingTestUtils.testContainerPlan(2, new Pair<>(COMPONENT_A, 4), new Pair<>(COMPONENT_A, 2), new Pair<>(COMPONENT_A, 6)));
containerPlansA.add(PackingTestUtils.testContainerPlan(3, new Pair<>(COMPONENT_A, 7), new Pair<>(COMPONENT_A, 8), new Pair<>(COMPONENT_A, 9)));
containerPlansA.add(PackingTestUtils.testContainerPlan(4, new Pair<>(COMPONENT_A, 10)));
newPlanA = new PackingPlan("A", containerPlansA);
// setup new packing plan B: word:1, exclaim1:1
Set<ContainerPlan> containerPlansB = new HashSet<>();
containerPlansB.add(PackingTestUtils.testContainerPlan(1, new Pair<>(COMPONENT_A, 3), new Pair<>(COMPONENT_B, 5)));
newPlanB = new PackingPlan("B", containerPlansB);
}
use of com.twitter.heron.spi.packing.PackingPlan.ContainerPlan in project incubator-heron by apache.
the class PackingPlanProvider method getBoltInstanceNames.
public String[] getBoltInstanceNames(String... boltComponents) {
HashSet<String> boltComponentNames = new HashSet<>();
Collections.addAll(boltComponentNames, boltComponents);
PackingPlan packing = get();
ArrayList<String> boltInstanceNames = new ArrayList<>();
for (ContainerPlan containerPlan : packing.getContainers()) {
for (InstancePlan instancePlan : containerPlan.getInstances()) {
if (!boltComponentNames.contains(instancePlan.getComponentName())) {
continue;
}
String name = "container_" + containerPlan.getId() + "_" + instancePlan.getComponentName() + "_" + instancePlan.getTaskId();
boltInstanceNames.add(name);
}
}
return boltInstanceNames.toArray(new String[boltInstanceNames.size()]);
}
Aggregations