| 18 | import org.apache.storm.task.GeneralTopologyContext; |
| 19 | |
| 20 | public class TupleImpl implements Tuple { |
| 21 | private final String srcComponent; |
| 22 | private List<Object> values; |
| 23 | private int taskId; |
| 24 | private String streamId; |
| 25 | private GeneralTopologyContext context; |
| 26 | private MessageId id; |
| 27 | private Long processSampleStartTime; |
| 28 | private Long executeSampleStartTime; |
| 29 | private long outAckVal = 0; |
| 30 | |
| 31 | public TupleImpl(Tuple t) { |
| 32 | this.values = t.getValues(); |
| 33 | this.taskId = t.getSourceTask(); |
| 34 | this.streamId = t.getSourceStreamId(); |
| 35 | this.id = t.getMessageId(); |
| 36 | this.context = t.getContext(); |
| 37 | this.srcComponent = t.getSourceComponent(); |
| 38 | try { |
| 39 | TupleImpl ti = (TupleImpl) t; |
| 40 | this.processSampleStartTime = ti.processSampleStartTime; |
| 41 | this.executeSampleStartTime = ti.executeSampleStartTime; |
| 42 | this.outAckVal = ti.outAckVal; |
| 43 | } catch (ClassCastException e) { |
| 44 | // ignore ... if t is not a TupleImpl type .. faster than checking and then casting |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | public TupleImpl(GeneralTopologyContext context, List<Object> values, String srcComponent, int taskId, String streamId, MessageId id) { |
| 49 | this.values = context.doSanityCheck() ? Collections.unmodifiableList(values) : values; |
| 50 | this.taskId = taskId; |
| 51 | this.streamId = streamId; |
| 52 | this.id = id; |
| 53 | this.context = context; |
| 54 | this.srcComponent = srcComponent; |
| 55 | |
| 56 | if (context.doSanityCheck()) { |
| 57 | String componentId = context.getComponentId(taskId); |
| 58 | Fields schema = context.getComponentOutputFields(componentId, streamId); |
| 59 | if (values.size() != schema.size()) { |
| 60 | throw new IllegalArgumentException("Tuple created with wrong number of fields. Expected " + schema.size() |
| 61 | + " fields but got " + values.size() + " fields"); |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | public TupleImpl(GeneralTopologyContext context, List<Object> values, String srcComponent, int taskId, String streamId) { |
| 67 | this(context, values, srcComponent, taskId, streamId, MessageId.makeUnanchored()); |
| 68 | } |
| 69 | |
| 70 | public Long getProcessSampleStartTime() { |
| 71 | return processSampleStartTime; |
| 72 | } |
| 73 | |
| 74 | public void setProcessSampleStartTime(long ms) { |
| 75 | processSampleStartTime = ms; |
| 76 | } |
| 77 |
nothing calls this directly
no outgoing calls
no test coverage detected