use of backtype.storm.tuple.Tuple in project jstorm by alibaba.
the class StatefulWindowedBoltExecutor method updateState.
private void updateState(Map<TaskStream, WindowState> state, List<Tuple> tuples, boolean newEvents) {
for (Tuple tuple : tuples) {
TaskStream taskStream = TaskStream.fromTuple(tuple);
WindowState curState = state.get(taskStream);
WindowState newState;
if ((newState = getUpdatedState(curState, getMsgId(tuple), newEvents)) != null) {
state.put(taskStream, newState);
}
}
}
use of backtype.storm.tuple.Tuple in project jstorm by alibaba.
the class ShellBolt method handleFail.
private void handleFail(Object id) {
Tuple failed = _inputs.remove(id);
if (failed == null) {
throw new RuntimeException("Failed a non-existent or already acked/failed id: " + id);
}
_collector.fail(failed);
}
use of backtype.storm.tuple.Tuple in project jstorm by alibaba.
the class VirtualPortCtrlDispatch method deserialize.
protected Object deserialize(byte[] ser_msg, int taskId) {
try {
if (ser_msg == null) {
return null;
}
if (ser_msg.length == 0) {
return null;
} else if (ser_msg.length == 1) {
//ignore
return null;
}
Tuple tuple = null;
// ser_msg.length > 1
KryoTupleDeserializer kryo = atomKryoDeserializer.get();
if (kryo != null)
tuple = kryo.deserialize(ser_msg);
return tuple;
} catch (Throwable e) {
if (Utils.exceptionCauseIsInstanceOf(KryoException.class, e))
throw new RuntimeException(e);
LOG.error(idStr + " recv thread error " + JStormUtils.toPrintableString(ser_msg) + "\n", e);
}
return null;
}
use of backtype.storm.tuple.Tuple 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;
}
use of backtype.storm.tuple.Tuple in project jstorm by alibaba.
the class TransactionBolt method processBatch.
public void processBatch(BatchGroupId batchGroupId, List<Tuple> batch) {
currentBatchTracker = getProcessingBatch(batchGroupId, true);
outputCollector.setCurrBatchTracker(currentBatchTracker);
for (Tuple batchTuple : batch) {
processBatchTuple(batchTuple);
}
}
Aggregations