Repository: storm
Updated Branches:
  refs/heads/0.10.x-branch 09cd78d27 -> f9f72f30d


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/fe115799
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/fe115799
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/fe115799

Branch: refs/heads/0.10.x-branch
Commit: fe11579905f454e14af876f87e3c208431196bee
Parents: bc06c83
Author: David Luu <[email protected]>
Authored: Sun May 8 15:34:48 2016 -0700
Committer: David Luu <[email protected]>
Committed: Sun May 8 15:34:48 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/fe115799/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;

Reply via email to