Ejemplo n.º 1
0
  def test_constructor(self):
    builder = TopologyBuilder("WordCount")
    self.assertEqual(builder.topology_name, "WordCount")

    with self.assertRaises(AssertionError):
      TopologyBuilder("Topology")

    with self.assertRaises(AssertionError):
      TopologyBuilder(123)

    with self.assertRaises(AssertionError):
      TopologyBuilder(None)
Ejemplo n.º 2
0
  def test_add_spec(self):
    builder = TopologyBuilder("Test")

    with self.assertRaises(ValueError):
      builder.add_spec(HeronComponentSpec(None, "path", True, 1))

    with self.assertRaises(TypeError):
      builder.add_spec(None)

    self.assertEqual(len(builder._specs), 0)

    # add 10 specs
    specs = []
    for i in range(10):
      specs.append(HeronComponentSpec(str(i), "path", True, 1))
    builder.add_spec(*specs)
    self.assertEqual(len(builder._specs), 10)
Ejemplo n.º 3
0
'''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
    }
Ejemplo n.º 4
0
# 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()