public List<Integer> emit(List<Object> tuple) { return emit(Utils.DEFAULT_STREAM_ID, tuple); }
public void execute(Tuple input) { _collector.setContext(input); try { _bolt.execute(input, _collector); _collector.getOutputter().ack(input); } catch (FailedException e) { if (e instanceof ReportedFailedException) { _collector.reportError(e); } _collector.getOutputter().fail(input); } }
public void prepare(Map<String, Object> topoConf, TopologyContext context, OutputCollector collector) { _bolt.prepare(topoConf, context); _collector = new BasicOutputCollector(collector); }
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { try { // do something which might fail here... } catch (Exception e) { // do you want to log the error? LOG.error("Bolt error {}", e); // do you want the error to show up in storm UI? collector.reportError(e); // or just put information on the queue for processing later } }
public void emitDirect(int taskId, List<Object> tuple) { emitDirect(taskId, Utils.DEFAULT_STREAM_ID, tuple); }
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { try { if (isTickTuple(tuple)) { // refresh our configs from HDFS _fileLoader.load(_configs); return; } // do your bolt stuff // use configs you loaded earlier // ... } catch (Exception e) { LOG.error("Bolt execute error: {}", e); collector.reportError(e); } }
public void emitDirect(int taskId, List<Object> tuple) { emitDirect(taskId, Utils.DEFAULT_STREAM_ID, tuple); }
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { System.out.println(tuple); LOG.debug("Got tuple {}", tuple); collector.emit(tuple.getValues()); }
public void execute(Tuple input) { _collector.setContext(input); try { _bolt.execute(input, _collector); _collector.getOutputter().ack(input); } catch(FailedException e) { if(e instanceof ReportedFailedException) { _collector.reportError(e); } _collector.getOutputter().fail(input); } }
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { try { DataBean bean = (DataBean)tuple.getValue(0); // do your bolt processing with the bean } catch (Exception e) { LOG.error("WordCountBolt error", e); collector.reportError(e); } }
@Override @SuppressWarnings("rawtypes") public void prepare(Map stormConf, TopologyContext context, OutputCollector newCollector) { delegate.prepare(stormConf, context); this.collector = new BasicOutputCollector(newCollector); }
public void emitDirect(int taskId, List<Object> tuple) { emitDirect(taskId, Utils.DEFAULT_STREAM_ID, tuple); }
@Override public void execute(Tuple input, BasicOutputCollector collector) { collector.emit(input.getValues()); }
@Override public void execute(Tuple input) { this.collector.setContext(input); try { delegate.execute(input, collector); this.collector.getOutputter().ack(input); } catch (FailedException e) { if (e instanceof ReportedFailedException) { this.collector.reportError(e); } this.collector.getOutputter().fail(input); } }
public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { _bolt.prepare(stormConf, context); _collector = new BasicOutputCollector(collector); }
public void execute(Tuple input, BasicOutputCollector collector) { String word = input.getStringByField("word"); int count; if (wordCounter.containsKey(word)) { count = wordCounter.get(word) + 1; wordCounter.put(word, wordCounter.get(word) + 1); } else { count = 1; } wordCounter.put(word, count); collector.emit(new Values(word, String.valueOf(count))); }
public void execute(Tuple input, BasicOutputCollector collector) { total = total.add(new BigInteger(input.getValues().get(1).toString())); collector.emit(tuple(total.toString())); //prints the total with low probability. if(RANDOM.nextInt(1000) > 995) { LOG.info("Running total = " + total); } }
public void execute(Tuple input, BasicOutputCollector collector) { total = total.add(new BigInteger(input.getValues().get(1).toString())); collector.emit(tuple(total.toString())); //prints the total with low probability. if (RANDOM.nextInt(1000) > 995) { LOG.info("Running total = " + total); } }
public void execute(Tuple input, BasicOutputCollector collector) { String word = input.getStringByField("word"); int count; if (wordCounter.containsKey(word)) { count = wordCounter.get(word) + 1; wordCounter.put(word, wordCounter.get(word) + 1); } else { count = 1; } wordCounter.put(word, count); collector.emit(new Values(word, String.valueOf(count))); }
public void execute(Tuple input, BasicOutputCollector collector) { String word = getTupleValue(input, 0); int count = 0; if (_counts.containsKey(word)) { count = _counts.get(word); } count++; _counts.put(word, count); collector.emit(tuple(word, count)); }