示例#1
0
  private void handleDataTuple(HeronTuples.HeronDataTuple dataTuple, TopologyAPI.StreamId stream) {
    long startTime = System.nanoTime();

    List<Object> values = new ArrayList<>();
    for (ByteString b : dataTuple.getValuesList()) {
      values.add(serializer.deserialize(b.toByteArray()));
    }

    // Decode the tuple
    TupleImpl t =
        new TupleImpl(
            helper.getTopologyContext(),
            stream,
            dataTuple.getKey(),
            dataTuple.getRootsList(),
            values);

    long deserializedTime = System.nanoTime();

    // Delegate to the use defined bolt
    bolt.execute(t);

    long executeLatency = System.nanoTime() - deserializedTime;

    // Invoke user-defined execute task hook
    helper.getTopologyContext().invokeHookBoltExecute(t, executeLatency);

    boltMetrics.deserializeDataTuple(
        stream.getId(), stream.getComponentName(), deserializedTime - startTime);

    // Update metrics
    boltMetrics.executeTuple(stream.getId(), stream.getComponentName(), executeLatency);
  }
示例#2
0
  public void dump(TopologyAPI.Topology.Builder bldr) {
    TopologyAPI.Spout.Builder spoutBldr = TopologyAPI.Spout.newBuilder();

    TopologyAPI.Component.Builder compBldr = TopologyAPI.Component.newBuilder();
    super.dump(compBldr);
    spoutBldr.setComp(compBldr);

    Map<String, TopologyAPI.StreamSchema.Builder> outs = output.getFieldsDeclaration();
    for (Map.Entry<String, TopologyAPI.StreamSchema.Builder> entry : outs.entrySet()) {
      TopologyAPI.OutputStream.Builder obldr = TopologyAPI.OutputStream.newBuilder();
      TopologyAPI.StreamId.Builder sbldr = TopologyAPI.StreamId.newBuilder();
      sbldr.setId(entry.getKey());
      sbldr.setComponentName(getName());
      obldr.setStream(sbldr);
      obldr.setSchema(entry.getValue());
      spoutBldr.addOutputs(obldr);
    }

    bldr.addSpouts(spoutBldr);
  }