예제 #1
0
파일: runner.py 프로젝트: lucperkins/heron
 def run(self, name, config, builder):
   """Builds the topology and submits it"""
   if not isinstance(name, str):
     raise RuntimeError("Name has to be a string type")
   if not isinstance(config, Config):
     raise RuntimeError("config has to be a Config type")
   if not isinstance(builder, Builder):
     raise RuntimeError("builder has to be a Builder type")
   bldr = TopologyBuilder(name=name)
   builder.build(bldr)
   bldr.set_config(config._api_config)
   bldr.build_and_submit()
예제 #2
0
파일: runner.py 프로젝트: nlu90/heron
 def run(self, name, config, builder):
     """Builds the topology and submits it"""
     if not isinstance(name, str):
         raise RuntimeError("Name has to be a string type")
     if not isinstance(config, Config):
         raise RuntimeError("config has to be a Config type")
     if not isinstance(builder, Builder):
         raise RuntimeError("builder has to be a Builder type")
     bldr = TopologyBuilder(name=name)
     builder.build(bldr)
     bldr.set_config(config._api_config)
     bldr.build_and_submit()
예제 #3
0
파일: streamlet.py 프로젝트: thaorell/heron
 def run(self, name, config=None):
     """Runs the Streamlet. This is run as a Heron python topology under the name
    'name'. The config attached is passed on to this Heron topology
    Once submitted, run returns immediately
 """
     if name is None or not isinstance(name, str):
         raise RuntimeError("Job Name has to be a string")
     bldr = TopologyBuilder(name=name)
     stage_names = {}
     bldr = self._build(bldr, stage_names)
     if config is not None:
         if not isinstance(config, dict):
             raise RuntimeError("config has to be a dict")
         bldr.set_config(config)
     bldr.build_and_submit()
'''Example WindowSizeTopology'''
import sys

import heronpy.api.api_constants as constants
from heronpy.api.topology import TopologyBuilder
from heronpy.api.stream import Grouping
from heronpy.api.bolt.window_bolt import SlidingWindowBolt
from heron.examples.src.python.spout import WordSpout
from examples.src.python.bolt import WindowSizeBolt

# 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)
  count_bolt = builder.add_bolt("count_bolt", WindowSizeBolt, par=2,
                                inputs={word_spout: Grouping.fields('word')},
                                config={SlidingWindowBolt.WINDOW_DURATION_SECS: 10,
                                        SlidingWindowBolt.WINDOW_SLIDEINTERVAL_SECS: 2})

  topology_config = {constants.TOPOLOGY_RELIABILITY_MODE:
                         constants.TopologyReliabilityMode.ATLEAST_ONCE}
  builder.set_config(topology_config)

  builder.build_and_submit()
예제 #5
0
import sys

import heronpy.api.api_constants as constants
from heronpy.api.topology import TopologyBuilder
from heronpy.api.stream import Grouping
from heronpy.api.bolt.window_bolt import SlidingWindowBolt
from heron.examples.src.python.spout import WordSpout
from examples.src.python.bolt import WindowSizeBolt

# Topology is defined using a topology builder
# Refer to multi_stream_topology for defining a topology by subclassing Topology
# pylint: disable=superfluous-parens
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)
  count_bolt = builder.add_bolt("count_bolt", WindowSizeBolt, par=2,
                                inputs={word_spout: Grouping.fields('word')},
                                config={SlidingWindowBolt.WINDOW_DURATION_SECS: 10,
                                        SlidingWindowBolt.WINDOW_SLIDEINTERVAL_SECS: 2})

  topology_config = {constants.TOPOLOGY_RELIABILITY_MODE:
                         constants.TopologyReliabilityMode.ATLEAST_ONCE}
  builder.set_config(topology_config)

  builder.build_and_submit()