예제 #1
0
    def _get_spout(self):
        """Returns Spout protobuf message"""
        spout = topology_pb2.Spout()
        spout.comp.CopyFrom(self._get_base_component())

        # Add output streams
        self._add_out_streams(spout)
        return spout
예제 #2
0
 def create_mock_spout(self, spout_name, output_streams, spout_parallelism):
     spout = protoTopology.Spout()
     spout.comp.name = spout_name
     kv = spout.comp.config.kvs.add()
     kv.key = constants.TOPOLOGY_COMPONENT_PARALLELISM
     kv.value = str(spout_parallelism)
     for stream in output_streams:
         spout.outputs.add().stream.CopyFrom(stream)
     return spout
예제 #3
0
def get_mock_spout(component=get_mock_component(), outputs=[]):
    """Returns a mock protobuf Spout object from topology_pb2"""
    spout = topology_pb2.Spout()
    spout.comp.CopyFrom(component)

    for out in outputs:
        added = spout.outputs.add()
        added.CopyFrom(out)

    return spout