Search in sources :

Example 1 with RoundRobinPacking

use of org.apache.heron.packing.roundrobin.RoundRobinPacking in project heron by twitter.

the class SchedulerMainTest method updateNumContainersIfNeeded.

@Test
public void updateNumContainersIfNeeded() {
    int configuredNumContainers = 4;
    int configuredNumStreamManagers = configuredNumContainers - 1;
    int packingPlanSize = 1;
    SubmitterMain submitterMain = new SubmitterMain(Config.newBuilder().put(Key.PACKING_CLASS, "org.apache.heron.packing.roundrobin.ResourceCompliantRRPacking").build(), null);
    PackingPlan packingPlan = PackingTestUtils.testPackingPlan(TOPOLOGY_NAME, new RoundRobinPacking());
    assertEquals(packingPlanSize, packingPlan.getContainers().size());
    org.apache.heron.api.Config apiConfig = new org.apache.heron.api.Config();
    apiConfig.setNumStmgrs(configuredNumStreamManagers);
    TopologyAPI.Topology initialTopology = TopologyTests.createTopology(TOPOLOGY_NAME, apiConfig, new HashMap<String, Integer>(), new HashMap<String, Integer>());
    Config initialConfig = Config.newBuilder().put(Key.NUM_CONTAINERS, configuredNumContainers).put(Key.PACKING_CLASS, RoundRobinPacking.class.getName()).put(Key.TOPOLOGY_DEFINITION, initialTopology).build();
    // assert preconditions
    assertEquals(Integer.toString(configuredNumStreamManagers), apiConfig.get(org.apache.heron.api.Config.TOPOLOGY_STMGRS));
    assertEquals(configuredNumStreamManagers, TopologyUtils.getNumContainers(initialTopology));
    assertContainerCount(configuredNumStreamManagers, initialConfig);
    Config newConfig = submitterMain.updateNumContainersIfNeeded(initialConfig, initialTopology, packingPlan);
    assertContainerCount(packingPlanSize, newConfig);
}
Also used : RoundRobinPacking(org.apache.heron.packing.roundrobin.RoundRobinPacking) Config(org.apache.heron.spi.common.Config) PackingPlan(org.apache.heron.spi.packing.PackingPlan) Mockito.anyString(org.mockito.Mockito.anyString) TopologyAPI(org.apache.heron.api.generated.TopologyAPI) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with RoundRobinPacking

use of org.apache.heron.packing.roundrobin.RoundRobinPacking in project heron by twitter.

the class HeronMasterDriverTest method scheduleHeronWorkersFailsOnDuplicateRequest.

@Test(expected = HeronMasterDriver.ContainerAllocationException.class)
public void scheduleHeronWorkersFailsOnDuplicateRequest() throws Exception {
    PackingPlan packingPlan = PackingTestUtils.testPackingPlan("test", new RoundRobinPacking());
    spyDriver.scheduleHeronWorkers(packingPlan);
    verify(spyDriver, times(1)).requestContainerForWorker(eq(1), anyHeronWorker());
    verify(mockRequestor, times(1)).submit(any(EvaluatorRequest.class));
    PackingPlan.ContainerPlan duplicatePlan = PackingTestUtils.testContainerPlan(1);
    Set<PackingPlan.ContainerPlan> toBeAddedContainerPlans = new HashSet<>();
    toBeAddedContainerPlans.add(duplicatePlan);
    spyDriver.scheduleHeronWorkers(toBeAddedContainerPlans);
}
Also used : RoundRobinPacking(org.apache.heron.packing.roundrobin.RoundRobinPacking) PackingPlan(org.apache.heron.spi.packing.PackingPlan) EvaluatorRequest(org.apache.reef.driver.evaluator.EvaluatorRequest) HashSet(java.util.HashSet) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with RoundRobinPacking

use of org.apache.heron.packing.roundrobin.RoundRobinPacking in project heron by twitter.

the class PackingPlanProviderTest method refreshesPackingPlanOnUpdate.

@Test
public void refreshesPackingPlanOnUpdate() {
    PackingPlans.PackingPlan proto = PackingTestUtils.testProtoPackingPlan(topologyName, new RoundRobinPacking());
    SchedulerStateManagerAdaptor adaptor = mock(SchedulerStateManagerAdaptor.class);
    when(adaptor.getPackingPlan(topologyName)).thenReturn(proto);
    PackingPlanProvider provider = new PackingPlanProvider(adaptor, eventManager, topologyName);
    PackingPlan packing = provider.get();
    Assert.assertEquals(1, packing.getContainers().size());
    provider.onEvent(new TopologyUpdate(null, null));
    provider.get();
    verify(adaptor, times(2)).getPackingPlan(topologyName);
}
Also used : PackingPlans(org.apache.heron.proto.system.PackingPlans) RoundRobinPacking(org.apache.heron.packing.roundrobin.RoundRobinPacking) PackingPlan(org.apache.heron.spi.packing.PackingPlan) TopologyUpdate(org.apache.heron.healthmgr.common.HealthManagerEvents.TopologyUpdate) SchedulerStateManagerAdaptor(org.apache.heron.spi.statemgr.SchedulerStateManagerAdaptor) Test(org.junit.Test)

Example 4 with RoundRobinPacking

use of org.apache.heron.packing.roundrobin.RoundRobinPacking in project heron by twitter.

the class PackingPlanProviderTest method providesBoltInstanceNames.

@Test
public void providesBoltInstanceNames() {
    PackingPlans.PackingPlan proto = PackingTestUtils.testProtoPackingPlan(topologyName, new RoundRobinPacking());
    SchedulerStateManagerAdaptor adaptor = mock(SchedulerStateManagerAdaptor.class);
    when(adaptor.getPackingPlan(topologyName)).thenReturn(proto);
    PackingPlanProvider packing = new PackingPlanProvider(adaptor, eventManager, topologyName);
    String[] boltNames = packing.getBoltInstanceNames("testBolt");
    assertEquals(3, boltNames.length);
    HashSet<String> expectedBoltNames = new HashSet<>();
    expectedBoltNames.add("container_1_testBolt_3");
    expectedBoltNames.add("container_1_testBolt_4");
    expectedBoltNames.add("container_1_testBolt_5");
    for (String name : boltNames) {
        expectedBoltNames.remove(name);
    }
    assertEquals(0, expectedBoltNames.size());
}
Also used : PackingPlans(org.apache.heron.proto.system.PackingPlans) RoundRobinPacking(org.apache.heron.packing.roundrobin.RoundRobinPacking) SchedulerStateManagerAdaptor(org.apache.heron.spi.statemgr.SchedulerStateManagerAdaptor) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 5 with RoundRobinPacking

use of org.apache.heron.packing.roundrobin.RoundRobinPacking in project heron by twitter.

the class ScaleUpResolverTest method createPacking.

private PackingPlan createPacking(TopologyAPI.Topology topology, Config config) {
    RoundRobinPacking packing = new RoundRobinPacking();
    packing.initialize(config, topology);
    return packing.pack();
}
Also used : RoundRobinPacking(org.apache.heron.packing.roundrobin.RoundRobinPacking)

Aggregations

RoundRobinPacking (org.apache.heron.packing.roundrobin.RoundRobinPacking)11 PackingPlan (org.apache.heron.spi.packing.PackingPlan)7 Test (org.junit.Test)7 PackingPlans (org.apache.heron.proto.system.PackingPlans)5 SchedulerStateManagerAdaptor (org.apache.heron.spi.statemgr.SchedulerStateManagerAdaptor)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 HashSet (java.util.HashSet)3 Config (org.apache.heron.spi.common.Config)2 EvaluatorRequest (org.apache.reef.driver.evaluator.EvaluatorRequest)2 TopologyAPI (org.apache.heron.api.generated.TopologyAPI)1 TopologyUpdate (org.apache.heron.healthmgr.common.HealthManagerEvents.TopologyUpdate)1 Scheduler (org.apache.heron.proto.scheduler.Scheduler)1 ISchedulerClient (org.apache.heron.scheduler.client.ISchedulerClient)1 IPacking (org.apache.heron.spi.packing.IPacking)1 ILauncher (org.apache.heron.spi.scheduler.ILauncher)1 IStateManager (org.apache.heron.spi.statemgr.IStateManager)1 IUploader (org.apache.heron.spi.uploader.IUploader)1 AllocatedEvaluator (org.apache.reef.driver.evaluator.AllocatedEvaluator)1 Configuration (org.apache.reef.tang.Configuration)1 Before (org.junit.Before)1