Search in sources :

Example 16 with Config

use of org.apache.heron.api.Config in project heron by twitter.

the class TopologyUtilsTest method testGetComponentCpuMapSomeCpuSpecified.

@Test
public void testGetComponentCpuMapSomeCpuSpecified() {
    int componentParallelism = 2;
    Config topologyConfig = new Config();
    Map<String, Integer> spouts = new HashMap<>();
    spouts.put("spout", componentParallelism);
    Map<String, Integer> bolts = new HashMap<>();
    bolts.put("bolt", componentParallelism);
    double spoutCpu = 2.0f;
    topologyConfig.setComponentCpu("spout", spoutCpu);
    // sort the component CPU map
    Map<String, Double> cpuMap = new TreeMap<>(TopologyUtils.getComponentCpuMapConfig(TopologyTests.createTopology("test", topologyConfig, spouts, bolts)));
    // Component CPU map sets only spout's CPU
    Assert.assertArrayEquals(new String[] { "spout" }, cpuMap.keySet().toArray());
    Assert.assertArrayEquals(new Double[] { spoutCpu }, cpuMap.values().toArray());
}
Also used : HashMap(java.util.HashMap) Config(org.apache.heron.api.Config) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 17 with Config

use of org.apache.heron.api.Config in project heron by twitter.

the class TopologyUtilsTest method testGetComponentCpuMapDefaultValue.

@Test
public void testGetComponentCpuMapDefaultValue() {
    int componentParallelism = 2;
    Config topologyConfig = new Config();
    Map<String, Integer> spouts = new HashMap<>();
    spouts.put("spout", componentParallelism);
    Map<String, Integer> bolts = new HashMap<>();
    bolts.put("bolt", componentParallelism);
    // sort the component CPU map
    Map<String, Double> cpuMap = new TreeMap<>(TopologyUtils.getComponentCpuMapConfig(TopologyTests.createTopology("test", topologyConfig, spouts, bolts)));
    // Component CPU map is not set, the cpuMap size should be 0
    Assert.assertEquals(0, cpuMap.size());
}
Also used : HashMap(java.util.HashMap) Config(org.apache.heron.api.Config) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 18 with Config

use of org.apache.heron.api.Config in project heron by twitter.

the class TopologyUtilsTest method testGetComponentDiskMapDefaultValue.

@Test
public void testGetComponentDiskMapDefaultValue() {
    int componentParallelism = 2;
    Config topologyConfig = new Config();
    Map<String, Integer> spouts = new HashMap<>();
    spouts.put("spout", componentParallelism);
    Map<String, Integer> bolts = new HashMap<>();
    bolts.put("bolt", componentParallelism);
    // sort the component disk map
    Map<String, ByteAmount> diskMap = new TreeMap<>(TopologyUtils.getComponentDiskMapConfig(TopologyTests.createTopology("test", topologyConfig, spouts, bolts)));
    // Component disk map is not set, the diskMap size should be 0
    Assert.assertEquals(0, diskMap.size());
}
Also used : ByteAmount(org.apache.heron.common.basics.ByteAmount) HashMap(java.util.HashMap) Config(org.apache.heron.api.Config) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 19 with Config

use of org.apache.heron.api.Config in project heron by twitter.

the class TopologyUtilsTest method testGetComponentDiskMapAllDiskSpecified.

@Test
public void testGetComponentDiskMapAllDiskSpecified() {
    int componentParallelism = 2;
    Config topologyConfig = new Config();
    Map<String, Integer> spouts = new HashMap<>();
    spouts.put("spout", componentParallelism);
    Map<String, Integer> bolts = new HashMap<>();
    bolts.put("bolt", componentParallelism);
    ByteAmount boltDisk = ByteAmount.fromGigabytes(1);
    ByteAmount spoutDisk = ByteAmount.fromGigabytes(2);
    topologyConfig.setComponentDisk("spout", spoutDisk);
    topologyConfig.setComponentDisk("bolt", boltDisk);
    // sort the component disk map
    Map<String, ByteAmount> diskMap = new TreeMap<>(TopologyUtils.getComponentDiskMapConfig(TopologyTests.createTopology("test", topologyConfig, spouts, bolts)));
    Assert.assertArrayEquals(new String[] { "bolt", "spout" }, diskMap.keySet().toArray());
    Assert.assertArrayEquals(new ByteAmount[] { boltDisk, spoutDisk }, diskMap.values().toArray());
}
Also used : ByteAmount(org.apache.heron.common.basics.ByteAmount) HashMap(java.util.HashMap) Config(org.apache.heron.api.Config) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 20 with Config

use of org.apache.heron.api.Config in project heron by twitter.

the class HeronEcoBuilderTest method testBuildTopologyBuilder_BuildsAsExpected.

@Test
public void testBuildTopologyBuilder_BuildsAsExpected() throws IllegalAccessException, ClassNotFoundException, InstantiationException, NoSuchFieldException, InvocationTargetException {
    Config config = new Config();
    EcoExecutionContext context = new EcoExecutionContext(ecoTopologyDefinition, config);
    ObjectBuilder objectBuilder = new ObjectBuilder();
    subject.buildTopologyBuilder(context, objectBuilder);
    verify(mockSpoutBuilder).buildSpouts(same(context), any(TopologyBuilder.class), same(objectBuilder));
    verify(mockBoltBuilder).buildBolts(same(context), same(objectBuilder));
    verify(mockStreamBuilder).buildStreams(same(context), any(TopologyBuilder.class), same(objectBuilder));
    verify(mockComponentBuilder).buildComponents(same(context), same(objectBuilder));
}
Also used : TopologyBuilder(org.apache.heron.api.topology.TopologyBuilder) Config(org.apache.heron.api.Config) EcoExecutionContext(org.apache.heron.eco.definition.EcoExecutionContext) ObjectBuilder(org.apache.heron.eco.builder.ObjectBuilder) Test(org.junit.Test)

Aggregations

Config (org.apache.heron.api.Config)74 Test (org.junit.Test)35 TopologyBuilder (org.apache.heron.api.topology.TopologyBuilder)21 HashMap (java.util.HashMap)16 EcoTopologyDefinition (org.apache.heron.eco.definition.EcoTopologyDefinition)10 TreeMap (java.util.TreeMap)9 ByteArrayInputStream (java.io.ByteArrayInputStream)8 FileInputStream (java.io.FileInputStream)8 InputStream (java.io.InputStream)8 Fields (org.apache.heron.api.tuple.Fields)7 EcoParser (org.apache.heron.eco.parser.EcoParser)7 Map (java.util.Map)6 TopologyAPI (org.apache.heron.api.generated.TopologyAPI)6 ByteAmount (org.apache.heron.common.basics.ByteAmount)6 Simulator (org.apache.heron.simulator.Simulator)6 LinkedList (java.util.LinkedList)5 List (java.util.List)5 TopologyContext (org.apache.heron.api.topology.TopologyContext)5 Tuple (org.apache.heron.api.tuple.Tuple)5 TestWordSpout (org.apache.heron.examples.api.spout.TestWordSpout)5