Search in sources :

Example 6 with ContainerPlan

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));
    }
}
Also used : ContainerPlan(com.twitter.heron.spi.packing.PackingPlan.ContainerPlan) Resource(com.twitter.heron.spi.packing.Resource)

Example 7 with ContainerPlan

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));
    }
}
Also used : ContainerPlan(com.twitter.heron.spi.packing.PackingPlan.ContainerPlan) Resource(com.twitter.heron.spi.packing.Resource)

Example 8 with ContainerPlan

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

Example 9 with ContainerPlan

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);
}
Also used : ContainerPlan(com.twitter.heron.spi.packing.PackingPlan.ContainerPlan) PackingPlan(com.twitter.heron.spi.packing.PackingPlan) HashSet(java.util.HashSet) Pair(com.twitter.heron.common.basics.Pair) Before(org.junit.Before)

Example 10 with ContainerPlan

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()]);
}
Also used : ContainerPlan(com.twitter.heron.spi.packing.PackingPlan.ContainerPlan) PackingPlan(com.twitter.heron.spi.packing.PackingPlan) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) InstancePlan(com.twitter.heron.spi.packing.PackingPlan.InstancePlan)

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