@Override public void ack(Object msgId) { if (acked == 0) { ackTimer = Timer.timer(); } acked++; if (acked % 1000 == 0) { emitToAckQueue(); } }
@Override public void nextTuple() { getSomeMoreTuples(); if (this.tuples.size() == 0) { Utils.sleep(10); return; } final EmitItem poll = this.tuples.poll(); collector.emit(poll.tuple, poll.sourceId); // collector.emit(poll.tuple); }
private void emitToAckQueue() { logger.debug("Acked: " + acked); final float throughput = acked / ((float) ackTimer.duration() / 1000); if (this.ackQueue != null) { final AckStats stats = new AckStats(throughput); final KestrelThriftClient client = getNextValidClient(); try { client.put(this.ackQueue, gson.toJson(stats), 0); } catch (final TException e) { logger.error("Failed to write acknowledgement"); } } }
@Override public StormTopology constructTopology() { TopologyBuilder b = new TopologyBuilder(); b.setSpout("twitterKestrelSpout", new UnreliableKestrelThriftSpout(kestrelSpecList, new StringScheme("tweet"), inputQueue)); TweetPreprocessingBolt bolt = new TweetPreprocessingBolt(outputQueue, kestrelHosts, twitterOptions.split(" ")); bolt.setExpireTime(this.expire); b.setBolt("preprocessing", bolt).shuffleGrouping("twitterKestrelSpout"); return b.createTopology(); }
private void emitToAckQueue() { logger.debug("Acked: " + acked); final float throughput = acked / ((float) ackTimer.duration() / 1000); if (this.ackQueue != null) { final AckStats stats = new AckStats(throughput); final KestrelThriftClient client = getNextValidClient(); try { client.put(this.ackQueue, gson.toJson(stats), 0); } catch (final TException e) { logger.error("Failed to write acknowledgement"); } } }
@Override public void nextTuple() { getSomeMoreTuples(); if (this.tuples.size() == 0) { Utils.sleep(10); return; } final EmitItem poll = this.tuples.poll(); collector.emit(poll.tuple, poll.sourceId); // collector.emit(poll.tuple); }
@Override public void ack(Object msgId) { if (acked == 0) { ackTimer = Timer.timer(); } acked++; if (acked % 1000 == 0) { emitToAckQueue(); } }