Repository: storm Updated Branches: refs/heads/1.x-branch ca2447217 -> 0ded1de06
backport change from master: add convenience methods for checking tuple type in node.js library Project: http://git-wip-us.apache.org/repos/asf/storm/repo Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/b8e7e4d3 Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/b8e7e4d3 Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/b8e7e4d3 Branch: refs/heads/1.x-branch Commit: b8e7e4d33a4bf98ee77901a76e554919d0ab2d61 Parents: 77b5af1 Author: David Luu <[email protected]> Authored: Sun May 8 15:39:22 2016 -0700 Committer: David Luu <[email protected]> Committed: Sun May 8 15:39:22 2016 -0700 ---------------------------------------------------------------------- .../src/main/resources/resources/storm.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/storm/blob/b8e7e4d3/storm-multilang/javascript/src/main/resources/resources/storm.js ---------------------------------------------------------------------- diff --git a/storm-multilang/javascript/src/main/resources/resources/storm.js b/storm-multilang/javascript/src/main/resources/resources/storm.js index dc6efc1..c8462ba 100755 --- a/storm-multilang/javascript/src/main/resources/resources/storm.js +++ b/storm-multilang/javascript/src/main/resources/resources/storm.js @@ -199,7 +199,7 @@ Storm.prototype.emitDirect = function(commandDetails) { /** * Initialize storm component according to the configuration received. - * @param conf configuration object accrding to storm protocol. + * @param conf configuration object according to storm protocol. * @param context context object according to storm protocol. * @param done callback. Call this method when finished initializing. */ @@ -221,10 +221,18 @@ function Tuple(id, component, stream, task, values) { this.values = values; } +Tuple.prototype.isTickTuple = function(){ + return this.task === -1 && this.stream === "__tick"; +} + +Tuple.prototype.isHeartbeatTuple = function(){ + return this.task === -1 && this.stream === "__heartbeat"; +} + /** * Base class for storm bolt. * To create a bolt implement 'process' method. - * You may also implement initialize method to + * You may also implement initialize method too */ function BasicBolt() { Storm.call(this); @@ -262,7 +270,7 @@ BasicBolt.prototype.handleNewCommand = function(command) { var self = this; var tup = new Tuple(command["id"], command["comp"], command["stream"], command["task"], command["tuple"]); - if (tup.task === -1 && tup.stream === "__heartbeat") { + if (tup.isHeartbeatTuple()) { self.sync(); return; } @@ -293,7 +301,6 @@ BasicBolt.prototype.fail = function(tup, err) { this.sendMsgToParent({"command": "fail", "id": tup.id}); } - /** * Base class for storm spout. * To create a spout implement the following methods: nextTuple, ack and fail (nextTuple - mandatory, ack and fail @@ -370,4 +377,4 @@ Spout.prototype.__emit = function(commandDetails) { } module.exports.BasicBolt = BasicBolt; -module.exports.Spout = Spout; \ No newline at end of file +module.exports.Spout = Spout;
