use of com.twitter.heron.spi.common.Config in project incubator-heron by apache.
the class CommonPackingTests method setUp.
@Before
public void setUp() {
this.spoutParallelism = 4;
this.boltParallelism = 3;
this.totalInstances = this.spoutParallelism + this.boltParallelism;
// Set up the topology and its config. Tests can safely modify the config by reference after the
// topology is created, but those changes will not be reflected in the underlying protobuf
// object Config and Topology objects. This is typically fine for packing tests since they don't
// access the protobuf values.
this.topologyConfig = new com.twitter.heron.api.Config();
this.topology = getTopology(spoutParallelism, boltParallelism, topologyConfig);
Config config = PackingTestUtils.newTestConfig(this.topology);
this.instanceDefaultResources = new Resource(Context.instanceCpu(config), Context.instanceRam(config), Context.instanceDisk(config));
}
use of com.twitter.heron.spi.common.Config in project incubator-heron by apache.
the class RoundRobinPackingTest method testRePacking.
/**
* test re-packing of instances
*/
@Test
public void testRePacking() throws Exception {
int numContainers = 2;
int componentParallelism = 4;
// Set up the topology and its config
com.twitter.heron.api.Config topologyConfig = new com.twitter.heron.api.Config();
topologyConfig.put(com.twitter.heron.api.Config.TOPOLOGY_STMGRS, numContainers);
TopologyAPI.Topology topology = getTopology(componentParallelism, componentParallelism, topologyConfig);
int numInstance = TopologyUtils.getTotalInstance(topology);
// Two components
Assert.assertEquals(2 * componentParallelism, numInstance);
Map<String, Integer> componentChanges = new HashMap<>();
componentChanges.put(SPOUT_NAME, -1);
componentChanges.put(BOLT_NAME, +1);
PackingPlan output = getRoundRobinRePackingPlan(topology, componentChanges);
Assert.assertEquals(numContainers, output.getContainers().size());
Assert.assertEquals((Integer) numInstance, output.getInstanceCount());
int spoutCount = 0;
int boltCount = 0;
for (PackingPlan.ContainerPlan container : output.getContainers()) {
Assert.assertEquals(numInstance / numContainers, container.getInstances().size());
for (PackingPlan.InstancePlan instancePlan : container.getInstances()) {
if (SPOUT_NAME.equals(instancePlan.getComponentName())) {
spoutCount++;
} else if (BOLT_NAME.equals(instancePlan.getComponentName())) {
boltCount++;
}
}
}
Assert.assertEquals(componentParallelism - 1, spoutCount);
Assert.assertEquals(componentParallelism + 1, boltCount);
}
use of com.twitter.heron.spi.common.Config in project incubator-heron by apache.
the class RoundRobinPackingTest method testDefaultResources.
@Test
public void testDefaultResources() throws Exception {
int numContainers = 2;
int spoutParallelism = 4;
int boltParallelism = 3;
Integer totalInstances = spoutParallelism + boltParallelism;
// Set up the topology and its config
com.twitter.heron.api.Config topologyConfig = new com.twitter.heron.api.Config();
topologyConfig.put(com.twitter.heron.api.Config.TOPOLOGY_STMGRS, numContainers);
// No explicit resources required
TopologyAPI.Topology topologyNoExplicitResourcesConfig = getTopology(spoutParallelism, boltParallelism, topologyConfig);
PackingPlan packingPlanNoExplicitResourcesConfig = getRoundRobinPackingPlan(topologyNoExplicitResourcesConfig);
Assert.assertEquals(numContainers, packingPlanNoExplicitResourcesConfig.getContainers().size());
Assert.assertEquals(totalInstances, packingPlanNoExplicitResourcesConfig.getInstanceCount());
}
use of com.twitter.heron.spi.common.Config in project incubator-heron by apache.
the class RoundRobinPackingTest method getRoundRobinRePackingPlan.
private PackingPlan getRoundRobinRePackingPlan(TopologyAPI.Topology topology, Map<String, Integer> componentChanges) {
Config config = PackingTestUtils.newTestConfig(topology);
RoundRobinPacking packing = new RoundRobinPacking();
packing.initialize(config, topology);
PackingPlan pp = packing.pack();
return packing.repack(pp, componentChanges);
}
use of com.twitter.heron.spi.common.Config in project incubator-heron by apache.
the class RoundRobinPackingTest method getRoundRobinPackingPlan.
private PackingPlan getRoundRobinPackingPlan(TopologyAPI.Topology topology) {
Config config = PackingTestUtils.newTestConfig(topology);
RoundRobinPacking packing = new RoundRobinPacking();
packing.initialize(config, topology);
return packing.pack();
}
Aggregations