def fields_grouping_builder(topology_name, http_server_url): builder = TestTopologyBuilder(topology_name, http_server_url) ab_spout = builder.add_spout("ab-spout", ABSpout, 1, max_executions=400) count_bolt = builder.add_bolt("count-bolt", WordCountBolt, inputs={ab_spout: Grouping.fields('word')}, par=2) builder.add_bolt("sum-bolt", CountAggregatorBolt, inputs={count_bolt: Grouping.NONE}, par=1) return builder.create_topology()
class MultiStream(Topology): spout = MultiStreamSpout.spec(par=2) count_bolt = CountBolt.spec( par=2, inputs={spout: Grouping.fields('word')}, config={constants.TOPOLOGY_TICK_TUPLE_FREQ_SECS: 10}) stream_aggregator = StreamAggregateBolt.spec( par=1, inputs={ spout: Grouping.ALL, spout['error']: Grouping.ALL }, config={constants.TOPOLOGY_TICK_TUPLE_FREQ_SECS: 15})
from heron.examples.src.python.spout import WordSpout from heron.examples.src.python.bolt import HalfAckBolt # Topology is defined using a topology builder # Refer to multi_stream_topology for defining a topology by subclassing Topology if __name__ == '__main__': if len(sys.argv) != 2: print "Topology's name is not specified" sys.exit(1) builder = TopologyBuilder(name=sys.argv[1]) word_spout = builder.add_spout("word_spout", WordSpout, par=2) half_ack_bolt = builder.add_bolt( "half_ack_bolt", HalfAckBolt, par=2, inputs={word_spout: Grouping.fields('word')}, config={constants.TOPOLOGY_TICK_TUPLE_FREQ_SECS: 10}) topology_config = { constants.TOPOLOGY_ENABLE_ACKING: True, constants.TOPOLOGY_MAX_SPOUT_PENDING: 100000000, constants.TOPOLOGY_MESSAGE_TIMEOUT_SECS: 300 } builder.set_config(topology_config) builder.build_and_submit()
# limitations under the License. '''Example HalfAckingTopology''' import sys from heron.pyheron.src.python import Grouping, TopologyBuilder, constants from heron.examples.src.python.spout import WordSpout from heron.examples.src.python.bolt import HalfAckBolt # Topology is defined using a topology builder # Refer to multi_stream_topology for defining a topology by subclassing Topology if __name__ == '__main__': if len(sys.argv) != 2: print "Topology's name is not specified" sys.exit(1) builder = TopologyBuilder(name=sys.argv[1]) word_spout = builder.add_spout("word_spout", WordSpout, par=2) half_ack_bolt = builder.add_bolt("half_ack_bolt", HalfAckBolt, par=2, inputs={word_spout: Grouping.fields('word')}, config={constants.TOPOLOGY_TICK_TUPLE_FREQ_SECS: 10}) topology_config = {constants.TOPOLOGY_ENABLE_ACKING: True, constants.TOPOLOGY_MAX_SPOUT_PENDING: 100000000, constants.TOPOLOGY_MESSAGE_TIMEOUT_SECS: 300} builder.set_config(topology_config) builder.build_and_submit()