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);
}
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);
}
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);
}
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());
}
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();
}
Aggregations