Search in sources :

Example 6 with TopologyBuilder

use of com.twitter.heron.api.topology.TopologyBuilder 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();
}
Also used : BaseBasicBolt(com.twitter.heron.api.bolt.BaseBasicBolt) TopologyBuilder(com.twitter.heron.api.topology.TopologyBuilder) Config(com.twitter.heron.api.Config) OutputFieldsDeclarer(com.twitter.heron.api.topology.OutputFieldsDeclarer) BasicOutputCollector(com.twitter.heron.api.bolt.BasicOutputCollector) Fields(com.twitter.heron.api.tuple.Fields) SpoutOutputCollector(com.twitter.heron.api.spout.SpoutOutputCollector) TopologyContext(com.twitter.heron.api.topology.TopologyContext) Tuple(com.twitter.heron.api.tuple.Tuple) BaseRichSpout(com.twitter.heron.api.spout.BaseRichSpout)

Aggregations

TopologyBuilder (com.twitter.heron.api.topology.TopologyBuilder)6 Config (com.twitter.heron.api.Config)3 HeronTopology (com.twitter.heron.api.HeronTopology)3 BaseBasicBolt (com.twitter.heron.api.bolt.BaseBasicBolt)3 BasicOutputCollector (com.twitter.heron.api.bolt.BasicOutputCollector)3 BaseRichSpout (com.twitter.heron.api.spout.BaseRichSpout)3 SpoutOutputCollector (com.twitter.heron.api.spout.SpoutOutputCollector)3 OutputFieldsDeclarer (com.twitter.heron.api.topology.OutputFieldsDeclarer)3 TopologyContext (com.twitter.heron.api.topology.TopologyContext)3 Tuple (com.twitter.heron.api.tuple.Tuple)3 TopologyAPI (com.twitter.heron.api.generated.TopologyAPI)2 Fields (com.twitter.heron.api.tuple.Fields)2 BoltDeclarer (com.twitter.heron.api.topology.BoltDeclarer)1 SystemConfig (com.twitter.heron.common.config.SystemConfig)1 TestBolt (com.twitter.heron.resource.TestBolt)1 TestSpout (com.twitter.heron.resource.TestSpout)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1