Search in sources :

Example 11 with Config

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

the class TopologyUtilsTest method testGetComponentRamMapSomeRamSpecified.

@Test
public void testGetComponentRamMapSomeRamSpecified() {
    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 spoutRam = ByteAmount.fromGigabytes(2);
    topologyConfig.setComponentRam("spout", spoutRam);
    // sort the component RAM map
    Map<String, ByteAmount> ramMap = new TreeMap<>(TopologyUtils.getComponentRamMapConfig(TopologyTests.createTopology("test", topologyConfig, spouts, bolts)));
    // Component RAM map sets only spout's RAM
    Assert.assertArrayEquals(new String[] { "spout" }, ramMap.keySet().toArray());
    Assert.assertArrayEquals(new ByteAmount[] { spoutRam }, ramMap.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 12 with Config

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

the class TopologyUtilsTest method testGetComponentDiskMapSomeDiskSpecified.

@Test
public void testGetComponentDiskMapSomeDiskSpecified() {
    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 spoutDisk = ByteAmount.fromGigabytes(2);
    topologyConfig.setComponentDisk("spout", spoutDisk);
    // sort the component disk map
    Map<String, ByteAmount> diskMap = new TreeMap<>(TopologyUtils.getComponentDiskMapConfig(TopologyTests.createTopology("test", topologyConfig, spouts, bolts)));
    // Component disk map sets only spout's disk
    Assert.assertArrayEquals(new String[] { "spout" }, diskMap.keySet().toArray());
    Assert.assertArrayEquals(new ByteAmount[] { 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 13 with Config

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

the class TopologyUtilsTest method testBadTopologyName.

@Test
public void testBadTopologyName() {
    int componentParallelism = 2;
    Map<String, Integer> spouts = new HashMap<>();
    spouts.put("spout", componentParallelism);
    Map<String, Integer> bolts = new HashMap<>();
    bolts.put("bolt", componentParallelism);
    Assert.assertFalse(TopologyUtils.verifyTopology(TopologyTests.createTopology("test.topology", /* Bad topology name */
    new Config(), spouts, bolts)));
}
Also used : HashMap(java.util.HashMap) Config(org.apache.heron.api.Config) Test(org.junit.Test)

Example 14 with Config

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

the class TopologyUtilsTest method testGetComponentParallelism.

@Test
public void testGetComponentParallelism() {
    int componentParallelism = 4;
    Config topologyConfig = new Config();
    Map<String, Integer> spouts = new HashMap<>();
    spouts.put("spout", componentParallelism);
    Map<String, Integer> bolts = new HashMap<>();
    bolts.put("bolt", componentParallelism);
    TopologyAPI.Topology topology = TopologyTests.createTopology("testTopology", topologyConfig, spouts, bolts);
    Map<String, Integer> componentParallelismMap = TopologyUtils.getComponentParallelism(topology);
    Assert.assertEquals(componentParallelism, componentParallelismMap.get("spout").intValue());
    Assert.assertEquals(componentParallelism, componentParallelismMap.get("bolt").intValue());
}
Also used : HashMap(java.util.HashMap) Config(org.apache.heron.api.Config) TopologyAPI(org.apache.heron.api.generated.TopologyAPI) Test(org.junit.Test)

Example 15 with Config

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

the class TopologyUtilsTest method testGetComponentRamMapAllRamSpecified.

@Test
public void testGetComponentRamMapAllRamSpecified() {
    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 boltRam = ByteAmount.fromGigabytes(1);
    ByteAmount spoutRam = ByteAmount.fromGigabytes(2);
    topologyConfig.setComponentRam("spout", spoutRam);
    topologyConfig.setComponentRam("bolt", boltRam);
    // sort the component RAM map
    Map<String, ByteAmount> ramMap = new TreeMap<>(TopologyUtils.getComponentRamMapConfig(TopologyTests.createTopology("test", topologyConfig, spouts, bolts)));
    Assert.assertArrayEquals(new String[] { "bolt", "spout" }, ramMap.keySet().toArray());
    Assert.assertArrayEquals(new ByteAmount[] { boltRam, spoutRam }, ramMap.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)

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