Search in sources :

Example 6 with RoundRobinPacking

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

the class PackingPlanProviderTest method fetchesAndCachesPackingFromStateMgr.

@Test
public void fetchesAndCachesPackingFromStateMgr() {
    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());
    // once fetched it is cached
    provider.get();
    verify(adaptor, times(1)).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) SchedulerStateManagerAdaptor(org.apache.heron.spi.statemgr.SchedulerStateManagerAdaptor) Test(org.junit.Test)

Example 7 with RoundRobinPacking

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

the class RuntimeManagerRunnerTest method doupdateTopologyComponentParallelismTest.

private void doupdateTopologyComponentParallelismTest(String newParallelism, boolean expectedResult) {
    ISchedulerClient client = mock(ISchedulerClient.class);
    SchedulerStateManagerAdaptor manager = mock(SchedulerStateManagerAdaptor.class);
    RuntimeManagerRunner runner = newRuntimeManagerRunner(Command.UPDATE, client);
    PowerMockito.mockStatic(Runtime.class);
    PowerMockito.when(Runtime.schedulerStateManagerAdaptor(runtime)).thenReturn(manager);
    RoundRobinPacking packing = new RoundRobinPacking();
    PackingPlans.PackingPlan currentPlan = PackingTestUtils.testProtoPackingPlan(TOPOLOGY_NAME, packing);
    PackingPlans.PackingPlan proposedPlan = PackingTestUtils.testProtoPackingPlan(TOPOLOGY_NAME, packing);
    Map<String, Integer> changeRequests = runner.parseNewParallelismParam(newParallelism);
    when(manager.getPackingPlan(eq(TOPOLOGY_NAME))).thenReturn(currentPlan);
    doReturn(proposedPlan).when(runner).buildNewPackingPlan(eq(currentPlan), eq(changeRequests), any(), any(TopologyAPI.Topology.class));
    Scheduler.UpdateTopologyRequest updateTopologyRequest = Scheduler.UpdateTopologyRequest.newBuilder().setCurrentPackingPlan(currentPlan).setProposedPackingPlan(proposedPlan).build();
    when(client.updateTopology(updateTopologyRequest)).thenReturn(true);
    try {
        runner.updateTopologyComponentParallelism(TOPOLOGY_NAME, newParallelism);
    } finally {
        int expectedClientUpdateCalls = expectedResult ? 1 : 0;
        verify(client, times(expectedClientUpdateCalls)).updateTopology(updateTopologyRequest);
    }
}
Also used : RoundRobinPacking(org.apache.heron.packing.roundrobin.RoundRobinPacking) Scheduler(org.apache.heron.proto.scheduler.Scheduler) SchedulerStateManagerAdaptor(org.apache.heron.spi.statemgr.SchedulerStateManagerAdaptor) PackingPlans(org.apache.heron.proto.system.PackingPlans) ISchedulerClient(org.apache.heron.scheduler.client.ISchedulerClient)

Example 8 with RoundRobinPacking

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

the class SubmitterMainTest method setUp.

@Before
public void setUp() throws Exception {
    // Mock objects to be verified
    IPacking packing = mock(IPacking.class);
    statemgr = mock(IStateManager.class);
    launcher = mock(ILauncher.class);
    uploader = mock(IUploader.class);
    // Mock ReflectionUtils stuff
    PowerMockito.spy(ReflectionUtils.class);
    PowerMockito.doReturn(statemgr).when(ReflectionUtils.class, "newInstance", STATE_MANAGER_CLASS);
    PowerMockito.doReturn(launcher).when(ReflectionUtils.class, "newInstance", LAUNCHER_CLASS);
    PowerMockito.doReturn(packing).when(ReflectionUtils.class, "newInstance", PACKING_CLASS);
    PowerMockito.doReturn(uploader).when(ReflectionUtils.class, "newInstance", UPLOADER_CLASS);
    config = mock(Config.class);
    when(config.getStringValue(Key.STATE_MANAGER_CLASS)).thenReturn(STATE_MANAGER_CLASS);
    when(config.getStringValue(Key.LAUNCHER_CLASS)).thenReturn(LAUNCHER_CLASS);
    when(config.getStringValue(Key.PACKING_CLASS)).thenReturn(PACKING_CLASS);
    when(config.getStringValue(Key.UPLOADER_CLASS)).thenReturn(UPLOADER_CLASS);
    when(packing.pack()).thenReturn(PackingTestUtils.testPackingPlan(TOPOLOGY_NAME, new RoundRobinPacking()));
    topology = TopologyAPI.Topology.getDefaultInstance();
}
Also used : IStateManager(org.apache.heron.spi.statemgr.IStateManager) IUploader(org.apache.heron.spi.uploader.IUploader) IPacking(org.apache.heron.spi.packing.IPacking) ILauncher(org.apache.heron.spi.scheduler.ILauncher) RoundRobinPacking(org.apache.heron.packing.roundrobin.RoundRobinPacking) Config(org.apache.heron.spi.common.Config) Before(org.junit.Before)

Example 9 with RoundRobinPacking

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

the class SchedulerMainTest method getTestPacking.

private SettableFuture<PackingPlans.PackingPlan> getTestPacking() {
    PackingPlans.PackingPlan packingPlan = PackingTestUtils.testProtoPackingPlan("testTopology", new RoundRobinPacking());
    final SettableFuture<PackingPlans.PackingPlan> future = SettableFuture.create();
    assertTrue(future.set(packingPlan));
    return future;
}
Also used : PackingPlans(org.apache.heron.proto.system.PackingPlans) RoundRobinPacking(org.apache.heron.packing.roundrobin.RoundRobinPacking) PackingPlan(org.apache.heron.spi.packing.PackingPlan)

Example 10 with RoundRobinPacking

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

the class HeronMasterDriverTest method scheduleHeronWorkersAddsContainers.

@Test
public void scheduleHeronWorkersAddsContainers() 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));
    Set<PackingPlan.ContainerPlan> toBeAddedContainerPlans = new HashSet<>();
    toBeAddedContainerPlans.add(PackingTestUtils.testContainerPlan(2));
    toBeAddedContainerPlans.add(PackingTestUtils.testContainerPlan(3));
    spyDriver.scheduleHeronWorkers(toBeAddedContainerPlans);
    verify(spyDriver, times(1)).requestContainerForWorker(eq(2), anyHeronWorker());
    verify(spyDriver, times(1)).requestContainerForWorker(eq(3), anyHeronWorker());
    verify(mockRequestor, times(3)).submit(any(EvaluatorRequest.class));
}
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)

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