Search in sources :

Example 6 with BaseRichSpout

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

the class TopologyManagerTest method getTestTopology.

/**
 * Construct the test topology
 */
public static TopologyAPI.Topology getTestTopology() {
    TopologyBuilder topologyBuilder = new TopologyBuilder();
    topologyBuilder.setSpout(STREAM_ID, new BaseRichSpout() {

        private static final long serialVersionUID = 5406114907377311020L;

        @Override
        public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) {
            outputFieldsDeclarer.declare(new Fields(STREAM_ID));
        }

        @Override
        public void open(Map<String, Object> map, TopologyContext topologyContext, SpoutOutputCollector spoutOutputCollector) {
        }

        @Override
        public void nextTuple() {
        }
    }, 2);
    topologyBuilder.setBolt(BOLT_ID, new BaseBasicBolt() {

        private static final long serialVersionUID = 4398578755681473899L;

        @Override
        public void execute(Tuple tuple, BasicOutputCollector basicOutputCollector) {
        }

        @Override
        public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) {
        }
    }, 2).shuffleGrouping(STREAM_ID);
    Config conf = new Config();
    conf.setDebug(true);
    conf.setMaxSpoutPending(10);
    conf.put(Config.TOPOLOGY_WORKER_CHILDOPTS, "-XX:+HeapDumpOnOutOfMemoryError");
    conf.setComponentRam(STREAM_ID, ByteAmount.fromMegabytes(500));
    conf.setComponentRam(BOLT_ID, 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

BaseBasicBolt (com.twitter.heron.api.bolt.BaseBasicBolt)6 BasicOutputCollector (com.twitter.heron.api.bolt.BasicOutputCollector)6 BaseRichSpout (com.twitter.heron.api.spout.BaseRichSpout)6 SpoutOutputCollector (com.twitter.heron.api.spout.SpoutOutputCollector)6 OutputFieldsDeclarer (com.twitter.heron.api.topology.OutputFieldsDeclarer)6 TopologyBuilder (com.twitter.heron.api.topology.TopologyBuilder)6 TopologyContext (com.twitter.heron.api.topology.TopologyContext)6 Tuple (com.twitter.heron.api.tuple.Tuple)6 HeronTopology (com.twitter.heron.api.HeronTopology)4 Fields (com.twitter.heron.api.tuple.Fields)4 Config (com.twitter.heron.api.Config)2 BoltDeclarer (com.twitter.heron.api.topology.BoltDeclarer)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2