예제 #1
0
    def __init__(self, pplan_helper, in_stream, out_stream, looper,
                 sys_config):
        super(SpoutInstance, self).__init__(pplan_helper, in_stream,
                                            out_stream, looper, sys_config)
        self.topology_state = topology_pb2.TopologyState.Value("PAUSED")

        if not self.pplan_helper.is_spout:
            raise RuntimeError("No spout in physicial plan")

        context = self.pplan_helper.context
        self.spout_metrics = SpoutMetrics(self.pplan_helper)
        self.serializer = SerializerHelper.get_serializer(context)

        # acking related
        self.acking_enabled = context.get_cluster_config().get(
            constants.TOPOLOGY_ENABLE_ACKING, False)
        self.enable_message_timeouts = \
          context.get_cluster_config().get(constants.TOPOLOGY_ENABLE_MESSAGE_TIMEOUTS)
        Log.info("Enable ACK: %s" % str(self.acking_enabled))
        Log.info("Enable Message Timeouts: %s" %
                 str(self.enable_message_timeouts))

        # map <tuple_info.key -> tuple_info>, ordered by insertion time
        self.in_flight_tuples = collections.OrderedDict()
        self.immediate_acks = collections.deque()
        self.total_tuples_emitted = 0

        # load user's spout class
        spout_impl_class = super(SpoutInstance,
                                 self).load_py_instance(is_spout=True)
        self.spout_impl = spout_impl_class(delegate=self)
예제 #2
0
    def __init__(self, pplan_helper, in_stream, out_stream, looper):
        super(SpoutInstance, self).__init__(pplan_helper, in_stream,
                                            out_stream, looper)
        self.topology_state = topology_pb2.TopologyState.Value("PAUSED")

        if not self.pplan_helper.is_spout:
            raise RuntimeError("No spout in physicial plan")

        context = self.pplan_helper.context
        self.spout_metrics = SpoutMetrics(self.pplan_helper)

        # acking related
        mode = context.get_cluster_config().get(
            api_constants.TOPOLOGY_RELIABILITY_MODE,
            api_constants.TopologyReliabilityMode.ATMOST_ONCE)
        self.acking_enabled = bool(
            mode == api_constants.TopologyReliabilityMode.ATLEAST_ONCE)
        self.enable_message_timeouts = \
          context.get_cluster_config().get(api_constants.TOPOLOGY_ENABLE_MESSAGE_TIMEOUTS)
        self._initialized_metrics_and_tasks = False
        Log.info("Enable ACK: %s" % str(self.acking_enabled))
        Log.info("Enable Message Timeouts: %s" %
                 str(self.enable_message_timeouts))

        # map <tuple_info.key -> tuple_info>, ordered by insertion time
        self.in_flight_tuples = collections.OrderedDict()
        self.immediate_acks = collections.deque()
        self.total_tuples_emitted = 0

        # load user's spout class
        spout_impl_class = super(SpoutInstance,
                                 self).load_py_instance(is_spout=True)
        self.spout_impl = spout_impl_class(delegate=self)