use of com.alibaba.jstorm.task.comm.TupleInfo in project jstorm by alibaba.
the class SpoutBatchCollector method getMessageId.
protected MessageId getMessageId(SpoutMsgInfo msg, Map<Long, MsgInfo> ackBatch) {
MessageId msgId = null;
if (msg.rootId != null) {
Long as = MessageId.generateId(random);
msgId = MessageId.makeRootId(msg.rootId, as);
MsgInfo msgInfo = ackBatch.get(msg.rootId);
List<Object> ackerTuple;
if (msgInfo == null) {
TupleInfo info = new TupleInfo();
info.setStream(msg.streamId);
info.setValues(msg.values);
info.setMessageId(msg.messageId);
info.setTimestamp(System.currentTimeMillis());
pending.putHead(msg.rootId, info);
ackerTuple = JStormUtils.mk_list((Object) msg.rootId, JStormUtils.bit_xor_vals(as), task_id);
msgInfo = new SpoutMsgInfo(Acker.ACKER_INIT_STREAM_ID, ackerTuple, null, null, null, null);
ackBatch.put(msg.rootId, msgInfo);
} else {
ackerTuple = msgInfo.values;
ackerTuple.set(1, JStormUtils.bit_xor_vals(ackerTuple.get(1), as));
}
}
return msgId;
}
use of com.alibaba.jstorm.task.comm.TupleInfo in project jstorm by alibaba.
the class SpoutTimeoutCallBack method expire.
/**
* pending.put(root_id, JStormUtils.mk_list(message_id, TupleInfo, ms));
*/
@Override
public void expire(K key, V val) {
if (val == null) {
return;
}
try {
TupleInfo tupleInfo = (TupleInfo) val;
FailSpoutMsg fail = new FailSpoutMsg(key, spout, (TupleInfo) tupleInfo, task_stats);
disruptorEventQueue.publish(fail);
} catch (Exception e) {
LOG.error("expire error", e);
}
}
use of com.alibaba.jstorm.task.comm.TupleInfo in project jstorm by alibaba.
the class SpoutCollector method sendMsgToAck.
protected void sendMsgToAck(String out_stream_id, List<Object> values, Object message_id, Long root_id, List<Long> ackSeq, boolean needAck) {
if (needAck) {
TupleInfo info = new TupleInfo();
info.setStream(out_stream_id);
info.setValues(values);
info.setMessageId(message_id);
info.setTimestamp(System.currentTimeMillis());
pending.putHead(root_id, info);
List<Object> ackerTuple = JStormUtils.mk_list((Object) root_id, JStormUtils.bit_xor_vals(ackSeq), task_id);
unanchoredSend(topology_context, sendTargets, transfer_fn, Acker.ACKER_INIT_STREAM_ID, ackerTuple);
} else if (message_id != null) {
TupleInfo info = new TupleInfo();
info.setStream(out_stream_id);
info.setValues(values);
info.setMessageId(message_id);
info.setTimestamp(0);
AckSpoutMsg ack = new AckSpoutMsg(root_id, spout, null, info, task_stats);
ack.run();
}
}
use of com.alibaba.jstorm.task.comm.TupleInfo in project jstorm by alibaba.
the class SpoutExecutors method processTupleEvent.
private Runnable processTupleEvent(Tuple event) {
Runnable runnable = null;
Tuple tuple = (Tuple) event;
if (event.getSourceStreamId().equals(Common.TOPOLOGY_MASTER_CONTROL_STREAM_ID)) {
TopoMasterCtrlEvent ctrlEvent = (TopoMasterCtrlEvent) tuple.getValueByField("ctrlEvent");
if (ctrlEvent.isTransactionEvent()) {
if (spout instanceof ICtrlMsgSpout) {
runnable = new CtrlMsgSpout((ICtrlMsgSpout) spout, ctrlEvent);
}
} else if (ctrlEvent.isFinishInitEvent()) {
LOG.info("spout task-{} received topology finish init operation message", taskId);
taskHbTrigger.updateExecutorStatus(TaskStatus.RUN);
this.checkTopologyFinishInit = true;
} else {
LOG.warn("Received unexpected control event, {}", ctrlEvent);
}
} else if (event.getSourceStreamId().equals(Common.TOPOLOGY_MASTER_REGISTER_METRICS_RESP_STREAM_ID)) {
this.metricsReporter.updateMetricMeta((Map<String, Long>) tuple.getValue(0));
} else {
Object id = tuple.getValue(0);
Object obj = pending.remove((Long) id);
if (obj == null) {
if (JStormDebugger.isDebug(id)) {
LOG.info("Pending map no entry:" + id);
}
runnable = null;
} else {
TupleInfo tupleInfo = (TupleInfo) obj;
String stream_id = tuple.getSourceStreamId();
if (stream_id.equals(Acker.ACKER_ACK_STREAM_ID)) {
runnable = new AckSpoutMsg(id, spout, tuple, tupleInfo, task_stats);
} else if (stream_id.equals(Acker.ACKER_FAIL_STREAM_ID)) {
runnable = new FailSpoutMsg(id, spout, tupleInfo, task_stats);
} else {
LOG.warn("Receive one unknown source Tuple " + idStr);
runnable = null;
}
}
task_stats.recv_tuple(tuple.getSourceComponent(), tuple.getSourceStreamId());
}
return runnable;
}
Aggregations