Search in sources :

Example 36 with Tuple

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);
        }
    }
}
Also used : Tuple(backtype.storm.tuple.Tuple)

Example 37 with Tuple

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);
}
Also used : Tuple(backtype.storm.tuple.Tuple)

Example 38 with Tuple

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;
}
Also used : KryoException(com.esotericsoftware.kryo.KryoException) KryoTupleDeserializer(backtype.storm.serialization.KryoTupleDeserializer) Tuple(backtype.storm.tuple.Tuple)

Example 39 with Tuple

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;
}
Also used : TopoMasterCtrlEvent(com.alibaba.jstorm.task.master.ctrlevent.TopoMasterCtrlEvent) TupleInfo(com.alibaba.jstorm.task.comm.TupleInfo) AckSpoutMsg(com.alibaba.jstorm.task.execute.spout.AckSpoutMsg) ICtrlMsgSpout(com.alibaba.jstorm.client.spout.ICtrlMsgSpout) CtrlMsgSpout(com.alibaba.jstorm.client.spout.CtrlMsgSpout) ICtrlMsgSpout(com.alibaba.jstorm.client.spout.ICtrlMsgSpout) FailSpoutMsg(com.alibaba.jstorm.task.execute.spout.FailSpoutMsg) Map(java.util.Map) RotatingMap(com.alibaba.jstorm.utils.RotatingMap) Tuple(backtype.storm.tuple.Tuple)

Example 40 with Tuple

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);
    }
}
Also used : Tuple(backtype.storm.tuple.Tuple)

Aggregations

Tuple (backtype.storm.tuple.Tuple)49 Values (backtype.storm.tuple.Values)11 ArrayList (java.util.ArrayList)10 MessageId (backtype.storm.tuple.MessageId)5 List (java.util.List)5 Test (org.testng.annotations.Test)5 Message (com.yahoo.pulsar.client.api.Message)4 TupleImpl (backtype.storm.tuple.TupleImpl)3 TupleImplExt (backtype.storm.tuple.TupleImplExt)3 Pair (com.alibaba.jstorm.utils.Pair)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 GlobalStreamId (backtype.storm.generated.GlobalStreamId)2 FailedException (backtype.storm.topology.FailedException)2 TupleExt (backtype.storm.tuple.TupleExt)2 TimerTrigger (com.alibaba.jstorm.daemon.worker.timer.TimerTrigger)2 TopoMasterCtrlEvent (com.alibaba.jstorm.task.master.ctrlevent.TopoMasterCtrlEvent)2 RotatingMap (com.alibaba.jstorm.utils.RotatingMap)2 Pair (com.alipay.dw.jstorm.example.sequence.bean.Pair)2 TradeCustomer (com.alipay.dw.jstorm.example.sequence.bean.TradeCustomer)2