Search in sources :

Example 46 with Config

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));
}
Also used : Config(com.twitter.heron.spi.common.Config) Resource(com.twitter.heron.spi.packing.Resource) Before(org.junit.Before)

Example 47 with 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);
}
Also used : HashMap(java.util.HashMap) Config(com.twitter.heron.spi.common.Config) PackingPlan(com.twitter.heron.spi.packing.PackingPlan) TopologyAPI(com.twitter.heron.api.generated.TopologyAPI) Test(org.junit.Test)

Example 48 with Config

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());
}
Also used : Config(com.twitter.heron.spi.common.Config) PackingPlan(com.twitter.heron.spi.packing.PackingPlan) TopologyAPI(com.twitter.heron.api.generated.TopologyAPI) Test(org.junit.Test)

Example 49 with Config

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

Example 50 with Config

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();
}
Also used : Config(com.twitter.heron.spi.common.Config)

Aggregations

Config (com.twitter.heron.spi.common.Config)211 Test (org.junit.Test)125 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)60 PackingPlan (com.twitter.heron.spi.packing.PackingPlan)53 TopologyAPI (com.twitter.heron.api.generated.TopologyAPI)43 SchedulerStateManagerAdaptor (com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor)35 LauncherUtils (com.twitter.heron.scheduler.utils.LauncherUtils)19 IStateManager (com.twitter.heron.spi.statemgr.IStateManager)18 IScheduler (com.twitter.heron.spi.scheduler.IScheduler)17 HashMap (java.util.HashMap)16 Before (org.junit.Before)16 ILauncher (com.twitter.heron.spi.scheduler.ILauncher)14 IOException (java.io.IOException)13 Resource (com.twitter.heron.spi.packing.Resource)12 URI (java.net.URI)12 HashSet (java.util.HashSet)11 CommandLine (org.apache.commons.cli.CommandLine)10 ByteAmount (com.twitter.heron.common.basics.ByteAmount)9 ISchedulerClient (com.twitter.heron.scheduler.client.ISchedulerClient)9 File (java.io.File)9