Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def emit(self, tup, stream=Stream.DEFAULT_STREAM_ID, anchors=None,
direct_task=None, need_task_ids=False):
Log.info("emitting tuple: %s", tup)
if tup is None:
super(IntegrationTestBolt, self).emit(list(self.current_tuple_processing),
stream=stream, anchors=anchors,
direct_task=direct_task, need_task_ids=need_task_ids)
else:
super(IntegrationTestBolt, self).emit(tup, stream, anchors, direct_task, need_task_ids)
:param stream_id: stream id
"""
# child has to be a bolt
child_component_spec = self.bolts[child]
# child_inputs is dict mapping from grouping>
child_inputs = child_component_spec.inputs
if parent in self.bolts:
parent_component_spec = self.bolts[parent]
else:
parent_component_spec = self.spouts[parent]
if stream_id == Stream.DEFAULT_STREAM_ID:
child_inputs[parent_component_spec] = Grouping.ALL
else:
child_inputs[parent_component_spec[stream_id]] = Grouping.ALL
def none_grouping_builder(topology_name, http_server_url):
"""Integration test topology builder for none grouping"""
builder = TestTopologyBuilder(topology_name, http_server_url)
ab_spout = builder.add_spout("ab-spout", ABSpout, 1)
builder.add_bolt("identity-bolt", IdentityBolt,
inputs={ab_spout: Grouping.NONE},
par=3,
optional_outputs=['word'])
return builder.create_topology()
def multi_spouts_multi_tasks_builder(topology_name, http_server_url):
builder = TestTopologyBuilder(topology_name, http_server_url)
spout_1 = builder.add_spout("ab-spout-1", ABSpout, 3)
spout_2 = builder.add_spout("ab-spout-2", ABSpout, 3)
builder.add_bolt("identity-bolt", IdentityBolt,
inputs={spout_1: Grouping.SHUFFLE,
spout_2: Grouping.SHUFFLE},
par=1,
optional_outputs=['word'])
return builder.create_topology()
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()
def one_spout_two_bolts_builder(topology_name, http_server_url):
builder = TestTopologyBuilder(topology_name, http_server_url)
ab_spout = builder.add_spout("ab-spout", ABSpout, 1)
builder.add_bolt("identity-bolt-1", IdentityBolt,
inputs={ab_spout: Grouping.SHUFFLE},
par=1,
optional_outputs=['word'])
builder.add_bolt("identity-bolt-2", IdentityBolt,
inputs={ab_spout: Grouping.SHUFFLE},
par=1,
optional_outputs=['word'])
return builder.create_topology()
# under the License.
"""Base bolt for integration tests"""
import copy
from heron.common.src.python.utils.log import Log
from heronpy.api.bolt.bolt import Bolt
from heronpy.api.stream import Stream
from heronpy.api.component.component_spec import HeronComponentSpec
import heron.common.src.python.pex_loader as pex_loader
from ..core import constants as integ_const
from .batch_bolt import BatchBolt
# pylint: disable=missing-docstring
class IntegrationTestBolt(Bolt):
"""Base bolt for integration test
Every bolt of integration test topology consists of this instance, each delegating user's bolt.
"""
outputs = [Stream(fields=[integ_const.INTEGRATION_TEST_TERMINAL],
name=integ_const.INTEGRATION_TEST_CONTROL_STREAM_ID)]
@classmethod
def spec(cls, name, par, inputs, config, user_bolt_classpath, user_output_fields=None):
python_class_path = "%s.%s" % (cls.__module__, cls.__name__)
config[integ_const.USER_BOLT_CLASSPATH] = user_bolt_classpath
# avoid modification to cls.outputs
_outputs = copy.copy(cls.outputs)
if user_output_fields is not None:
_outputs.extend(user_output_fields)
return HeronComponentSpec(name, python_class_path, is_spout=False, par=par,
def one_spout_bolt_multi_tasks_builder(topology_name, http_server_url):
builder = TestTopologyBuilder(topology_name, http_server_url)
ab_spout = builder.add_spout("ab-spout", ABSpout, 3)
builder.add_bolt("identity-bolt", IdentityBolt,
inputs={ab_spout: Grouping.SHUFFLE},
par=3,
optional_outputs=['word'])
return builder.create_topology()
def one_spout_multi_tasks_builder(topology_name, http_server_url):
builder = TestTopologyBuilder(topology_name, http_server_url)
ab_spout = builder.add_spout("ab-spout", ABSpout, 3)
builder.add_bolt("identity-bolt", IdentityBolt,
inputs={ab_spout: Grouping.SHUFFLE},
par=1,
optional_outputs=['word'])
return builder.create_topology()
def shuffle_grouping_builder(topology_name, http_server_url):
builder = TestTopologyBuilder(topology_name, http_server_url)
ab_spout = builder.add_spout("ab-spout", ABSpout, 1)
builder.add_bolt("identity-bolt", IdentityBolt,
inputs={ab_spout: Grouping.SHUFFLE},
par=3,
optional_outputs=['word'])
return builder.create_topology()