public void flush() { out.flush(); }
@Override public List<Integer> emit(String ignore, List<Object> values, Object msgId) { long batchIdVal = _rand.nextLong(); Object batchId = new RichSpoutBatchId(batchIdVal); FinishCondition finish = new FinishCondition(); finish.msgId = msgId; List<Integer> tasks = new ArrayList<>(); _collector.emit(_stream, new ConsList(batchId, values), new CollectorCb(tasks)); _collector.flush(); Set<Integer> outTasksSet = new HashSet<>(tasks); for(Integer t: _outputTasks) { int count = 0; if(outTasksSet.contains(t)) { count = 1; } long r = _rand.nextLong(); _collector.emitDirect(t, _coordStream, new Values(batchId, count), r); finish.vals.add(r); _msgIdToBatchId.put(r, batchIdVal); } _finishConditions.put(batchIdVal, finish); return tasks; }
@Override public void close() { if (JStormUtils.isKilledStatus(context)){ JStormUtils.sleepMs(10); int sendNum = 0; for (List<Integer> tasks : _targetTasks.values()) { for (Integer task : tasks) { sendNum++; _collector.emitDirect(task, new Values()); } } _collector.flush(); LOG.info("this component already sent {} finish messages", sendNum); JStormUtils.sleepMs(100); } }
public void flush(){ out.flush();}
@Override public List<Integer> emit(String ignore, List<Object> values, Object msgId) { long batchIdVal = _rand.nextLong(); Object batchId = new RichSpoutBatchId(batchIdVal); FinishCondition finish = new FinishCondition(); finish.msgId = msgId; List<Integer> tasks = new ArrayList<>(); _collector.emit(_stream, new ConsList(batchId, values), new CollectorCb(tasks)); _collector.flush(); Set<Integer> outTasksSet = new HashSet<>(tasks); for(Integer t: _outputTasks) { int count = 0; if(outTasksSet.contains(t)) { count = 1; } long r = _rand.nextLong(); _collector.emitDirect(t, _coordStream, new Values(batchId, count), r); finish.vals.add(r); _msgIdToBatchId.put(r, batchIdVal); } _finishConditions.put(batchIdVal, finish); return tasks; }