public static boolean isCheckpoint(Tuple input) { return CHECKPOINT_STREAM_ID.equals(input.getSourceStreamId()); }
private BatchStatus getBatchStatus(Tuple tuple) { String streamId = tuple.getSourceStreamId(); if (streamId.equals(BatchDef.PREPARE_STREAM_ID)) { return BatchStatus.PREPARE_COMMIT; } else if (streamId.equals(BatchDef.COMMIT_STREAM_ID)) { return BatchStatus.COMMIT; } else if (streamId.equals(BatchDef.REVERT_STREAM_ID)) { return BatchStatus.REVERT_COMMIT; } else if (streamId.equals(BatchDef.POST_STREAM_ID)) { return BatchStatus.POST_COMMIT; } else { return BatchStatus.COMPUTING; } }
@Override public void execute(Tuple input) { Object value = input.getValue(0); if (input.getSourceStreamId().equals(TopologyMaster.USER_DEFINED_STREAM)) { TMUdfMessage message = (TMUdfMessage) value; LOG.info("Received TM UDF message trigged by task-{}", message.spoutTaskId); } else { LOG.info("Received unkown message: {}", input); } }
@Override public void execute(Tuple input) { IKvState<K, V> state = null; if (fieldGrouping.containsKey(input.getSourceStreamId())) { state = getSpecifiedKeyRangeState(input, fieldGrouping.get(input.getSourceStreamId())); } execute(input, state); }
@Override public void execute(BatchInfo batchInfo, Tuple tuple) { String sourceStream = tuple.getSourceStreamId(); InitialReceiver ir = _roots.get(sourceStream); if (ir == null) { throw new RuntimeException("Received unexpected tuple " + tuple.toString()); } ir.receive((ProcessorContext) batchInfo.state, tuple); }
public static boolean isTickTuple(Tuple tuple) { return tuple.getSourceComponent().equals(Constants.SYSTEM_COMPONENT_ID) && tuple.getSourceStreamId().equals(Constants.SYSTEM_TICK_STREAM_ID); } }
public static boolean isTick(Tuple tuple) { return tuple != null && Constants.SYSTEM_COMPONENT_ID.equals(tuple.getSourceComponent()) && Constants.SYSTEM_TICK_STREAM_ID.equals(tuple.getSourceStreamId()); }
private TupleType getTupleType(Tuple tuple) { if (_idStreamSpec != null && tuple.getSourceGlobalStreamid().equals(_idStreamSpec._id)) { return TupleType.ID; } else if (!_sourceArgs.isEmpty() && tuple.getSourceStreamId().equals(Constants.COORDINATED_STREAM_ID)) { return TupleType.COORD; } else { return TupleType.REGULAR; } }
private TupleType getTupleType(Tuple tuple, TrackedBatch batch) { CoordCondition cond = batch.condition; if (cond.commitStream != null && tuple.getSourceGlobalStreamid().equals(cond.commitStream)) { return TupleType.COMMIT; } else if (cond.expectedTaskReports > 0 && tuple.getSourceStreamId().startsWith(COORD_STREAM_PREFIX)) { return TupleType.COORD; } else { return TupleType.REGULAR; } }
public void execute(Tuple input) { String component = input.getSourceComponent(); Map<String, List<FixedTuple>> captured = emitted_tuples.get(_name); if (!captured.containsKey(component)) { captured.put(component, new ArrayList<FixedTuple>()); } captured.get(component).add(new FixedTuple(input.getSourceStreamId(), input.getValues())); _collector.ack(input); }
@Override public void execute(Tuple input) { TMHandler tmHandler = handlers.get(input.getSourceStreamId()); if (tmHandler == null) { LOG.error("No handler of " + input.getSourceStreamId()); tmContext.getCollector().fail(input); return; } TMEvent event = new TMEvent(tmHandler, input); threadPools.submit(event); tmContext.getCollector().ack(input); }
/** * Gets the names of the fields in this tuple. */ public Fields getFields() { return context.getComponentOutputFields(getSourceComponent(), getSourceStreamId()); }
@Override public void ack(Tuple input) { if (input.getMessageId() != null) { if (!sendAckTuple(input)) { pendingAckQueue.add(input); } } Long latencyStart = (Long) tupleStartTimes.remove(input); taskStats.bolt_acked_tuple(input.getSourceComponent(), input.getSourceStreamId()); if (latencyStart != null && JStormMetrics.enabled) { long endTime = System.currentTimeMillis(); taskStats.update_bolt_acked_latency(input.getSourceComponent(), input.getSourceStreamId(), latencyStart, endTime); } }
@Override public void fail(Tuple input) { // if ackerNum == 0, we can just return if (input.getMessageId() != null) { pendingAcks.remove(input); for (Map.Entry<Long, Long> e : input.getMessageId().getAnchorsToIds().entrySet()) { List<Object> ackTuple = JStormUtils.mk_list((Object) e.getKey()); sendBoltMsg(Acker.ACKER_FAIL_STREAM_ID, null, ackTuple, null, null); } } taskStats.bolt_failed_tuple(input.getSourceComponent(), input.getSourceStreamId()); }
public byte[] serialize(Tuple tuple) { try { _outputter.reset(); WritableUtils.writeVInt(_dataOutputter, tuple.getSourceTask()); WritableUtils.writeVInt(_dataOutputter, _ids.getStreamId(tuple.getSourceComponent(), tuple.getSourceStreamId())); tuple.getMessageId().serialize(_dataOutputter); _kryo.serializeInto(tuple.getValues(), _outputter); return _outputter.toByteArray(); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public void fail(Tuple input) { // if ackerNum == 0, we can just return if (input.getMessageId() != null) { pendingAcks.remove(input); for (Entry<Long, Long> e : input.getMessageId().getAnchorsToIds().entrySet()) { unanchoredSend(topologyContext, sendTargets, taskTransfer, Acker.ACKER_FAIL_STREAM_ID, JStormUtils.mk_list((Object) e.getKey())); } } tupleStartTimes.remove(input); taskStats.bolt_failed_tuple(input.getSourceComponent(), input.getSourceStreamId()); }
@Override public void ack(Tuple input) { Pair<Long, Integer> pendingBatch = tracker.getPendingBatch(((TupleImplExt) input).getBatchId(), input.getSourceStreamId()); if (pendingBatch != null) { long rootId = getRootId(input); if (rootId != 0) pendingBatch.setFirst(JStormUtils.bit_xor(pendingBatch.getFirst(), rootId)); } delegate.ack(input); }
private BoltMsg createBoltMessage(Tuple input, String genId) { BoltMsg boltMsg = new BoltMsg(); boltMsg.setId(genId); boltMsg.setComp(input.getSourceComponent()); boltMsg.setStream(input.getSourceStreamId()); boltMsg.setTask(input.getSourceTask()); boltMsg.setTuple(input.getValues()); return boltMsg; }
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { TransactionAttempt attempt = (TransactionAttempt) tuple.getValue(0); if (tuple.getSourceStreamId().equals(MasterBatchCoordinator.SUCCESS_STREAM_ID)) { _state.cleanupBefore(attempt.getTransactionId()); _coord.success(attempt.getTransactionId()); } else { long txid = attempt.getTransactionId(); Object prevMeta = _state.getPreviousState(txid); Object meta = _coord.initializeTransaction(txid, prevMeta, _state.getState(txid)); _state.overrideState(txid, meta); collector.emit(MasterBatchCoordinator.BATCH_STREAM_ID, new Values(attempt, meta)); } }
@Override public void execute(Tuple input) { long rootId = getRootId(input); if (rootId != 0) { long batchId = ((TupleImplExt) input).getBatchId(); String streamId = input.getSourceStreamId(); Pair<Long, Integer> pendingBatch = batchXorTracker.getPendingBatch(batchId, streamId, true); if (pendingBatch == null) { pendingBatch = new Pair<>(0l, 0); batchXorTracker.putPendingBatch(batchId, streamId, pendingBatch); } pendingBatch.setFirst(JStormUtils.bit_xor(pendingBatch.getFirst(), rootId)); int count = pendingBatch.getSecond(); pendingBatch.setSecond(++count); } bolt.execute(input); }