You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by bo...@apache.org on 2017/04/17 17:19:08 UTC

[1/2] storm git commit: Merge branch 'STORM-2435' of https://github.com/XC-/storm into STORM-2435

Repository: storm
Updated Branches:
  refs/heads/1.x-branch 287f9daaa -> 052b67738


Merge branch 'STORM-2435' of https://github.com/XC-/storm into STORM-2435

STORM-2435: Logging levels and consistency with console.log etc


Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/d2c9ec2d
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/d2c9ec2d
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/d2c9ec2d

Branch: refs/heads/1.x-branch
Commit: d2c9ec2da5dfe3826f528b434afbf1fc014e28f1
Parents: 287f9da
Author: Robert Evans <ev...@yahoo-inc.com>
Authored: Wed Apr 12 20:59:06 2017 -0500
Committer: Robert Evans <ev...@yahoo-inc.com>
Committed: Mon Apr 17 10:51:24 2017 -0500

----------------------------------------------------------------------
 .../src/main/resources/resources/storm.js       | 121 ++++++++++++-------
 1 file changed, 75 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/d2c9ec2d/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 206119c..25e0a6d 100755
--- a/storm-multilang/javascript/src/main/resources/resources/storm.js
+++ b/storm-multilang/javascript/src/main/resources/resources/storm.js
@@ -25,38 +25,67 @@
 var fs = require('fs');
 
 function Storm() {
-    this.messagePart = "";
+    this.messagePart = '';
     this.taskIdsCallbacks = [];
     this.isFirstMessage = true;
     this.separator = '\nend\n';
+    this.logLevels = {
+        trace: 0, debug: 1, info: 2, warn: 3, error: 4
+    }
 }
 
 Storm.prototype.sendMsgToParent = function(msg) {
     var str = JSON.stringify(msg);
     process.stdout.write(str + this.separator);
-}
+};
 
 Storm.prototype.sync = function() {
-    this.sendMsgToParent({"command":"sync"});
-}
+    this.sendMsgToParent({'command':'sync'});
+};
 
 Storm.prototype.sendPid = function(heartbeatdir) {
     var pid = process.pid;
-    fs.closeSync(fs.openSync(heartbeatdir + "/" + pid, "w"));
-    this.sendMsgToParent({"pid": pid})
-}
+    fs.closeSync(fs.openSync(heartbeatdir + '/' + pid, 'w'));
+    this.sendMsgToParent({'pid': pid})
+};
+Storm.prototype.sendToLogging = function(args, logLevel) {
+    var argArray = Object.keys(args).map(function(key) {
+        return (typeof args[key] === 'string') ? args[key] : JSON.stringify(args[key]);
+    });
+    var msg = argArray.join(' ');
+    this.sendMsgToParent({'command': 'log', 'msg': msg, 'level': logLevel});
+};
 
-Storm.prototype.log = function(msg) {
-    this.sendMsgToParent({"command": "log", "msg": msg});
-}
+Storm.prototype.logTrace = function() {
+    this.sendToLogging(arguments, this.logLevels.trace);
+};
+
+Storm.prototype.logDebug = function() {
+    this.sendToLogging(arguments, this.logLevels.debug);
+};
+
+Storm.prototype.logInfo = function() {
+    this.sendToLogging(arguments, this.logLevels.info);
+};
+
+Storm.prototype.logWarn = function() {
+    this.sendToLogging(arguments, this.logLevels.warn);
+};
+
+Storm.prototype.logError = function() {
+    this.sendToLogging(arguments, this.logLevels.error);
+};
+
+// For backwards compatibility
+Storm.prototype.log = Storm.prototype.logInfo;
 
 Storm.prototype.initSetupInfo = function(setupInfo) {
     var self = this;
     var callback = function() {
         self.sendPid(setupInfo['pidDir']);
-    }
+    };
     this.initialize(setupInfo['conf'], setupInfo['context'], callback);
-}
+};
 
 Storm.prototype.startReadingInput = function() {
     var self = this;
@@ -68,7 +97,7 @@ Storm.prototype.startReadingInput = function() {
         })
 
     });
-}
+};
 
 /**
  * receives a new string chunk and returns a list of new messages with the separator removed
@@ -98,11 +127,11 @@ Storm.prototype.handleNewChunk = function(chunk) {
         }
     }
     return messages;
-}
+};
 
 Storm.prototype.isTaskIds = function(msg) {
     return (msg instanceof Array);
-}
+};
 
 Storm.prototype.handleNewMessage = function(msg) {
     var parsedMsg = JSON.parse(msg);
@@ -115,7 +144,7 @@ Storm.prototype.handleNewMessage = function(msg) {
     } else {
         this.handleNewCommand(parsedMsg);
     }
-}
+};
 
 Storm.prototype.handleNewTaskId = function(taskIds) {
     //When new list of task ids arrives, the callback that was passed with the corresponding emit should be called.
@@ -128,7 +157,7 @@ Storm.prototype.handleNewTaskId = function(taskIds) {
     } else {
         throw new Error('Something went wrong, we off the split of task id callbacks');
     }
-}
+};
 
 
 
@@ -166,8 +195,8 @@ Storm.prototype.emit = function(messageDetails, onTaskIds) {
     }
 
     this.taskIdsCallbacks.push(onTaskIds);
-    this.__emit(messageDetails);;
-}
+    this.__emit(messageDetails);
+};
 
 
 /**
@@ -193,10 +222,10 @@ Storm.prototype.emit = function(messageDetails, onTaskIds) {
  */
 Storm.prototype.emitDirect = function(commandDetails) {
     if (!commandDetails.task) {
-        throw new Error("Emit direct must receive task id!")
+        throw new Error('Emit direct must receive task id!')
     }
     this.__emit(commandDetails);
-}
+};
 
 /**
  * Initialize storm component according to the configuration received.
@@ -206,13 +235,13 @@ Storm.prototype.emitDirect = function(commandDetails) {
  */
 Storm.prototype.initialize = function(conf, context, done) {
     done();
-}
+};
 
 Storm.prototype.run = function() {
     process.stdout.setEncoding('utf8');
     process.stdin.setEncoding('utf8');
     this.startReadingInput();
-}
+};
 
 function Tuple(id, component, stream, task, values) {
     this.id = id;
@@ -223,12 +252,12 @@ function Tuple(id, component, stream, task, values) {
 }
 
 Tuple.prototype.isTickTuple = function(){
-  return this.task === -1 && this.stream === "__tick";
-}
+  return this.task === -1 && this.stream === '__tick';
+};
 
 Tuple.prototype.isHeartbeatTuple = function(){
-  return this.task === -1 && this.stream === "__heartbeat";
-}
+  return this.task === -1 && this.stream === '__heartbeat';
+};
 
 /**
  * Base class for storm bolt.
@@ -238,7 +267,7 @@ Tuple.prototype.isHeartbeatTuple = function(){
 function BasicBolt() {
     Storm.call(this);
     this.anchorTuple = null;
-};
+}
 
 BasicBolt.prototype = Object.create(Storm.prototype);
 BasicBolt.prototype.constructor = BasicBolt;
@@ -264,7 +293,7 @@ BasicBolt.prototype.__emit = function(commandDetails) {
     }
 
     var message = {
-        command: "emit",
+        command: 'emit',
         tuple: commandDetails.tuple,
         stream: commandDetails.stream,
         task: commandDetails.task,
@@ -272,11 +301,11 @@ BasicBolt.prototype.__emit = function(commandDetails) {
     };
 
     this.sendMsgToParent(message);
-}
+};
 
 BasicBolt.prototype.handleNewCommand = function(command) {
     var self = this;
-    var tup = new Tuple(command["id"], command["comp"], command["stream"], command["task"], command["tuple"]);
+    var tup = new Tuple(command['id'], command['comp'], command['stream'], command['task'], command['tuple']);
 
     if (tup.isHeartbeatTuple()) {
         self.sync();
@@ -289,9 +318,9 @@ BasicBolt.prototype.handleNewCommand = function(command) {
             return;
         }
         self.ack(tup);
-    }
+    };
     this.process(tup, callback);
-}
+};
 
 /**
  * Implement this method when creating a bolt. This is the main method that provides the logic of the bolt (what
@@ -302,12 +331,12 @@ BasicBolt.prototype.handleNewCommand = function(command) {
 BasicBolt.prototype.process = function(tuple, done) {};
 
 BasicBolt.prototype.ack = function(tup) {
-    this.sendMsgToParent({"command": "ack", "id": tup.id});
-}
+    this.sendMsgToParent({'command': 'ack', 'id': tup.id});
+};
 
 BasicBolt.prototype.fail = function(tup, err) {
-    this.sendMsgToParent({"command": "fail", "id": tup.id});
-}
+    this.sendMsgToParent({'command': 'fail', 'id': tup.id});
+};
 
 /**
  * Base class for storm spout.
@@ -318,7 +347,7 @@ BasicBolt.prototype.fail = function(tup, err) {
  */
 function Spout() {
     Storm.call(this);
-};
+}
 
 Spout.prototype = Object.create(Storm.prototype);
 
@@ -351,18 +380,18 @@ Spout.prototype.handleNewCommand = function(command) {
         self.sync();
     }
 
-    if (command["command"] === "next") {
+    if (command['command'] === 'next') {
         this.nextTuple(callback);
     }
 
-    if (command["command"] === "ack") {
-        this.ack(command["id"], callback);
+    if (command['command'] === 'ack') {
+        this.ack(command['id'], callback);
     }
 
-    if (command["command"] === "fail") {
-        this.fail(command["id"], callback);
+    if (command['command'] === 'fail') {
+        this.fail(command['id'], callback);
     }
-}
+};
 
 /**
  * @param commandDetails json with the required fields:
@@ -374,7 +403,7 @@ Spout.prototype.handleNewCommand = function(command) {
  */
 Spout.prototype.__emit = function(commandDetails) {
     var message = {
-        command: "emit",
+        command: 'emit',
         tuple: commandDetails.tuple,
         id: commandDetails.id,
         stream: commandDetails.stream,
@@ -382,7 +411,7 @@ Spout.prototype.__emit = function(commandDetails) {
     };
 
     this.sendMsgToParent(message);
-}
+};
 
 module.exports.BasicBolt = BasicBolt;
 module.exports.Spout = Spout;


[2/2] storm git commit: Added STORM-2435 to Changelog

Posted by bo...@apache.org.
Added STORM-2435 to Changelog


Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/052b6773
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/052b6773
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/052b6773

Branch: refs/heads/1.x-branch
Commit: 052b67738d1511b1ec7ef5e281a4cb0aeda3edb0
Parents: d2c9ec2
Author: Robert Evans <ev...@yahoo-inc.com>
Authored: Mon Apr 17 10:52:07 2017 -0500
Committer: Robert Evans <ev...@yahoo-inc.com>
Committed: Mon Apr 17 10:52:07 2017 -0500

----------------------------------------------------------------------
 CHANGELOG.md | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/052b6773/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 420a66f..724e9bb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,5 @@
 \ufeff## 1.1.1
+ * STORM-2435: Logging in storm.js inconsistent to console.log and does not support log levels
  * STORM-2315: New kafka spout can't commit offset when ack is disabled
  * STORM-2467: Use explicit charset when decoding from array backed buffer
  * STORM-1114: Race condition in trident zookeeper zk-node create/delete