Search in sources :

Example 1 with Config

use of com.twitter.heron.api.Config in project heron by twitter.

the class TopologyUtilsTest method testGetComponentRamMapDefaultValue.

@Test
public void testGetComponentRamMapDefaultValue() {
    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 ram map
    Map<String, ByteAmount> ramMap = new TreeMap<>(TopologyUtils.getComponentRamMapConfig(TopologyTests.createTopology("test", topologyConfig, spouts, bolts)));
    // Component ram map is not set, the ramMap size should be 0
    Assert.assertEquals(0, ramMap.size());
}
Also used : ByteAmount(com.twitter.heron.common.basics.ByteAmount) HashMap(java.util.HashMap) Config(com.twitter.heron.api.Config) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 2 with Config

use of com.twitter.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(com.twitter.heron.common.basics.ByteAmount) HashMap(java.util.HashMap) Config(com.twitter.heron.api.Config) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 3 with Config

use of com.twitter.heron.api.Config in project heron by twitter.

the class TopologyUtilsTest method testValidTopology.

@Test
public void testValidTopology() {
    int componentParallelism = 2;
    Map<String, Integer> spouts = new HashMap<>();
    spouts.put("spout", componentParallelism);
    Map<String, Integer> bolts = new HashMap<>();
    bolts.put("bolt", componentParallelism);
    Map<String, String> connections = new HashMap<>();
    connections.put("bolt", "spout");
    Assert.assertTrue(TopologyUtils.verifyTopology(TopologyTests.createTopologyWithConnection("testTopology", /* Bad topology name */
    new Config(), spouts, bolts, connections)));
}
Also used : HashMap(java.util.HashMap) Config(com.twitter.heron.api.Config) Test(org.junit.Test)

Example 4 with Config

use of com.twitter.heron.api.Config in project heron by twitter.

the class TopologyUtilsTest method testGetTotalInstance.

@Test
public void testGetTotalInstance() {
    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);
    Assert.assertEquals((spouts.size() + bolts.size()) * componentParallelism, TopologyUtils.getTotalInstance(topology));
}
Also used : HashMap(java.util.HashMap) Config(com.twitter.heron.api.Config) TopologyAPI(com.twitter.heron.api.generated.TopologyAPI) Test(org.junit.Test)

Example 5 with Config

use of com.twitter.heron.api.Config in project incubator-heron by apache.

the class ConfigUtils method translateComponentConfig.

/**
 * Translate storm config to heron config for components
 * @param stormConfig the storm config
 * @return a heron config
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Config translateComponentConfig(Map stormConfig) {
    Config heronConfig;
    if (stormConfig != null) {
        heronConfig = new Config((Map<String, Object>) stormConfig);
    } else {
        heronConfig = new Config();
    }
    doStormTranslation(heronConfig);
    return heronConfig;
}
Also used : Config(com.twitter.heron.api.Config) Map(java.util.Map)

Aggregations

Config (com.twitter.heron.api.Config)80 Test (org.junit.Test)39 TopologyBuilder (com.twitter.heron.api.topology.TopologyBuilder)25 HashMap (java.util.HashMap)22 Fields (com.twitter.heron.api.tuple.Fields)14 TopologyAPI (com.twitter.heron.api.generated.TopologyAPI)12 EcoTopologyDefinition (com.twitter.heron.eco.definition.EcoTopologyDefinition)12 TreeMap (java.util.TreeMap)12 ByteAmount (com.twitter.heron.common.basics.ByteAmount)9 FileInputStream (java.io.FileInputStream)9 EcoParser (com.twitter.heron.eco.parser.EcoParser)8 ByteArrayInputStream (java.io.ByteArrayInputStream)8 InputStream (java.io.InputStream)8 Map (java.util.Map)6 TopologyArgParser (com.github.ashvina.common.TopologyArgParser)5 TopologyContext (com.twitter.heron.api.topology.TopologyContext)5 Tuple (com.twitter.heron.api.tuple.Tuple)5 TestTopologyBuilder (com.twitter.heron.integration_test.core.TestTopologyBuilder)4 LinkedList (java.util.LinkedList)4 List (java.util.List)4