Search in sources :

Example 11 with ContainerPlan

use of com.twitter.heron.spi.packing.PackingPlan.ContainerPlan in project incubator-heron by apache.

the class SubmitDryRunRenderTest method setUp.

@Before
public void setUp() throws Exception {
    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);
    plan = new PackingPlan("A", containerPlans);
}
Also used : ContainerPlan(com.twitter.heron.spi.packing.PackingPlan.ContainerPlan) PackingPlan(com.twitter.heron.spi.packing.PackingPlan) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 12 with ContainerPlan

use of com.twitter.heron.spi.packing.PackingPlan.ContainerPlan in project incubator-heron by apache.

the class HeronMasterDriver method killWorkers.

/**
 * Terminates any yarn containers associated with the given containers.
 */
public void killWorkers(Set<ContainerPlan> containers) {
    for (ContainerPlan container : containers) {
        LOG.log(Level.INFO, "Find and kill container for worker {0}", container.getId());
        Optional<HeronWorker> worker = multiKeyWorkerMap.lookupByWorkerId(container.getId());
        if (worker.isPresent()) {
            LOG.log(Level.INFO, "Killing container {0} for worker {1}", new Object[] { worker.get().evaluator.getId(), worker.get().workerId });
            AllocatedEvaluator evaluator = multiKeyWorkerMap.detachEvaluatorAndRemove(worker.get());
            evaluator.close();
        } else {
            LOG.log(Level.WARNING, "Did not find worker for {0}", container.getId());
        }
        containerPlans.remove(container.getId());
    }
}
Also used : ContainerPlan(com.twitter.heron.spi.packing.PackingPlan.ContainerPlan) AllocatedEvaluator(org.apache.reef.driver.evaluator.AllocatedEvaluator)

Example 13 with ContainerPlan

use of com.twitter.heron.spi.packing.PackingPlan.ContainerPlan in project incubator-heron by apache.

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());
}
Also used : ContainerPlan(com.twitter.heron.spi.packing.PackingPlan.ContainerPlan) AllocatedEvaluator(org.apache.reef.driver.evaluator.AllocatedEvaluator)

Aggregations

ContainerPlan (com.twitter.heron.spi.packing.PackingPlan.ContainerPlan)13 PackingPlan (com.twitter.heron.spi.packing.PackingPlan)7 HashSet (java.util.HashSet)7 AllocatedEvaluator (org.apache.reef.driver.evaluator.AllocatedEvaluator)4 Before (org.junit.Before)4 TopologyAPI (com.twitter.heron.api.generated.TopologyAPI)2 Pair (com.twitter.heron.common.basics.Pair)2 LauncherUtils (com.twitter.heron.scheduler.utils.LauncherUtils)2 Config (com.twitter.heron.spi.common.Config)2 IPacking (com.twitter.heron.spi.packing.IPacking)2 Resource (com.twitter.heron.spi.packing.Resource)2 ILauncher (com.twitter.heron.spi.scheduler.ILauncher)2 SchedulerStateManagerAdaptor (com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor)2 InstancePlan (com.twitter.heron.spi.packing.PackingPlan.InstancePlan)1 ArrayList (java.util.ArrayList)1