@Override public void process(Object event) throws Exception { Tuple tuple = (Tuple) event; for (int boltTaskId : boltTasks) { collector.emitDirectCtrl(boltTaskId, TopologyMaster.USER_DEFINED_STREAM, tuple.getValues()); } }
@Override public void execute(Tuple input, BasicOutputCollector collector) { collector.emit(input.getValues()); }
private long getRootId(Tuple input) { int rootIdIndex = input.getValues().size() - 1; return (long) input.getValue(rootIdIndex); }
public void execute(Tuple input) { String word = (String) input.getValues().get(0); int count = (Integer) input.getValues().get(1); _counts.put(word, count); int globalCount = 0; for (String w : _counts.keySet()) { globalCount += _counts.get(w); } _collector.emit(tuple(globalCount)); _collector.ack(input); }
public void execute(Tuple input, BasicOutputCollector collector) { String word = (String) input.getValues().get(0); int count = 0; if (_counts.containsKey(word)) { count = _counts.get(word); } count++; _counts.put(word, count); collector.emit(tuple(word, count)); }
@Override public void execute(Tuple input, BasicOutputCollector collector) { long id = Utils.secureRandomLong(); List<Object> toEmit = new ArrayList<>(); toEmit.add(id); toEmit.addAll(input.getValues()); collector.emit(toEmit); }
@Override public void execute(Tuple input, BasicOutputCollector collector) { collector.emit(input.getValues()); }
/** * Construct a new instance based on the provided {@link Tuple}. * <p/> * This method expects the object to be ranked in the first field (index 0) * of the provided tuple, and the number of occurrences of the object (its * count) in the second field (index 1). Any further fields in the tuple * will be extracted and tracked, too. These fields can be accessed via * {@link RankableObjectWithFields#getFields()}. * * @param tuple * * @return new instance based on the provided tuple */ public static RankableObjectWithFields from(Tuple tuple) { List<Object> otherFields = Lists.newArrayList(tuple.getValues()); Object obj = otherFields.remove(0); Long count = (Long) otherFields.remove(0); return new RankableObjectWithFields(obj, count, otherFields.toArray()); }
@Override public void execute(Tuple tuple, Object state, TimeWindow window) { LOG.info("executing on window:{}", window); Map<String, Integer> counts = (Map<String, Integer>) state; List<Object> partialWordCounts = tuple.getValues(); for (Object partialWordCount : partialWordCounts) { Pair<String, Integer> pair = (Pair<String, Integer>) partialWordCount; counts.put(pair.getFirst(), pair.getSecond()); } }
public void execute(Tuple input) { String word = (String) input.getValues().get(0); int count = (Integer) input.getValues().get(1); _counts.put(word, count); int globalCount = 0; for(String w: _counts.keySet()) { globalCount+=_counts.get(w); } _collector.emit(tuple(globalCount)); _collector.ack(input); }
public void execute(Tuple input, BasicOutputCollector collector) { String word = (String) input.getValues().get(0); int count = 0; if(_counts.containsKey(word)) { count = _counts.get(word); } count++; _counts.put(word, count); collector.emit(tuple(word, count)); }
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); }
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); }
public TridentTuple create(Tuple parent) { return new TridentTupleView(PersistentVector.EMPTY.cons(parent.getValues()), index, fieldIndex); }
public long crc32(Tuple tuple) { try { CRC32OutputStream hasher = new CRC32OutputStream(); _kryo.serializeInto(tuple.getValues(), hasher); return hasher.getValue(); } catch (IOException e) { throw new RuntimeException(e); } } }
private void processTupleBatchEvent(Tuple tuple) { try { if ((!isSystemBolt && tuple.getSourceStreamId().equals(Common.TOPOLOGY_MASTER_CONTROL_STREAM_ID)) || tuple.getSourceStreamId().equals(Common.TOPOLOGY_MASTER_REGISTER_METRICS_RESP_STREAM_ID)) { if (tuple.getValues().get(0) instanceof Pair) { for (Object value : tuple.getValues()) { Pair<MessageId, List<Object>> val = (Pair<MessageId, List<Object>>) value; TupleImplExt t = new TupleImplExt( sysTopologyCtx, val.getSecond(), val.getFirst(), ((TupleImplExt) tuple)); processTupleEvent(t); } } } else { bolt.execute(tuple); } } catch (Throwable e) { error = e; LOG.error("bolt execute error ", e); reportError.report(e); } }
@Override public void process(Object event) throws Exception { if (event instanceof UpdateConfigEvent) { update(((UpdateConfigEvent) event).getConf()); return; } Tuple input = (Tuple) event; TopoMasterCtrlEvent ctlEvent = (TopoMasterCtrlEvent) input.getValues().get(0); if (ctlEvent != null) { if (ctlEvent.isTransactionEvent()) { snapshotStateMaster.process(input); } else { String errorInfo = "Received unexpected control event, {}" + event.toString(); LOG.warn(errorInfo); zkCluster.report_task_error(context.getTopologyId(), context.getThisTaskId(), errorInfo, ErrorConstants.WARN, ErrorConstants.CODE_USER); } } }
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); } }
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; }