Exemplo n.º 1
0
    def _handle_data_tuple(self, data_tuple, stream):
        start_time = time.time()

        values = []
        for value in data_tuple.values:
            values.append(self.serializer.deserialize(value))

        # create HeronTuple
        tup = TupleHelper.make_tuple(stream,
                                     data_tuple.key,
                                     values,
                                     roots=data_tuple.roots)

        deserialized_time = time.time()
        self.bolt_impl.process(tup)
        execute_latency_ns = (time.time() -
                              deserialized_time) * system_constants.SEC_TO_NS
        deserialize_latency_ns = (deserialized_time -
                                  start_time) * system_constants.SEC_TO_NS

        self.pplan_helper.context.invoke_hook_bolt_execute(
            tup, execute_latency_ns)

        self.bolt_metrics.deserialize_data_tuple(stream.id,
                                                 stream.component_name,
                                                 deserialize_latency_ns)
        self.bolt_metrics.execute_tuple(stream.id, stream.component_name,
                                        execute_latency_ns)
Exemplo n.º 2
0
  def test_normal_tuple(self):
    STREAM = mock_protobuf.get_mock_stream_id(id="stream_id", component_name="comp_name")
    TUPLE_KEY = "tuple_key"
    VALUES = mock_generator.prim_list

    # No roots
    tup = TupleHelper.make_tuple(STREAM, TUPLE_KEY, VALUES)
    self.assertEqual(tup.id, TUPLE_KEY)
    self.assertEqual(tup.component, STREAM.component_name)
    self.assertEqual(tup.stream, STREAM.id)
    self.assertIsNone(tup.task)
    self.assertEqual(tup.values, VALUES)
    self.assertAlmostEqual(tup.creation_time, time.time(), delta=0.01)
    self.assertIsNone(tup.roots)
Exemplo n.º 3
0
  def test_normal_tuple(self):
    STREAM = mock_protobuf.get_mock_stream_id(id="stream_id", component_name="comp_name")
    TUPLE_KEY = "tuple_key"
    VALUES = mock_generator.prim_list

    # No roots
    tup = TupleHelper.make_tuple(STREAM, TUPLE_KEY, VALUES)
    self.assertEqual(tup.id, TUPLE_KEY)
    self.assertEqual(tup.component, STREAM.component_name)
    self.assertEqual(tup.stream, STREAM.id)
    self.assertIsNone(tup.task)
    self.assertEqual(tup.values, VALUES)
    self.assertAlmostEqual(tup.creation_time, time.time(), delta=0.01)
    self.assertIsNone(tup.roots)
Exemplo n.º 4
0
  def _handle_data_tuple(self, data_tuple, stream):
    start_time = time.time()

    values = []
    for value in data_tuple.values:
      values.append(self.serializer.deserialize(value))

    # create HeronTuple
    tup = TupleHelper.make_tuple(stream, data_tuple.key, values, roots=data_tuple.roots)

    deserialized_time = time.time()
    self.bolt_impl.process(tup)
    execute_latency_ns = (time.time() - deserialized_time) * system_constants.SEC_TO_NS
    deserialize_latency_ns = (deserialized_time - start_time) * system_constants.SEC_TO_NS

    self.pplan_helper.context.invoke_hook_bolt_execute(tup, execute_latency_ns)

    self.bolt_metrics.deserialize_data_tuple(stream.id, stream.component_name,
                                             deserialize_latency_ns)
    self.bolt_metrics.execute_tuple(stream.id, stream.component_name, execute_latency_ns)