use of com.twitter.heron.api.Config in project heron by twitter.
the class CustomGroupingTest method constructPhysicalPlan.
private PhysicalPlans.PhysicalPlan constructPhysicalPlan(MyCustomGrouping myCustomGrouping) {
PhysicalPlans.PhysicalPlan.Builder pPlan = PhysicalPlans.PhysicalPlan.newBuilder();
// Set topology protobuf
TopologyBuilder topologyBuilder = new TopologyBuilder();
topologyBuilder.setSpout("test-spout", new TestSpout(), 1);
// Here we need case switch to corresponding grouping
topologyBuilder.setBolt("test-bolt", new TestBolt(), 1).customGrouping("test-spout", myCustomGrouping);
Config conf = new Config();
conf.setTeamEmail("streaming-compute@twitter.com");
conf.setTeamName("stream-computing");
conf.setTopologyProjectName("heron-integration-test");
conf.setNumStmgrs(1);
conf.setMaxSpoutPending(100);
conf.setEnableAcking(false);
TopologyAPI.Topology fTopology = topologyBuilder.createTopology().setName("topology-name").setConfig(conf).setState(TopologyAPI.TopologyState.RUNNING).getTopology();
pPlan.setTopology(fTopology);
// Set instances
// Construct the spoutInstance
PhysicalPlans.InstanceInfo.Builder spoutInstanceInfo = PhysicalPlans.InstanceInfo.newBuilder();
spoutInstanceInfo.setComponentName("test-spout");
spoutInstanceInfo.setTaskId(0);
spoutInstanceInfo.setComponentIndex(0);
PhysicalPlans.Instance.Builder spoutInstance = PhysicalPlans.Instance.newBuilder();
spoutInstance.setInstanceId("spout-id");
spoutInstance.setStmgrId("stream-manager-id");
spoutInstance.setInfo(spoutInstanceInfo);
// Construct the boltInstanceInfo
PhysicalPlans.InstanceInfo.Builder boltInstanceInfo = PhysicalPlans.InstanceInfo.newBuilder();
boltInstanceInfo.setComponentName("test-bolt");
boltInstanceInfo.setTaskId(1);
boltInstanceInfo.setComponentIndex(0);
PhysicalPlans.Instance.Builder boltInstance = PhysicalPlans.Instance.newBuilder();
boltInstance.setInstanceId("bolt-id");
boltInstance.setStmgrId("stream-manager-id");
boltInstance.setInfo(boltInstanceInfo);
pPlan.addInstances(spoutInstance);
pPlan.addInstances(boltInstance);
// Set stream mgr
PhysicalPlans.StMgr.Builder stmgr = PhysicalPlans.StMgr.newBuilder();
stmgr.setId("stream-manager-id");
stmgr.setHostName("127.0.0.1");
stmgr.setDataPort(8888);
stmgr.setLocalEndpoint("endpoint");
pPlan.addStmgrs(stmgr);
return pPlan.build();
}
use of com.twitter.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());
}
use of com.twitter.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());
}
use of com.twitter.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)));
}
use of com.twitter.heron.api.Config in project heron by twitter.
the class PhysicalPlanUtilTest method getTestTopology.
/**
* Construct the test topology
*/
public static TopologyAPI.Topology getTestTopology() {
TopologyBuilder topologyBuilder = new TopologyBuilder();
topologyBuilder.setSpout("word", new BaseRichSpout() {
private static final long serialVersionUID = 5406114907377311020L;
@Override
public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) {
outputFieldsDeclarer.declare(new Fields("word"));
}
@Override
public void open(Map<String, Object> map, TopologyContext topologyContext, SpoutOutputCollector spoutOutputCollector) {
}
@Override
public void nextTuple() {
}
}, 2);
topologyBuilder.setBolt("exclaim", new BaseBasicBolt() {
private static final long serialVersionUID = 4398578755681473899L;
@Override
public void execute(Tuple tuple, BasicOutputCollector basicOutputCollector) {
}
@Override
public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) {
}
}, 2).shuffleGrouping("word");
Config conf = new Config();
conf.setDebug(true);
conf.setMaxSpoutPending(10);
conf.put(Config.TOPOLOGY_WORKER_CHILDOPTS, "-XX:+HeapDumpOnOutOfMemoryError");
conf.setComponentRam("word", ByteAmount.fromMegabytes(500));
conf.setComponentRam("exclaim", ByteAmount.fromGigabytes(1));
conf.setMessageTimeoutSecs(1);
return topologyBuilder.createTopology().setName("topology-name").setConfig(conf).setState(TopologyAPI.TopologyState.RUNNING).getTopology();
}
Aggregations